From: Yu Zhang <zhangyu1@linux.microsoft.com>
To: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org,
iommu@lists.linux.dev, linux-pci@vger.kernel.org,
linux-arch@vger.kernel.org, x86@kernel.org
Cc: wei.liu@kernel.org, kys@microsoft.com, haiyangz@microsoft.com,
decui@microsoft.com, longli@microsoft.com, joro@8bytes.org,
will@kernel.org, robin.murphy@arm.com, bhelgaas@google.com,
kwilczynski@kernel.org, lpieralisi@kernel.org, mani@kernel.org,
robh@kernel.org, arnd@arndb.de, jgg@ziepe.ca,
mhklinux@outlook.com, jacob.pan@linux.microsoft.com,
tgopinath@linux.microsoft.com,
easwar.hariharan@linux.microsoft.com,
mrathor@linux.microsoft.com, baolu.lu@linux.intel.com,
suravee.suthikulpanit@amd.com, vasant.hegde@amd.com
Subject: [PATCH v4 3/5] iommu/x86: Add architectural MSI reserved region helper
Date: Fri, 21 Aug 2026 21:26:52 +0800 [thread overview]
Message-ID: <20260821132654.211730-4-zhangyu1@linux.microsoft.com> (raw)
In-Reply-To: <20260821132654.211730-1-zhangyu1@linux.microsoft.com>
Intel and AMD IOMMU drivers both reserve the x86 architectural MSI
address window from normal IOVA mappings, but each open-codes the range
and its allocation attributes.
Add iommu_alloc_resv_x86_msi_region() to encapsulate those details, and
convert the Intel and AMD drivers to use it.
Signed-off-by: Yu Zhang <zhangyu1@linux.microsoft.com>
---
arch/x86/include/asm/iommu.h | 14 ++++++++++++++
drivers/iommu/amd/iommu.c | 6 +-----
drivers/iommu/intel/iommu.c | 6 +-----
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index 3be2451e7bc8..6404f4fbeae8 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,15 @@ extern bool x86_swiotlb_enable;
/* 10 seconds */
#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)
+#ifdef CONFIG_IOMMU_API
+static inline struct iommu_resv_region *
+iommu_alloc_resv_x86_msi_region(void)
+{
+ return iommu_alloc_resv_region(0xfee00000, SZ_1M, 0,
+ IOMMU_RESV_MSI, GFP_KERNEL);
+}
+#endif
+
static inline int __init
arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
{
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 4dc306a4b5c6..b9bbd9aa99a8 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -50,8 +50,6 @@
#define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28))
/* Reserved IOVA ranges */
-#define MSI_RANGE_START (0xfee00000)
-#define MSI_RANGE_END (0xfeefffff)
#define HT_RANGE_START (0xfd00000000ULL)
#define HT_RANGE_END (0xffffffffffULL)
@@ -3140,9 +3138,7 @@ static void amd_iommu_get_resv_regions(struct device *dev,
list_add_tail(®ion->list, head);
}
- region = iommu_alloc_resv_region(MSI_RANGE_START,
- MSI_RANGE_END - MSI_RANGE_START + 1,
- 0, IOMMU_RESV_MSI, GFP_KERNEL);
+ region = iommu_alloc_resv_x86_msi_region();
if (!region)
return;
list_add_tail(®ion->list, head);
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2e3b3ab216f8..c4de4bbcb065 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -39,8 +39,6 @@
#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
-#define IOAPIC_RANGE_START (0xfee00000)
-#define IOAPIC_RANGE_END (0xfeefffff)
#define IOVA_START_ADDR (0x1000)
#define DEFAULT_DOMAIN_ADDRESS_WIDTH 57
@@ -3459,9 +3457,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
}
#endif /* CONFIG_INTEL_IOMMU_FLOPPY_WA */
- reg = iommu_alloc_resv_region(IOAPIC_RANGE_START,
- IOAPIC_RANGE_END - IOAPIC_RANGE_START + 1,
- 0, IOMMU_RESV_MSI, GFP_KERNEL);
+ reg = iommu_alloc_resv_x86_msi_region();
if (!reg)
return;
list_add_tail(®->list, head);
--
2.52.0
next prev parent reply other threads:[~2026-08-21 13:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 13:26 [PATCH v4 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-08-21 13:26 ` [PATCH v4 1/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-08-21 13:41 ` sashiko-bot
2026-08-21 13:26 ` [PATCH v4 2/5] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-08-21 13:33 ` sashiko-bot
2026-08-21 13:26 ` Yu Zhang [this message]
2026-08-21 13:33 ` [PATCH v4 3/5] iommu/x86: Add architectural MSI reserved region helper sashiko-bot
2026-08-21 13:26 ` [PATCH v4 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-08-21 13:45 ` sashiko-bot
2026-08-21 13:26 ` [PATCH v4 5/5] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-08-21 13:41 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260821132654.211730-4-zhangyu1@linux.microsoft.com \
--to=zhangyu1@linux.microsoft.com \
--cc=arnd@arndb.de \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=decui@microsoft.com \
--cc=easwar.hariharan@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.pan@linux.microsoft.com \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kwilczynski@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mrathor@linux.microsoft.com \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tgopinath@linux.microsoft.com \
--cc=vasant.hegde@amd.com \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox