From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 08/14] KVM: x86: Enable NMI Watchdog via in-kernel PIT source Date: Sun, 28 Sep 2008 12:40:42 +0300 Message-ID: <48DF511A.6040100@redhat.com> References: <20080926073044.252540328@mchn012c.ww002.siemens.net> <20080926073045.926844425@mchn012c.ww002.siemens.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, sheng.yang@intel.com, gleb@redhat.com To: jan.kiszka@siemens.com Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58191 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbYI1Jkt (ORCPT ); Sun, 28 Sep 2008 05:40:49 -0400 In-Reply-To: <20080926073045.926844425@mchn012c.ww002.siemens.net> Sender: kvm-owner@vger.kernel.org List-ID: jan.kiszka@siemens.com wrote: > LINT0 of the LAPIC can be used to route PIT events as NMI watchdog ticks > into the guest. This patch aligns the in-kernel irqchip emulation with > the user space irqchip with already supports this feature. The trick is > to route PIT interrupts to all LAPIC's LVT0 lines. > > Rebased and slightly polished patch originally posted by Sheng Yang. > > Signed-off-by: Jan Kiszka > Signed-off-by: Sheng Yang > --- > arch/x86/kvm/i8254.c | 15 +++++++++++++++ > arch/x86/kvm/irq.h | 1 + > arch/x86/kvm/lapic.c | 34 +++++++++++++++++++++++++++++----- > 3 files changed, 45 insertions(+), 5 deletions(-) > > Index: b/arch/x86/kvm/i8254.c > =================================================================== > --- a/arch/x86/kvm/i8254.c > +++ b/arch/x86/kvm/i8254.c > @@ -594,10 +594,25 @@ void kvm_free_pit(struct kvm *kvm) > > static void __inject_pit_timer_intr(struct kvm *kvm) > { > + struct kvm_vcpu *vcpu; > + int i; > + > mutex_lock(&kvm->lock); > kvm_set_irq(kvm, 0, 1); > kvm_set_irq(kvm, 0, 0); > mutex_unlock(&kvm->lock); > + > + /* > + * Provides NMI watchdog support in IOAPIC mode. > + * The route is: PIT -> PIC -> LVT0 in NMI mode, > + * timer IRQs will continue to flow through the IOAPIC. > + */ > + for (i = 0; i < KVM_MAX_VCPUS; ++i) { > + vcpu = kvm->vcpus[i]; > + if (!vcpu) > + continue; > + kvm_apic_local_deliver(vcpu, APIC_LVT0); > + } > } > It would be better to gate this on a variable which is set only if this is actually necessary (e.g, does any vcpu have LVT0 set to NMI mode). Otherwise, we touch all vcpus up to 1000 times a second. As this is an optimization, it can be done later. -- error compiling committee.c: too many arguments to function