[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 4/5] amd/iommu: assign iommu devices to Xen



AMD IOMMU devices are exposed on the PCI bus, and thus are assigned by
default to the hardware domain. This can cause issues because the
IOMMU devices are not behind an IOMMU, and conceptually it's also wrong
to give the hardware domain ownership of those devices since they are
in use by Xen.

Fix this by assigning the PCI IOMMU devices to Xen.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
Cc: Brian Woods <brian.woods@xxxxxxx>
---
 xen/drivers/passthrough/amd/iommu_init.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/xen/drivers/passthrough/amd/iommu_init.c 
b/xen/drivers/passthrough/amd/iommu_init.c
index 15c10b0929..c74c1566d9 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -993,6 +993,16 @@ static void * __init allocate_ppr_log(struct amd_iommu 
*iommu)
 
 static int __init amd_iommu_init_one(struct amd_iommu *iommu)
 {
+    struct pci_dev *pdev;
+
+    pcidevs_lock();
+    pdev = pci_get_pdev(iommu->seg, PCI_BUS(iommu->bdf),
+                        PCI_DEVFN2(iommu->bdf));
+    if ( pdev )
+        /* Assign the IOMMU PCI device to Xen  */
+        pdev->domain = dom_xen;
+    pcidevs_unlock();
+
     if ( map_iommu_mmio_region(iommu) != 0 )
         goto error_out;
 
-- 
2.19.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.