summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorJan Dakinevich <jan.dakinevich@virtuozzo.com>2019-08-27 16:07:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 13:30:32 +0300
commitd729e306707b004cc1494a11242c25047313fa07 (patch)
tree5230c2e66525155e2f5e98e3fd0e08dc13c8bd6a /arch/x86/kvm/x86.c
parentf5cab8c2ee3d932ea5baa770f334930481470aec (diff)
downloadlinux-d729e306707b004cc1494a11242c25047313fa07.tar.xz
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>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4285532326e4..ededa7b8c75d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5765,6 +5765,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;
}