iommu/amd: Add support for HTRangeIgnore feature
Subsystems (2)
PATCH 1/1 iommu/amd: Add support for HTRangeIgnore feature
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.
--- drivers/iommu/amd/amd_iommu.h | 2 ++ drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/init.c | 5 +++++ drivers/iommu/amd/iommu.c | 3 +++ 4 files changed, 11 insertions(+)
drivers/iommu/amd/amd_iommu.h +2 -0
@@ -148,6 +148,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.
drivers/iommu/amd/amd_iommu_types.h +1 -0
@@ -111,6 +111,7 @@#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)/* Note: * The current driver only support 16-bit PASID.
drivers/iommu/amd/init.c +5 -0
@@ -258,6 +258,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.
drivers/iommu/amd/iommu.c +3 -0
@@ -2907,6 +2907,9 @@ static void amd_iommu_get_resv_regions(struct device *dev,return ;list_add_tail (®ion->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 );
Signature · 1 line
2.34.1
Quoted 8 lines · Sairaj Kodilkar
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
HTRangeIgnoreis 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 <[email protected]>
-Vasant
Quoted 62 lines
--- drivers/iommu/amd/amd_iommu.h | 2 ++ drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/init.c | 5 +++++ drivers/iommu/amd/iommu.c | 3 +++ 4 files changed, 11 insertions(+)drivers/iommu/amd/amd_iommu.h +2
-0@@ -148,6 +148,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. drivers/iommu/amd/amd_iommu_types.h +1
-0@@ -111,6 +111,7 @@#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)/* Note: * The current driver only support 16-bit PASID. drivers/iommu/amd/init.c +5
-0@@ -258,6 +258,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. drivers/iommu/amd/iommu.c +3
-0@@ -2907,6 +2907,9 @@ static void amd_iommu_get_resv_regions(struct device *dev,return ;list_add_tail (®ion->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 );
Quoted 7 lines · Sairaj Kodilkar
Signed-off-by Sairaj Kodilkar <[email protected]>--- drivers/iommu/amd/amd_iommu.h | 2 ++ drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/init.c | 5 +++++ drivers/iommu/amd/iommu.c | 3 +++ 4 files changed, 11 insertions(+)
Applied, thanks.