diff options
author | Avi Kivity <avi@redhat.com> | 2009-01-04 17:53:19 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-03-24 05:03:00 -0400 |
commit | 10f32d84c750ccf8c0afb3a4ea9d4059aa3e9ffc (patch) | |
tree | 308c71a5fa5401e4cb0c0e08c9acaa5dd7a2dc10 /arch/x86/kvm | |
parent | 9fd4a3b7a412f983696b23121413a79d2132fed6 (diff) |
KVM: VMX: Prevent exit handler from running if emulating due to invalid state
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>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/vmx.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a6598cbaa001..a309be6788e7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3130,7 +3130,6 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
3130 | static void handle_invalid_guest_state(struct kvm_vcpu *vcpu, | 3130 | static void handle_invalid_guest_state(struct kvm_vcpu *vcpu, |
3131 | struct kvm_run *kvm_run) | 3131 | struct kvm_run *kvm_run) |
3132 | { | 3132 | { |
3133 | struct vcpu_vmx *vmx = to_vmx(vcpu); | ||
3134 | int err; | 3133 | int err; |
3135 | 3134 | ||
3136 | preempt_enable(); | 3135 | preempt_enable(); |
@@ -3155,11 +3154,6 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu, | |||
3155 | 3154 | ||
3156 | local_irq_disable(); | 3155 | local_irq_disable(); |
3157 | preempt_disable(); | 3156 | preempt_disable(); |
3158 | |||
3159 | /* Guest state should be valid now except if we need to | ||
3160 | * emulate an MMIO */ | ||
3161 | if (guest_state_valid(vcpu)) | ||
3162 | vmx->emulation_required = 0; | ||
3163 | } | 3157 | } |
3164 | 3158 | ||
3165 | /* | 3159 | /* |
@@ -3208,8 +3202,11 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
3208 | 3202 | ||
3209 | /* If we need to emulate an MMIO from handle_invalid_guest_state | 3203 | /* If we need to emulate an MMIO from handle_invalid_guest_state |
3210 | * we just return 0 */ | 3204 | * we just return 0 */ |
3211 | if (vmx->emulation_required && emulate_invalid_guest_state) | 3205 | if (vmx->emulation_required && emulate_invalid_guest_state) { |
3206 | if (guest_state_valid(vcpu)) | ||
3207 | vmx->emulation_required = 0; | ||
3212 | return 0; | 3208 | return 0; |
3209 | } | ||
3213 | 3210 | ||
3214 | /* Access CR3 don't cause VMExit in paging mode, so we need | 3211 | /* Access CR3 don't cause VMExit in paging mode, so we need |
3215 | * to sync with guest real CR3. */ | 3212 | * to sync with guest real CR3. */ |