From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] KVM: nVMX: Do not emulate #UD while in guest mode Date: Mon, 09 Mar 2015 20:56:43 +0100 Message-ID: <54FDFAFB.7050901@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit To: kvm , Paolo Bonzini , Marcelo Tosatti Return-path: Received: from thoth.sbs.de ([192.35.17.2]:46643 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751702AbbCIT4s (ORCPT ); Mon, 9 Mar 2015 15:56:48 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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(+) 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); -- 2.1.4