From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sheng Yang Subject: Re: [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2 Date: Mon, 20 Oct 2008 20:22:37 +0800 Message-ID: <20081020122237.GF30536@yukikaze> References: <48FC4671.90409@siemens.com> <48FC7435.4020707@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 ti-out-0910.google.com ([209.85.142.191]:42304 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbYJTMWr (ORCPT ); Mon, 20 Oct 2008 08:22:47 -0400 Received: by ti-out-0910.google.com with SMTP id b6so827453tic.23 for ; Mon, 20 Oct 2008 05:22:44 -0700 (PDT) Content-Disposition: inline In-Reply-To: <48FC7435.4020707@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Oct 20, 2008 at 02:06:13PM +0200, Jan Kiszka wrote: > [ taking Sheng's comments into account ] > > The logic of kvm_apic_accept_pic_intr has a minor, practically hardly > relevant incorrectness: PIC interrupts are still delivered even if the > APIC of VPU0 (BSP) is disabled. This does not comply with the Virtual > Wire mode according to the Intel MP spec. > > Signed-off-by: Jan Kiszka Acked-by: Sheng Yang -- regards Yang, Sheng > --- > arch/x86/kvm/lapic.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > Index: b/arch/x86/kvm/lapic.c > =================================================================== > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -1089,17 +1089,18 @@ int kvm_apic_has_interrupt(struct kvm_vc > > int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu) > { > - u32 lvt0 = apic_get_reg(vcpu->arch.apic, APIC_LVT0); > - int r = 0; > + struct kvm_lapic *apic = vcpu->arch.apic; > + u32 lvt0 = apic_get_reg(apic, APIC_LVT0); > > - if (vcpu->vcpu_id == 0) { > - if (!apic_hw_enabled(vcpu->arch.apic)) > - r = 1; > - if ((lvt0 & APIC_LVT_MASKED) == 0 && > - GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT) > - r = 1; > - } > - return r; > + /* > + * Virtual Wire mode, but we only deliver to the BSP. > + * Note that apic_sw_enabled() is covered by testing for !LVT_MASKED. > + */ > + if (vcpu->vcpu_id == 0 && apic_hw_enabled(apic) > + && !(lvt0 & APIC_LVT_MASKED) > + && GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT) > + return 1; > + return 0; > } > > void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu) > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html