]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Add support for HTRangeIgnore feature
authorSairaj Kodilkar <sarunkod@amd.com>
Mon, 17 Mar 2025 05:50:20 +0000 (11:20 +0530)
committerJoerg Roedel <jroedel@suse.de>
Fri, 2 May 2025 06:38:09 +0000 (08:38 +0200)
AMD IOMMU reserves the address range 0xfd00000000-0xffffffffff for
the hypertransport protocol (HT) and has special meaning. Hence devices
cannot use this address range for the DMA. However on some AMD platforms
this HT range is shifted to the very top of the address space and new
feature bit `HTRangeIgnore` is introduced. When this feature bit is on,
IOMMU treats the GPA access to the legacy HT range as regular GPA access.

Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20250317055020.25214-1-sarunkod@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/amd_iommu.h
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/init.c
drivers/iommu/amd/iommu.c

index 220c598b7e1486fe0f0b78aa4c8bd090194b3e57..29a8864381c3592bbfa5ce04b44e9435b4e9d5a6 100644 (file)
@@ -147,6 +147,8 @@ static inline int get_pci_sbdf_id(struct pci_dev *pdev)
        return PCI_SEG_DEVID_TO_SBDF(seg, devid);
 }
 
+bool amd_iommu_ht_range_ignore(void);
+
 /*
  * This must be called after device probe completes. During probe
  * use rlookup_amd_iommu() get the iommu.
index 5089b58e528a7bf1ca100cdede21c8ccd3b5152e..11dd152cfa9574d035242e2312ebd2be2f2efcfe 100644 (file)
 #define FEATURE_SNPAVICSUP     GENMASK_ULL(7, 5)
 #define FEATURE_SNPAVICSUP_GAM(x) \
        (FIELD_GET(FEATURE_SNPAVICSUP, x) == 0x1)
+#define FEATURE_HT_RANGE_IGNORE                BIT_ULL(11)
 
 #define FEATURE_NUM_INT_REMAP_SUP      GENMASK_ULL(9, 8)
 #define FEATURE_NUM_INT_REMAP_SUP_2K(x) \
index dd9e26b7b71848dd5449316df1eb2ee31eecb67f..acf8941e1ed3d66ab8fa50e53ceff88f6b1dbc17 100644 (file)
@@ -256,6 +256,11 @@ int amd_iommu_get_num_iommus(void)
        return amd_iommus_present;
 }
 
+bool amd_iommu_ht_range_ignore(void)
+{
+       return check_feature2(FEATURE_HT_RANGE_IGNORE);
+}
+
 /*
  * Iterate through all the IOMMUs to get common EFR
  * masks among all IOMMUs and warn if found inconsistency.
index 15e3342648811a999689128d612b25c0774003ef..95520bcf6c0e1230d8799ee4db02369ec8d3ca0b 100644 (file)
@@ -2916,6 +2916,9 @@ static void amd_iommu_get_resv_regions(struct device *dev,
                return;
        list_add_tail(&region->list, head);
 
+       if (amd_iommu_ht_range_ignore())
+               return;
+
        region = iommu_alloc_resv_region(HT_RANGE_START,
                                         HT_RANGE_END - HT_RANGE_START + 1,
                                         0, IOMMU_RESV_RESERVED, GFP_KERNEL);