Skip to content

Commit

Permalink
thunderbolt: Use pre-boot DMA protection on AMD systems
Browse files Browse the repository at this point in the history
The information is exported from the IOMMU driver whether or not
pre-boot DMA protection has been enabled on AMD systems.  Use this
information to properly set iomma_dma_protection.

Link: https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-kernel-dma-protection
Link: https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
  • Loading branch information
superm1 authored and intel-lab-lkp committed Mar 15, 2022
1 parent fa63035 commit 9b0b707
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/thunderbolt/domain.c
Expand Up @@ -6,6 +6,7 @@
* Author: Mika Westerberg <mika.westerberg@linux.intel.com>
*/

#include <linux/amd-iommu.h>
#include <linux/device.h>
#include <linux/dmar.h>
#include <linux/idr.h>
Expand Down Expand Up @@ -259,11 +260,15 @@ static ssize_t iommu_dma_protection_show(struct device *dev,
{
/*
* Kernel DMA protection is a feature where Thunderbolt security is
* handled natively using IOMMU. It is enabled when IOMMU is
* enabled and ACPI DMAR table has DMAR_PLATFORM_OPT_IN set.
* handled natively using IOMMU. It is enabled when the IOMMU is
* enabled and either:
* ACPI DMAR table has DMAR_PLATFORM_OPT_IN set
* or
* ACPI IVRS table has DMA_REMAP bitset
*/
return sprintf(buf, "%d\n",
iommu_present(&pci_bus_type) && dmar_platform_optin());
iommu_present(&pci_bus_type) &&
(dmar_platform_optin() || amd_ivrs_remap_support()));
}
static DEVICE_ATTR_RO(iommu_dma_protection);

Expand Down

0 comments on commit 9b0b707

Please sign in to comment.