aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-06-10 10:02:16 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:46:35 -0400
commit2390218b6aa2eb3784b0a82fa811c19097dc793a (patch)
treefacf41c6ed5c3d2eafa939e7ab9209cc1594cddb /arch/x86/kvm/x86.c
parenta83b29c6ad6d6497e569edbc29e556a384cebddd (diff)
KVM: Fix mov cr3 #GP at wrong instruction
On Intel, we call skip_emulated_instruction() even if we injected a #GP, resulting in the #GP pointing at the wrong address. Fix by injecting the exception and skipping the instruction at the same place, so we can do just one or the other. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ed3af15d4404..795999e1ac19 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -565,7 +565,7 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
565} 565}
566EXPORT_SYMBOL_GPL(kvm_set_cr4); 566EXPORT_SYMBOL_GPL(kvm_set_cr4);
567 567
568static int __kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) 568int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
569{ 569{
570 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) { 570 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) {
571 kvm_mmu_sync_roots(vcpu); 571 kvm_mmu_sync_roots(vcpu);
@@ -604,12 +604,6 @@ static int __kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
604 vcpu->arch.mmu.new_cr3(vcpu); 604 vcpu->arch.mmu.new_cr3(vcpu);
605 return 0; 605 return 0;
606} 606}
607
608void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
609{
610 if (__kvm_set_cr3(vcpu, cr3))
611 kvm_inject_gp(vcpu, 0);
612}
613EXPORT_SYMBOL_GPL(kvm_set_cr3); 607EXPORT_SYMBOL_GPL(kvm_set_cr3);
614 608
615int __kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8) 609int __kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8)
@@ -3726,7 +3720,7 @@ static int emulator_set_cr(int cr, unsigned long val, struct kvm_vcpu *vcpu)
3726 vcpu->arch.cr2 = val; 3720 vcpu->arch.cr2 = val;
3727 break; 3721 break;
3728 case 3: 3722 case 3:
3729 res = __kvm_set_cr3(vcpu, val); 3723 res = kvm_set_cr3(vcpu, val);
3730 break; 3724 break;
3731 case 4: 3725 case 4:
3732 res = kvm_set_cr4(vcpu, mk_cr_64(kvm_read_cr4(vcpu), val)); 3726 res = kvm_set_cr4(vcpu, mk_cr_64(kvm_read_cr4(vcpu), val));