iommu: Add capability for pre-boot DMA protection
authorRobin Murphy <robin.murphy@arm.com>
Mon, 25 Apr 2022 12:42:03 +0000 (13:42 +0100)
committerJoerg Roedel <jroedel@suse.de>
Thu, 28 Apr 2022 08:30:25 +0000 (10:30 +0200)
VT-d's dmar_platform_optin() actually represents a combination of
properties fairly well standardised by Microsoft as "Pre-boot DMA
Protection" and "Kernel DMA Protection"[1]. As such, we can provide
interested consumers with an abstracted capability rather than
driver-specific interfaces that won't scale. We name it for the former
aspect since that's what external callers are most likely to be
interested in; the latter is for the IOMMU layer to handle itself.

[1] https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-kernel-dma-protection

Suggested-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/d6218dff2702472da80db6aec2c9589010684551.1650878781.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/iommu.c
include/linux/iommu.h

index df5c62ecf942b8e0b402cf05dbb79a9ee95835ed..0edf6084dc148aca1b9c7a63944dfa6d6f67aac0 100644 (file)
@@ -4551,6 +4551,8 @@ static bool intel_iommu_capable(enum iommu_cap cap)
                return domain_update_iommu_snooping(NULL);
        if (cap == IOMMU_CAP_INTR_REMAP)
                return irq_remapping_enabled == 1;
+       if (cap == IOMMU_CAP_PRE_BOOT_PROTECTION)
+               return dmar_platform_optin();
 
        return false;
 }
index e26cf84e5d82da3f377ce3d8abfd1e08f1b06373..4123693ae319ebd4be69f6faf9ed2d2edc17f9b2 100644 (file)
@@ -107,6 +107,8 @@ enum iommu_cap {
                                           transactions */
        IOMMU_CAP_INTR_REMAP,           /* IOMMU supports interrupt isolation */
        IOMMU_CAP_NOEXEC,               /* IOMMU_NOEXEC flag */
+       IOMMU_CAP_PRE_BOOT_PROTECTION,  /* Firmware says it used the IOMMU for
+                                          DMA protection and we should too */
 };
 
 /* These are the possible reserved region types */