History

PCI/ATS: Only enable ATS for trusted devices

Add pci_ats_supported(), which checks whether a device has an ATS capability, and whether it is trusted. A device is untrusted if it is plugged into an external-facing port such as Thunderbolt and could be spoofing an existing device to exploit weaknesses in the IOMMU configuration. PCIe ATS is one such weaknesses since it allows endpoints to cache IOMMU translations and emit transactions with 'Translated' Address Type (10b) that partially bypass the IOMMU translation. The SMMUv3 and VT-d IOMMU drivers already disallow ATS and transactions with 'Translated' Address Type for untrusted devices. Add the check to pci_enable_ats() to let other drivers (AMD IOMMU for now) benefit from it. By checking ats_cap, the pci_ats_supported() helper also returns whether ATS was globally disabled with pci=noats, and could later include more things, for example whether the whole PCIe hierarchy down to the endpoint supports ATS.

Jean-Philippe Brucker committed 6 years ago

Commit 52137671 parent 79659192 files · +20 −1Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/pci-ats.h+3−0
@@ -6,11 +6,14 @@ · 5 unmodified lines
6 6
7#ifdef CONFIG_PCI_ATS7#ifdef CONFIG_PCI_ATS
8/* Address Translation Service */8/* Address Translation Service */
9bool pci_ats_supported(struct pci_dev *dev);
9int pci_enable_ats(struct pci_dev *dev, int ps);10int pci_enable_ats(struct pci_dev *dev, int ps);
10void pci_disable_ats(struct pci_dev *dev);11void pci_disable_ats(struct pci_dev *dev);
11int pci_ats_queue_depth(struct pci_dev *dev);12int pci_ats_queue_depth(struct pci_dev *dev);
12int pci_ats_page_aligned(struct pci_dev *dev);13int pci_ats_page_aligned(struct pci_dev *dev);
13#else /* CONFIG_PCI_ATS */14#else /* CONFIG_PCI_ATS */
15static inline bool pci_ats_supported(struct pci_dev *d)
16{ return false; }
14static inline int pci_enable_ats(struct pci_dev *d, int ps)17static inline int pci_enable_ats(struct pci_dev *d, int ps)
15{ return -ENODEV; }18{ return -ENODEV; }
16static inline void pci_disable_ats(struct pci_dev *d) { }19static inline void pci_disable_ats(struct pci_dev *d) { }