Skip to contentSkip to conversation

AMD/IOMMU: check fault-reported dev ID against table limit

PATCH New Jan Beulich 1 participant 1 message Nov 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AMD/IOMMU: check fault-reported dev ID against table limit

Requests with IDs beyond the device table limit report the bad ID in the resulting fault. Hence like hardware we should not try to access the (out- of-bounds) table entry.

Fixes 0e461c2d7f45 ("AMD/IOMMU: walk trees upon page fault")
xen/drivers/passthrough/amd/iommu_map.c +6 -0
@@ -556,6 +556,12 @@ void amd_iommu_print_entries(const struc
     unsigned int level;
     const struct amd_iommu_dte *dt = iommu->dev_table.buffer;
 
+    if ( dev_id >= ivrs_bdf_entries )
+    {
+        printk("%pp: beyond table limit\n", &PCI_SBDF(iommu->sbdf.seg, dev_id));
+        return;
+    }
+
     if ( !dt[dev_id].tv )
     {
         printk("%pp: no root\n", &PCI_SBDF(iommu->sbdf.seg, dev_id));