mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 02:46:45 +07:00
521376741b
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. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Reviewed-by: Joerg Roedel <jroedel@suse.de> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20200520152201.3309416-2-jean-philippe@linaro.org Signed-off-by: Joerg Roedel <jroedel@suse.de>
49 lines
1.6 KiB
C
49 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef LINUX_PCI_ATS_H
|
|
#define LINUX_PCI_ATS_H
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#ifdef CONFIG_PCI_ATS
|
|
/* Address Translation Service */
|
|
bool pci_ats_supported(struct pci_dev *dev);
|
|
int pci_enable_ats(struct pci_dev *dev, int ps);
|
|
void pci_disable_ats(struct pci_dev *dev);
|
|
int pci_ats_queue_depth(struct pci_dev *dev);
|
|
int pci_ats_page_aligned(struct pci_dev *dev);
|
|
#else /* CONFIG_PCI_ATS */
|
|
static inline bool pci_ats_supported(struct pci_dev *d)
|
|
{ return false; }
|
|
static inline int pci_enable_ats(struct pci_dev *d, int ps)
|
|
{ return -ENODEV; }
|
|
static inline void pci_disable_ats(struct pci_dev *d) { }
|
|
static inline int pci_ats_queue_depth(struct pci_dev *d)
|
|
{ return -ENODEV; }
|
|
static inline int pci_ats_page_aligned(struct pci_dev *dev)
|
|
{ return 0; }
|
|
#endif /* CONFIG_PCI_ATS */
|
|
|
|
#ifdef CONFIG_PCI_PRI
|
|
int pci_enable_pri(struct pci_dev *pdev, u32 reqs);
|
|
void pci_disable_pri(struct pci_dev *pdev);
|
|
int pci_reset_pri(struct pci_dev *pdev);
|
|
int pci_prg_resp_pasid_required(struct pci_dev *pdev);
|
|
#endif /* CONFIG_PCI_PRI */
|
|
|
|
#ifdef CONFIG_PCI_PASID
|
|
int pci_enable_pasid(struct pci_dev *pdev, int features);
|
|
void pci_disable_pasid(struct pci_dev *pdev);
|
|
int pci_pasid_features(struct pci_dev *pdev);
|
|
int pci_max_pasids(struct pci_dev *pdev);
|
|
#else /* CONFIG_PCI_PASID */
|
|
static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
|
|
{ return -EINVAL; }
|
|
static inline void pci_disable_pasid(struct pci_dev *pdev) { }
|
|
static inline int pci_pasid_features(struct pci_dev *pdev)
|
|
{ return -EINVAL; }
|
|
static inline int pci_max_pasids(struct pci_dev *pdev)
|
|
{ return -EINVAL; }
|
|
#endif /* CONFIG_PCI_PASID */
|
|
|
|
#endif /* LINUX_PCI_ATS_H */
|