summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorGleb Natapov2010-04-15 20:03:50 +0200
committerAvi Kivity2010-05-17 11:17:55 +0200
commitacb5451789f21ad51215897bb8f9306a05e8acd4 (patch)
tree7ab1d73a9b4fbbc82a5a2a98dda701a81c4eaf33 /arch/x86/kvm/vmx.c
parentKVM: MMU: remove unused parameter in mmu_parent_walk() (diff)
downloadkernel-qcow2-linux-acb5451789f21ad51215897bb8f9306a05e8acd4.tar.gz
kernel-qcow2-linux-acb5451789f21ad51215897bb8f9306a05e8acd4.tar.xz
kernel-qcow2-linux-acb5451789f21ad51215897bb8f9306a05e8acd4.zip
KVM: prevent spurious exit to userspace during task switch emulation.
If kvm_task_switch() fails code exits to userspace without specifying exit reason, so the previous exit reason is reused by userspace. Fix this by specifying exit reason correctly. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1b38d8a88cf7..6e5e75e0d7d3 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3316,9 +3316,13 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
type != INTR_TYPE_NMI_INTR))
skip_emulated_instruction(vcpu);
- if (!kvm_task_switch(vcpu, tss_selector, reason, has_error_code,
- error_code))
+ if (kvm_task_switch(vcpu, tss_selector, reason,
+ has_error_code, error_code) == EMULATE_FAIL) {
+ vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
+ vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
+ vcpu->run->internal.ndata = 0;
return 0;
+ }
/* clear all local breakpoint enable flags */
vmcs_writel(GUEST_DR7, vmcs_readl(GUEST_DR7) & ~55);