iommu: Prevent VMD child devices from being remapping targets
PATCH v3 1/1 iommu: Prevent VMD child devices from being remapping targets
VMD child devices must use the VMD endpoint's ID as the requester. Because of this, there needs to be a way to link the parent VMD endpoint's iommu group and associated mappings to the VMD child devices such that attaching and detaching child devices modify the endpoint's mappings, while preventing early detaching on a singular device removal or unbinding.
The reassignment of individual VMD child devices devices to VMs is outside the scope of VMD, but may be implemented in the future. For now it is best to prevent any such attempts.
This patch prevents VMD child devices from returning an IOMMU, which prevents it from exposing an iommu_group sysfs directories and allowing subsequent binding by userspace-access drivers such as VFIO.
---
v2->3, wrapped in x86 ifdef to avoid ia64 compilation errors
drivers/iommu/intel-iommu.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/intel-iommu.c +7 -0
@@ -901,6 +901,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfstruct pci_dev *pf_pdev; pdev =to_pci_dev (dev); + +#ifdef CONFIG_X86 +/* VMD child devices currently cannot be handled individually */ +if (is_vmd (pdev->bus)) +return NULL ; +#endif +/* VFs aren't listed in scope tables; we need to look up * the PF instead to find the IOMMU. */ pf_pdev =pci_physfn (pdev);
Signature · 1 line
1.8.3.1
Bjorn Helgaas
AppliedQuoted 11 lines · Jon Derrick
VMD child devices must use the VMD endpoint's ID as the requester. Because of this, there needs to be a way to link the parent VMD endpoint's iommu group and associated mappings to the VMD child devices such that attaching and detaching child devices modify the endpoint's mappings, while preventing early detaching on a singular device removal or unbinding.
The reassignment of individual VMD child devices devices to VMs is outside the scope of VMD, but may be implemented in the future. For now it is best to prevent any such attempts.
Quoted 5 lines
This patch prevents VMD child devices from returning an IOMMU, which prevents it from exposing an
iommu_groupsysfs directories and allowing subsequent binding by userspace-access drivers such as VFIO.Signed-off-by Jon Derrick <[email protected]>
Applied to pci/host-vmd for v4.14, thanks!
Quoted 27 lines
---
v2->3, wrapped in x86 ifdef to avoid ia64 compilation errorsdrivers/iommu/intel-iommu.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/iommu/intel-iommu.c +7
-0@@ -901,6 +901,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfstruct pci_dev *pf_pdev; pdev =to_pci_dev (dev); + +#ifdef CONFIG_X86 +/* VMD child devices currently cannot be handled individually */ +if (is_vmd (pdev->bus)) +return NULL ; +#endif +/* VFs aren't listed in scope tables; we need to look up * the PF instead to find the IOMMU. */ pf_pdev =pci_physfn (pdev);Signature · 1 line
1.8.3.1