From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpqYW-0004JF-Q2 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpqYS-0001Kw-Ko for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:40:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpqYS-0001Kn-Dy for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:40:16 -0400 Date: Fri, 30 Sep 2016 13:40:11 +0800 From: Peter Xu Message-ID: <20160930054011.GN11134@pxdev.xzpeter.org> References: <20160929112329.2408-1-rkrcmar@redhat.com> <20160929112329.2408-8-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160929112329.2408-8-rkrcmar@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 7/7] intel-iommu: keep buggy EIM enabled in 2.7 machine type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: qemu-devel@nongnu.org, Igor Mammedov , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" On Thu, Sep 29, 2016 at 01:23:29PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: [...] > @@ -2481,11 +2482,14 @@ static void vtd_realize(DeviceState *dev, Error= **errp) > if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO && !x86_iommu->intr_suppor= ted) { > s->intr_eim =3D ON_OFF_AUTO_OFF; > } > + if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO && pcmc->buggy_intel_iommu= _eim) { > + s->intr_eim =3D ON_OFF_AUTO_ON; > + } > if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO) { > s->intr_eim =3D kvm_irqchip_in_kernel() ? ON_OFF_AUTO_ON > : ON_OFF_AUTO_OFF; > } > - if (s->intr_eim =3D=3D ON_OFF_AUTO_ON) { > + if (s->intr_eim =3D=3D ON_OFF_AUTO_ON && !pcmc->buggy_intel_iommu_= eim) { > if (kvm_irqchip_in_kernel() && !kvm_enable_x2apic()) { > error_report("intel-iommu,eim=3Don requires support on the= KVM side " > "(X2APIC_API, first shipped in v4.7)."); No matter how we would treat this patch, I see that we are stacking up if clauses here. So IMHO maybe it's time to award EIM a new routine: int vtd_eim_detect(IntelIOMMUState *, Error **errp); And squash all these conditions in. Then in vtd_realize(): if (vtd_eim_detect(s, errp)) { return; } Thanks, -- peterx