Commit 924b6231 authored by David Woodhouse's avatar David Woodhouse

intel-iommu: Fix device-to-iommu mapping for PCI-PCI bridges.

When the DMAR table identifies that a PCI-PCI bridge belongs to a given
IOMMU, that means that the bridge and all devices behind it should be
associated with the IOMMU. Not just the bridge itself.

This fixes the device_to_iommu() function accordingly.

(It's broken if you have the same PCI bus numbers in multiple domains,
but this function was always broken in that way; I'll be dealing with
that later).
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent d0b03bd1
...@@ -477,11 +477,16 @@ static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn) ...@@ -477,11 +477,16 @@ static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn)
if (drhd->ignored) if (drhd->ignored)
continue; continue;
for (i = 0; i < drhd->devices_cnt; i++) for (i = 0; i < drhd->devices_cnt; i++) {
if (drhd->devices[i] && if (drhd->devices[i] &&
drhd->devices[i]->bus->number == bus && drhd->devices[i]->bus->number == bus &&
drhd->devices[i]->devfn == devfn) drhd->devices[i]->devfn == devfn)
return drhd->iommu; return drhd->iommu;
if (drhd->devices[i]->subordinate &&
drhd->devices[i]->subordinate->number <= bus &&
drhd->devices[i]->subordinate->subordinate >= bus)
return drhd->iommu;
}
if (drhd->include_all) if (drhd->include_all)
return drhd->iommu; return drhd->iommu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment