]> git.hungrycats.org Git - linux/commitdiff
KVM: x86: Exit to user-mode on #UD intercept when emulator requires
authorLiran Alon <liran.alon@oracle.com>
Sun, 5 Nov 2017 14:56:32 +0000 (16:56 +0200)
committerSasha Levin <alexander.levin@verizon.com>
Fri, 8 Dec 2017 23:01:15 +0000 (18:01 -0500)
[ Upstream commit 61cb57c9ed631c95b54f8e9090c89d18b3695b3c ]

Instruction emulation after trapping a #UD exception can result in an
MMIO access, for example when emulating a MOVBE on a processor that
doesn't support the instruction.  In this case, the #UD vmexit handler
must exit to user mode, but there wasn't any code to do so.  Add it for
both VMX and SVM.

Signed-off-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c

index abee10e2296d7ac91edfe438099fbdf3d0100dba..c5ecf85227e090cbdf23c4fb8821fb213b20370b 100644 (file)
@@ -1780,6 +1780,8 @@ static int ud_interception(struct vcpu_svm *svm)
        int er;
 
        er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD);
+       if (er == EMULATE_USER_EXIT)
+               return 0;
        if (er != EMULATE_DONE)
                kvm_queue_exception(&svm->vcpu, UD_VECTOR);
        return 1;
index 2012b7b930ab39cf42e6fa904a4b51a943e015ea..665b10a55b305351976611f5be70eeec8fa1f1b8 100644 (file)
@@ -5096,6 +5096,8 @@ static int handle_exception(struct kvm_vcpu *vcpu)
                        return 1;
                }
                er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
+               if (er == EMULATE_USER_EXIT)
+                       return 0;
                if (er != EMULATE_DONE)
                        kvm_queue_exception(vcpu, UD_VECTOR);
                return 1;