]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.18.86/kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.86 / kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch
CommitLineData
b3d5543a
GKH
1From 61cb57c9ed631c95b54f8e9090c89d18b3695b3c Mon Sep 17 00:00:00 2001
2From: Liran Alon <liran.alon@oracle.com>
3Date: Sun, 5 Nov 2017 16:56:32 +0200
4Subject: KVM: x86: Exit to user-mode on #UD intercept when emulator requires
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Liran Alon <liran.alon@oracle.com>
10
11commit 61cb57c9ed631c95b54f8e9090c89d18b3695b3c upstream.
12
13Instruction emulation after trapping a #UD exception can result in an
14MMIO access, for example when emulating a MOVBE on a processor that
15doesn't support the instruction. In this case, the #UD vmexit handler
16must exit to user mode, but there wasn't any code to do so. Add it for
17both VMX and SVM.
18
19Signed-off-by: Liran Alon <liran.alon@oracle.com>
20Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
21Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
22Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
23Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
24Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
25Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28---
29 arch/x86/kvm/svm.c | 2 ++
30 arch/x86/kvm/vmx.c | 2 ++
31 2 files changed, 4 insertions(+)
32
33--- a/arch/x86/kvm/svm.c
34+++ b/arch/x86/kvm/svm.c
35@@ -1785,6 +1785,8 @@ static int ud_interception(struct vcpu_s
36 int er;
37
38 er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD);
39+ if (er == EMULATE_USER_EXIT)
40+ return 0;
41 if (er != EMULATE_DONE)
42 kvm_queue_exception(&svm->vcpu, UD_VECTOR);
43 return 1;
44--- a/arch/x86/kvm/vmx.c
45+++ b/arch/x86/kvm/vmx.c
46@@ -4899,6 +4899,8 @@ static int handle_exception(struct kvm_v
47
48 if (is_invalid_opcode(intr_info)) {
49 er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
50+ if (er == EMULATE_USER_EXIT)
51+ return 0;
52 if (er != EMULATE_DONE)
53 kvm_queue_exception(vcpu, UD_VECTOR);
54 return 1;