All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Add support for HTRangeIgnore feature
@ 2025-03-17  5:50 Sairaj Kodilkar
  2025-05-01 10:26 ` Vasant Hegde
  2025-05-02  6:38 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Sairaj Kodilkar @ 2025-03-17  5:50 UTC (permalink / raw)
  To: joro, iommu
  Cc: suravee.suthikulpanit, will, robin.murphy, vasant.hegde, sarunkod

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>
---
 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(+)

diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
index 68debf5ee2d7..156eb66caca1 100644
--- a/drivers/iommu/amd/amd_iommu.h
+++ b/drivers/iommu/amd/amd_iommu.h
@@ -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.
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index 23caea22f8dc..1b3fc25bcdbf 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -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.
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index cb536d372b12..538af5a7418f 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -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.
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index cd5116d8c3b2..4985855914a3 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2907,6 +2907,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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/amd: Add support for HTRangeIgnore feature
  2025-03-17  5:50 [PATCH] iommu/amd: Add support for HTRangeIgnore feature Sairaj Kodilkar
@ 2025-05-01 10:26 ` Vasant Hegde
  2025-05-02  6:38 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Vasant Hegde @ 2025-05-01 10:26 UTC (permalink / raw)
  To: Sairaj Kodilkar, joro, iommu; +Cc: suravee.suthikulpanit, will, robin.murphy



On 3/17/2025 11:20 AM, Sairaj Kodilkar wrote:
> 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>

-Vasant

> ---
>  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(+)
> 
> diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
> index 68debf5ee2d7..156eb66caca1 100644
> --- a/drivers/iommu/amd/amd_iommu.h
> +++ b/drivers/iommu/amd/amd_iommu.h
> @@ -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.
> diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
> index 23caea22f8dc..1b3fc25bcdbf 100644
> --- a/drivers/iommu/amd/amd_iommu_types.h
> +++ b/drivers/iommu/amd/amd_iommu_types.h
> @@ -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.
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index cb536d372b12..538af5a7418f 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -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.
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index cd5116d8c3b2..4985855914a3 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2907,6 +2907,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);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/amd: Add support for HTRangeIgnore feature
  2025-03-17  5:50 [PATCH] iommu/amd: Add support for HTRangeIgnore feature Sairaj Kodilkar
  2025-05-01 10:26 ` Vasant Hegde
@ 2025-05-02  6:38 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2025-05-02  6:38 UTC (permalink / raw)
  To: Sairaj Kodilkar
  Cc: iommu, suravee.suthikulpanit, will, robin.murphy, vasant.hegde

On Mon, Mar 17, 2025 at 11:20:20AM +0530, Sairaj Kodilkar wrote:
> Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
> ---
>  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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-02  6:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  5:50 [PATCH] iommu/amd: Add support for HTRangeIgnore feature Sairaj Kodilkar
2025-05-01 10:26 ` Vasant Hegde
2025-05-02  6:38 ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.