Received: from eggs.gnu.org ([2001:4830:134:3::10]:35450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZSc-0002hF-Om for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:25:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpZSX-0003AT-Qz for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:25:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZSX-0003AJ-IK for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:25:01 -0400 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Thu, 29 Sep 2016 13:23:27 +0200 Message-Id: <20160929112329.2408-6-rkrcmar@redhat.com> In-Reply-To: <20160929112329.2408-1-rkrcmar@redhat.com> References: <20160929112329.2408-1-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 5/7] intel-iommu: add OnOffAuto intr_eim as "eim" property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Xu , Igor Mammedov , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" The default (auto) emulates the current behavior. Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- hw/i386/intel_iommu.c | 20 +++++++++++++++++++- include/hw/i386/intel_iommu.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index eb488c14625d..47141cea64f4 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2011,6 +2011,8 @@ static const MemoryRegionOps vtd_mem_ops =3D { =20 static Property vtd_properties[] =3D { DEFINE_PROP_UINT32("version", IntelIOMMUState, version, 0), + DEFINE_PROP_ON_OFF_AUTO("eim", IntelIOMMUState, intr_eim, + ON_OFF_AUTO_AUTO), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2367,7 +2369,11 @@ static void vtd_init(IntelIOMMUState *s) s->ecap =3D VTD_ECAP_QI | VTD_ECAP_IRO; =20 if (x86_iommu->intr_supported) { - s->ecap |=3D VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHMV; + s->ecap |=3D VTD_ECAP_IR | VTD_ECAP_MHMV; + if (s->intr_eim =3D=3D ON_OFF_AUTO_ON) { + s->ecap |=3D VTD_ECAP_EIM; + } + assert(s->intr_eim !=3D ON_OFF_AUTO_AUTO); } =20 vtd_reset_context_cache(s); @@ -2466,6 +2472,18 @@ static void vtd_realize(DeviceState *dev, Error **= errp) exit(1); } =20 + if (s->intr_eim =3D=3D ON_OFF_AUTO_ON && !x86_iommu->intr_supported)= { + error_report("intel-iommu,eim=3Don cannot be selected without " + "intremap=3Don."); + exit(1); + } + if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO && !x86_iommu->intr_supporte= d) { + s->intr_eim =3D ON_OFF_AUTO_OFF; + } + if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO) { + s->intr_eim =3D ON_OFF_AUTO_ON; + } + memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.= h index a42dbd745a70..b5ac60927b1f 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -289,6 +289,7 @@ struct IntelIOMMUState { dma_addr_t intr_root; /* Interrupt remapping table pointer= */ uint32_t intr_size; /* Number of IR table entries */ bool intr_eime; /* Extended interrupt mode enabled *= / + OnOffAuto intr_eim; /* Toggle for EIM cabability */ }; =20 /* Find the VTD Address space associated with the given bus pointer, --=20 2.10.0