]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: VMX: Prevent exit handler from running if emulating due to invalid state
authorAvi Kivity <avi@redhat.com>
Sun, 4 Jan 2009 22:53:19 +0000 (00:53 +0200)
committerAvi Kivity <avi@redhat.com>
Tue, 24 Mar 2009 09:03:00 +0000 (11:03 +0200)
If we've just emulated an instruction, we won't have any valid exit
reason and associated information.

Fix by moving the clearing of the emulation_required flag to the exit handler.
This way the exit handler can notice that we've been emulating and abort
early.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/vmx.c

index a6598cbaa001cccc64cecf2c0021a11ffd1e5f75..a309be6788e74ce62f74f49ed7134f1ed84812ca 100644 (file)
@@ -3130,7 +3130,6 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
                                struct kvm_run *kvm_run)
 {
-       struct vcpu_vmx *vmx = to_vmx(vcpu);
        int err;
 
        preempt_enable();
@@ -3155,11 +3154,6 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
 
        local_irq_disable();
        preempt_disable();
-
-       /* Guest state should be valid now except if we need to
-        * emulate an MMIO */
-       if (guest_state_valid(vcpu))
-               vmx->emulation_required = 0;
 }
 
 /*
@@ -3208,8 +3202,11 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 
        /* If we need to emulate an MMIO from handle_invalid_guest_state
         * we just return 0 */
-       if (vmx->emulation_required && emulate_invalid_guest_state)
+       if (vmx->emulation_required && emulate_invalid_guest_state) {
+               if (guest_state_valid(vcpu))
+                       vmx->emulation_required = 0;
                return 0;
+       }
 
        /* Access CR3 don't cause VMExit in paging mode, so we need
         * to sync with guest real CR3. */