diff mbox

KVM: nVMX: Do not emulate #UD while in guest mode

Message ID 54FDFAFB.7050901@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka March 9, 2015, 7:56 p.m. UTC
While in L2, leave all #UD to L2 and do not try to emulate it. If L1 is
interested in doing this, it reports its interest via the exception
bitmap, and we never get into handle_exception of L0 anyway.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Noticed while wondering where the vmmcall of a misconfigured L2 went on
an Intel box: to nowhere. This bug caused a spurious fixup, and the
emulator bug did not even let it trigger a vmcall vmexit.

 arch/x86/kvm/vmx.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Marcelo Tosatti March 13, 2015, 4:44 p.m. UTC | #1
On Mon, Mar 09, 2015 at 08:56:43PM +0100, Jan Kiszka wrote:
> While in L2, leave all #UD to L2 and do not try to emulate it. If L1 is
> interested in doing this, it reports its interest via the exception
> bitmap, and we never get into handle_exception of L0 anyway.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Noticed while wondering where the vmmcall of a misconfigured L2 went on
> an Intel box: to nowhere. This bug caused a spurious fixup, and the
> emulator bug did not even let it trigger a vmcall vmexit.

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f7b20b4..fa0627c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5065,6 +5065,10 @@  static int handle_exception(struct kvm_vcpu *vcpu)
 	}
 
 	if (is_invalid_opcode(intr_info)) {
+		if (is_guest_mode(vcpu)) {
+			kvm_queue_exception(vcpu, UD_VECTOR);
+			return 1;
+		}
 		er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
 		if (er != EMULATE_DONE)
 			kvm_queue_exception(vcpu, UD_VECTOR);