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 23:28:52 +0200 Message-ID: <49248514.9020605@redhat.com> References: <491858C8.2040401@siemens.com> <49201213.1080305@redhat.com> <49203513.2080800@web.de> <4920392F.9020303@redhat.com> <49203EAF.3000800@web.de> <49244F20.3030803@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm-devel , "Xu, Jiajun" , "Yang, Sheng" , Jan Kiszka To: Jan Kiszka Return-path: Received: from mx2.redhat.com ([66.187.237.31]:52085 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbYKSV2p (ORCPT ); Wed, 19 Nov 2008 16:28:45 -0500 In-Reply-To: <49244F20.3030803@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity wrote: > 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). > Oh, and I think this is more correct than the previous approach of letting the nmi preempt the interrupt. The nmi handler could change the tpr to mask the preempted interrupt; but the code would not notice that. Once the interrupt was injected the guest would see an interrupt at a higher priority than it has programmed the hardware to allow. Basically, once we commit to an interrupt via kvm_cpu_get_interrupt(), we must inject it before the any instruction gets executed. I don't think any real guest would notice, though. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.