summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorYu Zhang <zhangyu1@linux.microsoft.com>2026-09-30 22:14:07 +0800
committerJoerg Roedel <joerg.roedel@amd.com>2026-10-09 10:37:41 +0200
commit07f8807ca978f486243e93aa4e85d20df871cd7f (patch)
treeab68ffde6a948d98094ec82f902fb3eef5b6efb2 /arch
parent118bdac1054628c04c547c2c988bb06ca43677a3 (diff)
downloadlinux-07f8807ca978f486243e93aa4e85d20df871cd7f.tar.gz
linux-07f8807ca978f486243e93aa4e85d20df871cd7f.zip
iommu/x86: Add architectural MSI reserved region helper
Intel and AMD IOMMU drivers both reserve the x86 architectural MSI address window from normal IOVA mappings, but each open-codes the range, allocation attributes, and insertion into the reserved-region list. Add iommu_add_resv_x86_msi_region() to encapsulate those operations, and convert the Intel and AMD drivers to use it. Return an error on allocation failure so callers can preserve their existing error paths. Signed-off-by: Yu Zhang <zhangyu1@linux.microsoft.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/iommu.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index 3be2451e7bc8..4e1e55c3c09a 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -4,6 +4,11 @@
#include <linux/acpi.h>
+#ifdef CONFIG_IOMMU_API
+#include <linux/iommu.h>
+#include <linux/sizes.h>
+#endif
+
#include <asm/e820/api.h>
extern int force_iommu, no_iommu;
@@ -21,6 +26,21 @@ extern bool x86_swiotlb_enable;
/* 10 seconds */
#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)
+#ifdef CONFIG_IOMMU_API
+static inline int iommu_add_resv_x86_msi_region(struct list_head *head)
+{
+ struct iommu_resv_region *region;
+
+ region = iommu_alloc_resv_region(0xfee00000, SZ_1M, 0,
+ IOMMU_RESV_MSI, GFP_KERNEL);
+ if (!region)
+ return -ENOMEM;
+
+ list_add_tail(&region->list, head);
+ return 0;
+}
+#endif
+
static inline int __init
arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
{