Skip to content

Commit

Permalink
Test patch fixing crash on AMD IOMMU init on some systems
Browse files Browse the repository at this point in the history
Details on XenProject matrix channel.
  • Loading branch information
marmarek committed Sep 30, 2024
1 parent 0f8d32f commit aa617d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 9999-amd-iommu-test.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 3f5508eba049..2573f59abcfd 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -248,6 +248,29 @@ static int __init register_range_for_device(
iommu = find_iommu_for_device(seg, bdf);
if ( !iommu )
{
+ const struct pci_dev *pdev;
+
+ for_each_amd_iommu(iommu)
+ {
+ if ( iommu->seg == seg && iommu->bdf == bdf )
+ {
+ AMD_IOMMU_WARN("IVMD: IOMMU %pp not covered by IVRS\n",
+ &PCI_SBDF(seg, bdf));
+ return 0;
+ }
+ }
+
+ pcidevs_lock();
+ pdev = pci_get_pdev(NULL, PCI_SBDF(seg, bdf));
+ /* No need to hold the lock - the device can't be removed at init. */
+ pcidevs_unlock();
+ if ( pdev && pdev->type == DEV_TYPE_PCI_HOST_BRIDGE )
+ {
+ AMD_IOMMU_WARN("IVMD: PCI Host bridge %pp not covered by IVRS\n",
+ &PCI_SBDF(seg, bdf));
+ return 0;
+ }
+
AMD_IOMMU_ERROR("IVMD: no IOMMU for Dev_Id %#x\n", bdf);
return -ENODEV;
}

2 changes: 2 additions & 0 deletions xen.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ Patch1200: 1200-hypercall-XENMEM_get_mfn_from_pfn.patch
Patch1201: 1201-patch-gvt-hvmloader.patch.patch
Patch1202: 1202-libxl-Add-partially-Intel-GVT-g-support-xengt-device.patch

Patch9999: 9999-amd-iommu-test.patch

%if %build_qemutrad
BuildRequires: libidn-devel zlib-devel SDL-devel curl-devel
BuildRequires: libX11-devel gtk2-devel libaio-devel
Expand Down

0 comments on commit aa617d0

Please sign in to comment.