aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorNadav Amit <namit@cs.technion.ac.il>2014-08-13 09:50:13 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-08-19 09:12:28 -0400
commit3a6095a0173ad8f20c508446880558c9f9224324 (patch)
tree4725c419f4a5cfe54f20e9f0d80ea3efa6476c34 /arch/x86/kvm
parentc04fa5831d4d89dfbc88406f4a46f9846841a560 (diff)
KVM: x86: Avoid emulating instructions on #UD mistakenly
Commit d40a6898e5 mistakenly caused instructions which are not marked as EmulateOnUD to be emulated upon #UD exception. The commit caused the check of whether the instruction flags include EmulateOnUD to never be evaluated. As a result instructions whose emulation is broken may be emulated. This fix moves the evaluation of EmulateOnUD so it would be evaluated. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> [Tweak operand order in &&, remove EmulateOnUD where it's now superfluous. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/emulate.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 56657b0bb3bb..ef117b842334 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4394,8 +4394,11 @@ done_prefixes:
4394 4394
4395 ctxt->execute = opcode.u.execute; 4395 ctxt->execute = opcode.u.execute;
4396 4396
4397 if (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD)))
4398 return EMULATION_FAILED;
4399
4397 if (unlikely(ctxt->d & 4400 if (unlikely(ctxt->d &
4398 (NotImpl|EmulateOnUD|Stack|Op3264|Sse|Mmx|Intercept|CheckPerm))) { 4401 (NotImpl|Stack|Op3264|Sse|Mmx|Intercept|CheckPerm))) {
4399 /* 4402 /*
4400 * These are copied unconditionally here, and checked unconditionally 4403 * These are copied unconditionally here, and checked unconditionally
4401 * in x86_emulate_insn. 4404 * in x86_emulate_insn.
@@ -4406,9 +4409,6 @@ done_prefixes:
4406 if (ctxt->d & NotImpl) 4409 if (ctxt->d & NotImpl)
4407 return EMULATION_FAILED; 4410 return EMULATION_FAILED;
4408 4411
4409 if (!(ctxt->d & EmulateOnUD) && ctxt->ud)
4410 return EMULATION_FAILED;
4411
4412 if (mode == X86EMUL_MODE_PROT64 && (ctxt->d & Stack)) 4412 if (mode == X86EMUL_MODE_PROT64 && (ctxt->d & Stack))
4413 ctxt->op_bytes = 8; 4413 ctxt->op_bytes = 8;
4414 4414