diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-04-15 14:03:50 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:17:55 -0400 |
commit | acb5451789f21ad51215897bb8f9306a05e8acd4 (patch) | |
tree | 7ab1d73a9b4fbbc82a5a2a98dda701a81c4eaf33 /arch/x86 | |
parent | 6b18493d60e7f54a0feb771fa141b5fcb72ce1e4 (diff) |
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')
-rw-r--r-- | arch/x86/kvm/svm.c | 10 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 78af52222fd2..ab78eb8ba899 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -2266,8 +2266,14 @@ static int task_switch_interception(struct vcpu_svm *svm) | |||
2266 | (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) | 2266 | (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) |
2267 | skip_emulated_instruction(&svm->vcpu); | 2267 | skip_emulated_instruction(&svm->vcpu); |
2268 | 2268 | ||
2269 | return kvm_task_switch(&svm->vcpu, tss_selector, reason, | 2269 | if (kvm_task_switch(&svm->vcpu, tss_selector, reason, |
2270 | has_error_code, error_code); | 2270 | has_error_code, error_code) == EMULATE_FAIL) { |
2271 | svm->vcpu.run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | ||
2272 | svm->vcpu.run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | ||
2273 | svm->vcpu.run->internal.ndata = 0; | ||
2274 | return 0; | ||
2275 | } | ||
2276 | return 1; | ||
2271 | } | 2277 | } |
2272 | 2278 | ||
2273 | static int cpuid_interception(struct vcpu_svm *svm) | 2279 | static int cpuid_interception(struct vcpu_svm *svm) |
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) | |||
3316 | type != INTR_TYPE_NMI_INTR)) | 3316 | type != INTR_TYPE_NMI_INTR)) |
3317 | skip_emulated_instruction(vcpu); | 3317 | skip_emulated_instruction(vcpu); |
3318 | 3318 | ||
3319 | if (!kvm_task_switch(vcpu, tss_selector, reason, has_error_code, | 3319 | if (kvm_task_switch(vcpu, tss_selector, reason, |
3320 | error_code)) | 3320 | has_error_code, error_code) == EMULATE_FAIL) { |
3321 | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | ||
3322 | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | ||
3323 | vcpu->run->internal.ndata = 0; | ||
3321 | return 0; | 3324 | return 0; |
3325 | } | ||
3322 | 3326 | ||
3323 | /* clear all local breakpoint enable flags */ | 3327 | /* clear all local breakpoint enable flags */ |
3324 | vmcs_writel(GUEST_DR7, vmcs_readl(GUEST_DR7) & ~55); | 3328 | vmcs_writel(GUEST_DR7, vmcs_readl(GUEST_DR7) & ~55); |