From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: VMX: Fix race between pending IRQ and NMI Date: Wed, 19 Nov 2008 19:38:40 +0200 Message-ID: <49244F20.3030803@redhat.com> References: <491858C8.2040401@siemens.com> <49201213.1080305@redhat.com> <49203513.2080800@web.de> <4920392F.9020303@redhat.com> <49203EAF.3000800@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060301010900010400080708" Cc: kvm-devel , "Xu, Jiajun" , "Yang, Sheng" , Jan Kiszka To: Jan Kiszka Return-path: Received: from mx2.redhat.com ([66.187.237.31]:40132 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbYKSRis (ORCPT ); Wed, 19 Nov 2008 12:38:48 -0500 In-Reply-To: <49203EAF.3000800@web.de> Sender: kvm-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------060301010900010400080708 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Jan Kiszka wrote: > Jiajun kindly provided me a RHEL kernel and initrd (2.6.18-53-el5) which > I ran for a while (or booted a few times) to trigger the hang. Basically > you need high IRQ load (preferably via LAPIC, to exploit that un-acked > IRQs will block low-prio IRQs as well) + high NMI load (e.g. via NMI > watchdog). > I was able to reproduce it easily by zapping the mmu every second. Attached is a patch the fixes it for me. Basically it avoids the nmi path if an interrupt is being injected. This is closer to my event queue plan, and also is similar to what the code does today with exceptions (avoid ->inject_pending_irq() if an exception is pending). Please review (and test if possible). -- error compiling committee.c: too many arguments to function --------------060301010900010400080708 Content-Type: text/plain; name="dont-inject-nmi-if-interrupt-is-pending.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dont-inject-nmi-if-interrupt-is-pending.patch" diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ebf5406..93f9010 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3268,7 +3268,10 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu) vmx_update_window_states(vcpu); if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) { - if (vcpu->arch.nmi_window_open) { + if (vcpu->arch.interrupt.pending) { + if (!vcpu->arch.nmi_window_open) + enable_nmi_window(vcpu); + } else if (vcpu->arch.nmi_window_open) { vcpu->arch.nmi_pending = false; vcpu->arch.nmi_injected = true; } else { --------------060301010900010400080708--