summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Zhang <zhangyu1@linux.microsoft.com>2026-03-31 18:25:50 +0300
committerJoerg Roedel <joerg.roedel@amd.com>2026-05-11 10:36:51 +0300
commit45ccfdd3b577f3f0a9e86fe3f37132798dfbb2a1 (patch)
tree9dde9e0e0737c71ba19a6f3df6421daab3f0bda8
parent4bf53c2d0c08bbdaa32f2114281f1ddab61902bf (diff)
downloadlinux-45ccfdd3b577f3f0a9e86fe3f37132798dfbb2a1.tar.xz
iommu/amd: Remove dead code for exclusion ranges in IVMD
Exclusion ranges in IVMD are treated as unity mappings with r&w permissions since commit 0bbe4ced53e3 ("iommu/amd: Fix the overwritten field in IVMD header"), using 1:1 mappings. And IOMMU Exclusion Base & Range Limit Registers (0x0020/0x0028) are actually no longer used. As a result, several definitions and code paths became dead code: - exclusion_start/exclusion_length in struct amd_iommu are never assigned, - iommu_set_exclusion_range() always returns 0 now. - MMIO_EXCL_ENABLE_MASK & MMIO_EXCL_ALLOW_MASK are only used by the removed iommu_set_exclusion_range(). - DEV_ENTRY_EX is no longer set in any DTE. - IOMMU_UNITY_MAP_FLAG_EXCL_RANGE is no longer set, thus the IOMMU_RESV_RESERVED branch in amd_iommu_get_resv_regions() is no longer reachable. Just remove all of the dead code. No functional change. Signed-off-by: Yu Zhang <zhangyu1@linux.microsoft.com> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Reviewed-by: Jacob Pan <jacob.pan@linux.microsoft.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
-rw-r--r--drivers/iommu/amd/amd_iommu_types.h12
-rw-r--r--drivers/iommu/amd/init.c23
-rw-r--r--drivers/iommu/amd/iommu.c3
3 files changed, 0 insertions, 38 deletions
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index c726d115939a..9fc9e8f0887a 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -51,10 +51,6 @@
#define MMIO_GET_BUS(x) (((x) & MMIO_RANGE_BUS_MASK) >> MMIO_RANGE_BUS_SHIFT)
#define MMIO_MSI_NUM(x) ((x) & 0x1f)
-/* Flag masks for the AMD IOMMU exclusion range */
-#define MMIO_EXCL_ENABLE_MASK 0x01ULL
-#define MMIO_EXCL_ALLOW_MASK 0x02ULL
-
/* Used offsets into the MMIO space */
#define MMIO_DEV_TABLE_OFFSET 0x0000
#define MMIO_CMD_BUF_OFFSET 0x0008
@@ -231,7 +227,6 @@
#define DEV_ENTRY_IR 0x3d
#define DEV_ENTRY_IW 0x3e
#define DEV_ENTRY_NO_PAGE_FAULT 0x62
-#define DEV_ENTRY_EX 0x67
#define DEV_ENTRY_SYSMGT1 0x68
#define DEV_ENTRY_SYSMGT2 0x69
#define DTE_DATA1_SYSMGT_MASK GENMASK_ULL(41, 40)
@@ -389,8 +384,6 @@
#define IOMMU_PROT_IR 0x01
#define IOMMU_PROT_IW 0x02
-#define IOMMU_UNITY_MAP_FLAG_EXCL_RANGE (1 << 2)
-
/* IOMMU capabilities */
#define IOMMU_CAP_IOTLB 24
#define IOMMU_CAP_NPCACHE 26
@@ -685,11 +678,6 @@ struct amd_iommu {
/* pci domain of this IOMMU */
struct amd_iommu_pci_seg *pci_seg;
- /* start of exclusion range of that IOMMU */
- u64 exclusion_start;
- /* length of exclusion range of that IOMMU */
- u64 exclusion_length;
-
/* command buffer virtual address */
u8 *cmd_buf;
u32 cmd_buf_head;
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 16a4567984b8..d146fa2f57ae 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -355,28 +355,6 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val)
*
****************************************************************************/
-/*
- * This function set the exclusion range in the IOMMU. DMA accesses to the
- * exclusion range are passed through untranslated
- */
-static void iommu_set_exclusion_range(struct amd_iommu *iommu)
-{
- u64 start = iommu->exclusion_start & PAGE_MASK;
- u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK;
- u64 entry;
-
- if (!iommu->exclusion_start)
- return;
-
- entry = start | MMIO_EXCL_ENABLE_MASK;
- memcpy_toio(iommu->mmio_base + MMIO_EXCL_BASE_OFFSET,
- &entry, sizeof(entry));
-
- entry = limit;
- memcpy_toio(iommu->mmio_base + MMIO_EXCL_LIMIT_OFFSET,
- &entry, sizeof(entry));
-}
-
static void iommu_set_cwwb_range(struct amd_iommu *iommu)
{
u64 start = iommu_virt_to_phys((void *)iommu->cmd_sem);
@@ -2905,7 +2883,6 @@ static void early_enable_iommu(struct amd_iommu *iommu)
iommu_init_flags(iommu);
iommu_set_device_table(iommu);
iommu_enable_command_buffer(iommu);
- iommu_set_exclusion_range(iommu);
iommu_enable_gt(iommu);
iommu_enable_ga(iommu);
iommu_enable_xt(iommu);
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index f78e23f03938..f1333071da10 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3082,9 +3082,6 @@ static void amd_iommu_get_resv_regions(struct device *dev,
prot |= IOMMU_READ;
if (entry->prot & IOMMU_PROT_IW)
prot |= IOMMU_WRITE;
- if (entry->prot & IOMMU_UNITY_MAP_FLAG_EXCL_RANGE)
- /* Exclusion range */
- type = IOMMU_RESV_RESERVED;
region = iommu_alloc_resv_region(entry->address_start,
length, prot, type,