diff options
author | Avi Kivity <avi@redhat.com> | 2010-12-05 11:56:11 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:31:16 -0500 |
commit | aff48baa34c033318ad322ecbf2e4bcd891b29ca (patch) | |
tree | 84955c55c812dd540cd0c54e5bdf6d3f5bfd08be /arch/x86/kvm/x86.c | |
parent | 9f8fe5043fd26627c2fa2e9a41896885e675000b (diff) |
KVM: Fetch guest cr3 from hardware on demand
Instead of syncing the guest cr3 every exit, which is expensince on vmx
with ept enabled, sync it only on demand.
[sheng: fix incorrect cr3 seen by Windows XP]
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6e50314d64fb..fa708c9a7437 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -667,6 +667,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) | |||
667 | if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT))) | 667 | if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT))) |
668 | return 1; | 668 | return 1; |
669 | vcpu->arch.cr3 = cr3; | 669 | vcpu->arch.cr3 = cr3; |
670 | __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail); | ||
670 | vcpu->arch.mmu.new_cr3(vcpu); | 671 | vcpu->arch.mmu.new_cr3(vcpu); |
671 | return 0; | 672 | return 0; |
672 | } | 673 | } |
@@ -5583,6 +5584,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5583 | vcpu->arch.cr2 = sregs->cr2; | 5584 | vcpu->arch.cr2 = sregs->cr2; |
5584 | mmu_reset_needed |= kvm_read_cr3(vcpu) != sregs->cr3; | 5585 | mmu_reset_needed |= kvm_read_cr3(vcpu) != sregs->cr3; |
5585 | vcpu->arch.cr3 = sregs->cr3; | 5586 | vcpu->arch.cr3 = sregs->cr3; |
5587 | __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail); | ||
5586 | 5588 | ||
5587 | kvm_set_cr8(vcpu, sregs->cr8); | 5589 | kvm_set_cr8(vcpu, sregs->cr8); |
5588 | 5590 | ||