From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 8/9] VMX: work around lacking VNMI support Date: Sun, 21 Sep 2008 17:31:44 +0300 Message-ID: <20080921143144.GB27089@minantech.com> References: <48D392F2.300@siemens.com> <48D39555.4020106@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm-devel , "Yang, Sheng" , Avi Kivity To: Jan Kiszka Return-path: Received: from il.qumranet.com ([212.179.150.194]:46452 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbYIUObq (ORCPT ); Sun, 21 Sep 2008 10:31:46 -0400 Content-Disposition: inline In-Reply-To: <48D39555.4020106@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: Hi Jan, On Fri, Sep 19, 2008 at 02:04:37PM +0200, Jan Kiszka wrote: > static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq) > { > struct vcpu_vmx *vmx = to_vmx(vcpu); > @@ -2356,6 +2384,29 @@ static void vmx_inject_nmi(struct kvm_vc > { > struct vcpu_vmx *vmx = to_vmx(vcpu); > > + if (!cpu_has_virtual_nmis()) { > + int desc_size = is_long_mode(vcpu) ? 16 : 8; > + struct descriptor_table dt; > + gpa_t gpa; > + u64 desc; > + > + /* > + * Deny delivery if the NMI will not be handled by an > + * interrupt gate (workaround depends on IRQ masking). > + */ > + vmx_get_idt(vcpu, &dt); > + if (!vcpu->arch.rmode.active && dt.limit > + >= desc_size * (NMI_VECTOR + 1) - 1) { > + gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, > + dt.base + desc_size * NMI_VECTOR); > + if (kvm_read_guest(vcpu->kvm, gpa, &desc, 8) == 0 > + && ((desc >> 40) & 0x7) != 0x6) > + return; > + } Windows2003 sets NMI entry in IDT as a task gate (0x5) during hibernation and this check prevents it from shutting down itself. It hangs in "It is save to turn your computer now" screen. If I replace this part by: if(vmx->soft_vnmi_blocked) return; It shut itself down properly. > + vmx->soft_vnmi_blocked = 1; > + vmx->vnmi_blocked_time = 0; > + } > + -- Gleb.