Skip to content

Commit 7a441b2

Browse files
jpbruckerjoergroedel
authored andcommitted
iommu/amd: Use pci_ats_supported()
The pci_ats_supported() function checks if a device supports ATS and is allowed to use it. In addition to checking that the device has an ATS capability and that the global pci=noats is not set (pci_ats_disabled()), it also checks if a device is untrusted. 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. By calling pci_ats_supported() we keep DTE[I]=0 for untrusted devices and abort transactions with Pretranslated Addresses. Signed-off-by: Jean-Philippe Brucker <[email protected]> Reviewed-by: Joerg Roedel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5213767 commit 7a441b2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,15 @@ static struct iommu_group *acpihid_device_group(struct device *dev)
291291
static bool pci_iommuv2_capable(struct pci_dev *pdev)
292292
{
293293
static const int caps[] = {
294-
PCI_EXT_CAP_ID_ATS,
295294
PCI_EXT_CAP_ID_PRI,
296295
PCI_EXT_CAP_ID_PASID,
297296
};
298297
int i, pos;
299298

300-
if (pci_ats_disabled())
299+
if (!pci_ats_supported(pdev))
301300
return false;
302301

303-
for (i = 0; i < 3; ++i) {
302+
for (i = 0; i < 2; ++i) {
304303
pos = pci_find_ext_capability(pdev, caps[i]);
305304
if (pos == 0)
306305
return false;
@@ -3028,11 +3027,8 @@ int amd_iommu_device_info(struct pci_dev *pdev,
30283027

30293028
memset(info, 0, sizeof(*info));
30303029

3031-
if (!pci_ats_disabled()) {
3032-
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS);
3033-
if (pos)
3034-
info->flags |= AMD_IOMMU_DEVICE_FLAG_ATS_SUP;
3035-
}
3030+
if (pci_ats_supported(pdev))
3031+
info->flags |= AMD_IOMMU_DEVICE_FLAG_ATS_SUP;
30363032

30373033
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
30383034
if (pos)

0 commit comments

Comments
 (0)