From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: call irq notifiers with directed EOI Date: Fri, 20 Mar 2015 15:43:02 +0100 Message-ID: <20150320144302.GA14772@potion.brq.redhat.com> References: <1426703902-16818-1-git-send-email-rkrcmar@redhat.com> <20150319214449.GA4264@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , chao.zhou@intel.com To: Marcelo Tosatti Return-path: Content-Disposition: inline In-Reply-To: <20150319214449.GA4264@amt.cnet> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2015-03-19 18:44-0300, Marcelo Tosatti: > On Wed, Mar 18, 2015 at 07:38:22PM +0100, Radim Kr=C4=8Dm=C3=A1=C5=99= wrote: > > kvm_ioapic_update_eoi() wasn't called if directed EOI was enabled. > > We need to do that for irq notifiers. (Like with edge interrupts.) > >=20 > > Fix it by skipping EOI broadcast only. > >=20 > > Bug: https://bugzilla.kernel.org/show_bug.cgi?id=3D82211 > > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > > --- > > diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c > > @@ -443,7 +444,8 @@ static void __kvm_ioapic_update_eoi(struct kvm_= vcpu *vcpu, > > - if (trigger_mode !=3D IOAPIC_LEVEL_TRIG) > > + if (trigger_mode !=3D IOAPIC_LEVEL_TRIG || > > + kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) > > continue; >=20 > Don't you have to handle kvm_ioapic_eoi_inject_work as well? It works without that: ent->fields.remote_irr =3D=3D 1, thus kvm_ioapic_eoi_inject_work() will do nothing. Adding a check would be better for clarity, though. We could add the EOI register (implement IO-APIC version 0x20), because kernels are forced to do ugly hacks otherwise (switching to edge-triggered mode and back). We also clear remote_irr on a different occasion (just a write to ioreg). I'll take a closer look at the second one. > > ASSERT(ent->fields.trig_mode =3D=3D IOAPIC_LEVEL_TRIG); >=20 > This assert can now fail? I think it can't (nothing changed), but that is how asserts should be. It checks a different variable than the condition above. ('trigger_mode' is sourced from APIC_TMR, which should correctly match 'ent->fields.trig_mode'.) The assert would be more useful before 'continue;', and modified: ASSERT(ent->fields.trig_mode =3D=3D trigger_mode) Thanks for the review, I'll incorporate the your comments to v2.