diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-11-29 11:51:49 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:30:07 -0500 |
commit | fc3a9157d3148ab91039c75423da8ef97be3e105 (patch) | |
tree | bd356d2ec06e34554691913419ac18cef1fcf3c9 /arch | |
parent | 2030753de70a8aed39543ed09c2360665b3af481 (diff) |
KVM: X86: Don't report L2 emulation failures to user-space
This patch prevents that emulation failures which result
from emulating an instruction for an L2-Guest results in
being reported to userspace.
Without this patch a malicious L2-Guest would be able to
kill the L1 by triggering a race-condition between an vmexit
and the instruction emulator.
With this patch the L2 will most likely only kill itself in
this situation.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 47e5a41cc40e..8b4d5fc08012 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4314,13 +4314,19 @@ EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt); | |||
4314 | 4314 | ||
4315 | static int handle_emulation_failure(struct kvm_vcpu *vcpu) | 4315 | static int handle_emulation_failure(struct kvm_vcpu *vcpu) |
4316 | { | 4316 | { |
4317 | int r = EMULATE_DONE; | ||
4318 | |||
4317 | ++vcpu->stat.insn_emulation_fail; | 4319 | ++vcpu->stat.insn_emulation_fail; |
4318 | trace_kvm_emulate_insn_failed(vcpu); | 4320 | trace_kvm_emulate_insn_failed(vcpu); |
4319 | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | 4321 | if (!is_guest_mode(vcpu)) { |
4320 | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | 4322 | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; |
4321 | vcpu->run->internal.ndata = 0; | 4323 | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; |
4324 | vcpu->run->internal.ndata = 0; | ||
4325 | r = EMULATE_FAIL; | ||
4326 | } | ||
4322 | kvm_queue_exception(vcpu, UD_VECTOR); | 4327 | kvm_queue_exception(vcpu, UD_VECTOR); |
4323 | return EMULATE_FAIL; | 4328 | |
4329 | return r; | ||
4324 | } | 4330 | } |
4325 | 4331 | ||
4326 | static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) | 4332 | static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) |