From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 5/8] KVM: x86: use MDA for interrupt matching Date: Fri, 30 Jan 2015 14:09:41 +0100 Message-ID: <20150130130941.GB28519@potion.redhat.com> References: <1422568135-28402-1-git-send-email-rkrcmar@redhat.com> <1422568135-28402-6-git-send-email-rkrcmar@redhat.com> <54CB48F5.9060503@redhat.com> 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, Nadav Amit , Gleb Natapov To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <54CB48F5.9060503@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2015-01-30 10:03+0100, Paolo Bonzini: > On 29/01/2015 22:48, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > > +/* KVM APIC implementation has two quirks > > + * - dest always begins at 0 while xAPIC MDA has offset 24, > > + * - IOxAPIC messages have to be delivered (directly) to x2APIC. > > + */ > > +static u32 > > +kvm_apic_mda(unsigned int dest, struct kvm_lapic *ipi, bool x2apic= _dest) >=20 > Please pass two struct kvm_lapic, so that you can write >=20 > bool ipi =3D source !=3D NULL; > bool x2apic_mda =3D apic_x2apic_mode(ipi ? source : dest); >=20 > Looks a little nicer to me at least. Definitely. > > +{ > > + bool x2apic_mda =3D ipi ? apic_x2apic_mode(ipi) : x2apic_dest; > > + > > + if (!ipi && dest =3D=3D APIC_BROADCAST) > > + dest =3D X2APIC_BROADCAST; >=20 > This works, but it is not super-clear that you are shifting left by 2= 4 > here, and right in kvm_apic_broadcast(). What if you just make it >=20 > if (!ipi && dest =3D=3D APIC_BROADCAST && x2apic_mda) > return X2APIC_BROADCAST. It's better, it will be that way in v2 of [5-8/8], thanks. (I was using it twice in earlier iterations and didn't think again.)