Skip to contentSkip to conversation

amd/iommu: fixes for PVH Dom0

PATCH In review Roger Pau Monne 2 participants 5 messages Nov 27, 2018 – Nov 29, 2018

lore
Share & tools
lore
#0 lore raw

v6 cover amd/iommu: fixes for PVH Dom0

Hello,

This is the remaining of the PVH Dom0 fixes, which now only contains the AMD IOMMU patches. The series can be found at:

git://xenbits.xen.org/people/royger/xen.git fixes-pvh-v6

Roger Pau Monne (2):
amd/iommu: assign iommu devices to Xen
amd/iommu: skip bridge devices when updating IOMMU page tables

 xen/drivers/passthrough/amd/iommu_init.c | 2 ++
 xen/drivers/passthrough/amd/iommu_map.c  | 3 +++
 2 files changed, 5 insertions(+)
Signature · 7 lines
2.19.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v6 1/2 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 themselves are not behind an IOMMU, so update_paging_mode will return an error if Xen tries to expand the page tables of a domain that has assigned devices not behind an IOMMU. update_paging_mode failing will cause the domain to be destroyed.

Fix this by hiding PCI IOMMU devices, so they are not assigned to the hardware domain.

---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
---
Changes since v4:
- Use pci_hide_device.
- Expand commit message.

---
 xen/drivers/passthrough/amd/iommu_init.c | 2 ++
 1 file changed, 2 insertions(+)
xen/drivers/passthrough/amd/iommu_init.c +2 -0
index 15c10b0929..17f39552a9 100644
@@ -993,6 +993,8 @@ static void * __init allocate_ppr_log(struct amd_iommu *iommu)
 
 static int __init amd_iommu_init_one(struct amd_iommu *iommu)
 {
+    pci_hide_device(iommu->seg, PCI_BUS(iommu->bdf), PCI_DEVFN2(iommu->bdf));
+
     if ( map_iommu_mmio_region(iommu) != 0 )
         goto error_out;
 
Signature · 7 lines
2.19.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v6 1/2
#2 lore raw

Re: [PATCH v6 1/2] amd/iommu: assign iommu devices to Xen

Quoted 7 lines · Roger Pau Monne

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 themselves are not behind an IOMMU, so update_paging_mode will return an error if Xen tries to expand the page tables of a domain that has assigned devices not behind an IOMMU. update_paging_mode failing will cause the domain to be destroyed.

Quoted 5 lines

Fix this by hiding PCI IOMMU devices, so they are not assigned to the hardware domain.

Signature · 6 lines
Brian Woods

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH v6 2/2 amd/iommu: skip bridge devices when updating IOMMU page tables

In reply to Roger Pau Monne

Bridges are not behind an IOMMU, and are already special cased and skipped in amd_iommu_add_device. Apply the same special casing when updating page tables.

This is required or else update_paging_mode will fail and return an error to the caller (amd_iommu_{un}map_page) which will destroy the domain.

---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
---
Changes since v5:
- Remove the hardware domain check.

Changes since v4:
- Invert condition order so they match the order in amd_iommu_add_device.
- Expand commit message to spell out why this is required.

---
 xen/drivers/passthrough/amd/iommu_map.c | 3 +++
 1 file changed, 3 insertions(+)
xen/drivers/passthrough/amd/iommu_map.c +3 -0
index c1daba8422..e4904bb3c5 100644
@@ -612,6 +612,9 @@ static int update_paging_mode(struct domain *d, unsigned long dfn)
         /* Update device table entries using new root table and paging mode */
         for_each_pdev( d, pdev )
         {
+            if ( pdev->type == DEV_TYPE_PCI_HOST_BRIDGE )
+                continue;
+
             bdf = PCI_BDF2(pdev->bus, pdev->devfn);
             iommu = find_iommu_for_device(pdev->seg, bdf);
             if ( !iommu )
Signature · 7 lines
2.19.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v6 2/2
#4 lore raw

Re: [PATCH v6 2/2] amd/iommu: skip bridge devices when updating IOMMU page tables

Quoted 9 lines · Roger Pau Monne

Bridges are not behind an IOMMU, and are already special cased and skipped in amd_iommu_add_device. Apply the same special casing when updating page tables.

This is required or else update_paging_mode will fail and return an error to the caller (amd_iommu_{un}map_page) which will destroy the domain.

Signature · 6 lines
Brian Woods

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel