summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dakinevich <jan.dakinevich@virtuozzo.com>2019-08-27 13:07:08 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 12:27:52 +0200
commitbcb66cfc3fcf5a879b93eb6e6b5a60487d80b63d (patch)
tree91bc29094083c40d4092b10cf3934463d948839b
parent5de105cc60f8d3b58661d9084f9a409bb720c0c0 (diff)
downloadlinux-stable-bcb66cfc3fcf5a879b93eb6e6b5a60487d80b63d.tar.gz
linux-stable-bcb66cfc3fcf5a879b93eb6e6b5a60487d80b63d.tar.bz2
linux-stable-bcb66cfc3fcf5a879b93eb6e6b5a60487d80b63d.zip
KVM: x86: set ctxt->have_exception in x86_decode_insn()
commit c8848cee74ff05638e913582a476bde879c968ad upstream. x86_emulate_instruction() takes into account ctxt->have_exception flag during instruction decoding, but in practice this flag is never set in x86_decode_insn(). Fixes: 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn") Cc: stable@vger.kernel.org Cc: Denis Lunev <den@virtuozzo.com> Cc: Roman Kagan <rkagan@virtuozzo.com> Cc: Denis Plotnikov <dplotnikov@virtuozzo.com> Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/x86/kvm/emulate.c2
-rw-r--r--arch/x86/kvm/x86.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 5dd56e3517f3..6c7847b3aa2d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -5245,6 +5245,8 @@ done_prefixes:
ctxt->memopp->addr.mem.ea + ctxt->_eip);
done:
+ if (rc == X86EMUL_PROPAGATE_FAULT)
+ ctxt->have_exception = true;
return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 393d9846a04f..441b8b70277f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5487,6 +5487,12 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
emulation_type))
return EMULATE_DONE;
if (ctxt->have_exception) {
+ /*
+ * #UD should result in just EMULATION_FAILED, and trap-like
+ * exception should not be encountered during decode.
+ */
+ WARN_ON_ONCE(ctxt->exception.vector == UD_VECTOR ||
+ exception_type(ctxt->exception.vector) == EXCPT_TRAP);
inject_emulated_exception(vcpu);
return EMULATE_DONE;
}