From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Bader Subject: Re: [PATCH v5] AMD IOMMU: fix Dom0 device setup failure for host bridges Date: Thu, 12 Sep 2013 11:42:55 +0200 Message-ID: <52318C9F.6080202@canonical.com> References: <1378928368-2631-1-git-send-email-suravee.suthikulpanit@amd.com> <523194B302000078000F2A12@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2345509394469923119==" Return-path: In-Reply-To: <523194B302000078000F2A12@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xiantao.zhang@intel.com, suravee.suthikulpanit@amd.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============2345509394469923119== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigA9B044E78D0725032488099A" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA9B044E78D0725032488099A Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 12.09.2013 10:17, Jan Beulich wrote: > The host bridge device (i.e. 0x18 for AMD) does not require IOMMU, and > therefore is not included in the IVRS. The current logic tries to map > all PCI devices to an IOMMU. In this case, "xl dmesg" shows the > following message on AMD sytem. >=20 > (XEN) setup 0000:00:18.0 for d0 failed (-19) > (XEN) setup 0000:00:18.1 for d0 failed (-19) > (XEN) setup 0000:00:18.2 for d0 failed (-19) > (XEN) setup 0000:00:18.3 for d0 failed (-19) > (XEN) setup 0000:00:18.4 for d0 failed (-19) > (XEN) setup 0000:00:18.5 for d0 failed (-19) >=20 > This patch adds a new device type (i.e. DEV_TYPE_PCI_HOST_BRIDGE) which= > corresponds to PCI class code 0x06 and sub-class 0x00. Then, it uses > this new type to filter when trying to map device to IOMMU. >=20 > Signed-off-by: Suravee Suthikulpanit > Reported-by: Stefan Bader >=20 > On VT-d refuse (un)mapping host bridges for other than the hardware > domain. >=20 > Coding style cleanup. >=20 > Signed-off-by: Jan Beulich As this looks to be about final. Tested-by: Stefan Bader >=20 > --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c > +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c > @@ -147,9 +147,10 @@ static void amd_iommu_setup_domain_devic > =20 > amd_iommu_flush_device(iommu, req_id); > =20 > - AMD_IOMMU_DEBUG("Setup I/O page table: device id =3D %#x, " > + AMD_IOMMU_DEBUG("Setup I/O page table: device id =3D %#x, type= =3D %#x, " > "root table =3D %#"PRIx64", " > - "domain =3D %d, paging mode =3D %d\n", req_id,= > + "domain =3D %d, paging mode =3D %d\n", > + req_id, pdev->type, > page_to_maddr(hd->root_table), > hd->domain_id, hd->paging_mode); > } > @@ -175,6 +176,15 @@ static int __init amd_iommu_setup_dom0_d > =20 > if ( unlikely(!iommu) ) > { > + /* Filter the bridge devices */ > + if ( pdev->type =3D=3D DEV_TYPE_PCI_HOST_BRIDGE ) > + { > + AMD_IOMMU_DEBUG("Skipping host bridge %04x:%02x:%02x.%u\n"= , > + pdev->seg, PCI_BUS(bdf), PCI_SLOT(bdf), > + PCI_FUNC(bdf)); > + return 0; > + } > + > AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n", > pdev->seg, pdev->bus, > PCI_SLOT(devfn), PCI_FUNC(devfn)); > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -194,9 +194,6 @@ static struct pci_dev *alloc_pdev(struct > u16 cap; > u8 sec_bus, sub_bus; > =20 > - case DEV_TYPE_PCIe_BRIDGE: > - break; > - > case DEV_TYPE_PCIe2PCI_BRIDGE: > case DEV_TYPE_LEGACY_PCI_BRIDGE: > sec_bus =3D pci_conf_read8(pseg->nr, bus, PCI_SLOT(devfn),= > @@ -244,6 +241,8 @@ static struct pci_dev *alloc_pdev(struct > break; > =20 > case DEV_TYPE_PCI: > + case DEV_TYPE_PCIe_BRIDGE: > + case DEV_TYPE_PCI_HOST_BRIDGE: > break; > =20 > default: > @@ -697,6 +696,7 @@ void pci_release_devices(struct domain * > spin_unlock(&pcidevs_lock); > } > =20 > +#define PCI_CLASS_BRIDGE_HOST 0x0600 > #define PCI_CLASS_BRIDGE_PCI 0x0604 > =20 > enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) > @@ -720,6 +720,8 @@ enum pdev_type pdev_type(u16 seg, u8 bus > return DEV_TYPE_PCI2PCIe_BRIDGE; > } > return DEV_TYPE_PCIe_BRIDGE; > + case PCI_CLASS_BRIDGE_HOST: > + return DEV_TYPE_PCI_HOST_BRIDGE; > =20 > case 0x0000: case 0xffff: > return DEV_TYPE_PCI_UNKNOWN; > --- a/xen/drivers/passthrough/vtd/intremap.c > +++ b/xen/drivers/passthrough/vtd/intremap.c > @@ -442,6 +442,7 @@ static void set_msi_source_id(struct pci > case DEV_TYPE_PCIe_ENDPOINT: > case DEV_TYPE_PCIe_BRIDGE: > case DEV_TYPE_PCIe2PCI_BRIDGE: > + case DEV_TYPE_PCI_HOST_BRIDGE: > switch ( pdev->phantom_stride ) > { > case 1: sq =3D SQ_13_IGNORE_3; break; > --- a/xen/drivers/passthrough/vtd/iommu.c > +++ b/xen/drivers/passthrough/vtd/iommu.c > @@ -1433,6 +1433,15 @@ static int domain_context_mapping( > =20 > switch ( pdev->type ) > { > + case DEV_TYPE_PCI_HOST_BRIDGE: > + if ( iommu_verbose ) > + dprintk(VTDPREFIX, "d%d:Hostbridge: skip %04x:%02x:%02x.%u= map\n", > + domain->domain_id, seg, bus, > + PCI_SLOT(devfn), PCI_FUNC(devfn)); > + if ( !is_hardware_domain(domain) ) > + return -EPERM; > + break; > + > case DEV_TYPE_PCIe_BRIDGE: > case DEV_TYPE_PCIe2PCI_BRIDGE: > case DEV_TYPE_LEGACY_PCI_BRIDGE: > @@ -1563,6 +1572,15 @@ static int domain_context_unmap( > =20 > switch ( pdev->type ) > { > + case DEV_TYPE_PCI_HOST_BRIDGE: > + if ( iommu_verbose ) > + dprintk(VTDPREFIX, "d%d:Hostbridge: skip %04x:%02x:%02x.%u= unmap\n", > + domain->domain_id, seg, bus, > + PCI_SLOT(devfn), PCI_FUNC(devfn)); > + if ( !is_hardware_domain(domain) ) > + return -EPERM; > + goto out; > + > case DEV_TYPE_PCIe_BRIDGE: > case DEV_TYPE_PCIe2PCI_BRIDGE: > case DEV_TYPE_LEGACY_PCI_BRIDGE: > --- a/xen/include/xen/pci.h > +++ b/xen/include/xen/pci.h > @@ -63,6 +63,7 @@ struct pci_dev { > DEV_TYPE_PCIe2PCI_BRIDGE, // PCIe-to-PCI/PCIx bridge > DEV_TYPE_PCI2PCIe_BRIDGE, // PCI/PCIx-to-PCIe bridge > DEV_TYPE_LEGACY_PCI_BRIDGE, // Legacy PCI bridge > + DEV_TYPE_PCI_HOST_BRIDGE, // PCI Host bridge > DEV_TYPE_PCI, > } type; > =20 >=20 >=20 --------------enigA9B044E78D0725032488099A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQIcBAEBCgAGBQJSMYyoAAoJEOhnXe7L7s6j1LUP/0q2ODfGabiE+ESbNixULD7u kvsP2ls1xF9ZxBC5ilJrw65c2YHTr9Q6WdPcwE1DJB4T7Ir429vjJAUq6Xlex6qi Yib861V01WpTG+hjXqFh+HACIgAzwL6u0+McUlhVk8cNALOSpqmxxChqEaiejaru x1HADv62W5W0pVGfQyUhKSZJy2YxAJvAtVd6y+Hc1ycXEC6wcnWNuHn/vSj/YZbB mjBP5G503AsRAsnDOCmFA6s8oKthmdMyk/saCiaFhXJOX6stPsILHMAmNaQljVgO SteYCAtQImN/QhM14SmyZwfNDFQLzpHqheOQFSosF33DNe63L2G0ISYNE0hb1a8c ny8c93514zf/3QnWvl0xOahTvFYzic2o5d0GZsUuzr8N+EzSqA5z3we4gGl3Dslv edtj5Mo3Ao7q4Mg/UPcPEcsbBEw2Bt+G9UVaY2LRtG6BeGuCaHET4dYw0HAQ1Ga9 nmjLOIQUJdeCsNGi4T8cx6FkiwUqwbpe7h7x3pEUFmjFMQTXnYE8S8gnm37ga7gk ETCdgI8jZaNoEmRIvH2qncTnxxAPfvSv9jUVbdA4eJ3y1kIeu/I2r3Ysv963Jcs3 XpBJp2QkcOADsX3w8u5wVCpBozj0AyWMloaw1o0njoUjjoqOQhAQ2ky1KH3P7pyb jD2j9CZnp07Xe7wlU9in =dR32 -----END PGP SIGNATURE----- --------------enigA9B044E78D0725032488099A-- --===============2345509394469923119== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2345509394469923119==--