[PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES

Ankit Soni posted 2 patches 1 month ago
There is a newer version of this series
[PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Ankit Soni 1 month ago
Dynamic top is used to grow the page table levels. However, if the VA
size is small and the initial page table level already covers the entire
address space, table growth is not required. In that case, the generic
page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
error -EOPNOTSUPP and leads to domain initialization failure.

Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
via cfg.common.features, this keeps normal runtime behavior unchanged.

Signed-off-by: Ankit Soni <Ankit.Soni@amd.com>
---
 drivers/iommu/generic_pt/fmt/iommu_amdv1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/generic_pt/fmt/iommu_amdv1.c b/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
index 72a2337d0c55..61e025a85e6a 100644
--- a/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
+++ b/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
@@ -9,7 +9,7 @@
 	 BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |                           \
 	 BIT(PT_FEAT_AMDV1_FORCE_COHERENCE))
 #define PT_FORCE_ENABLED_FEATURES                                       \
-	(BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) | \
+	(BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |				\
 	 BIT(PT_FEAT_AMDV1_FORCE_COHERENCE))
 
 #include "iommu_template.h"
-- 
2.43.0
Re: [PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Vasant Hegde 4 weeks ago
+ Jason

On 3/9/2026 7:35 PM, Ankit Soni wrote:
> Dynamic top is used to grow the page table levels. However, if the VA
> size is small and the initial page table level already covers the entire
> address space, table growth is not required. In that case, the generic
> page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
> error -EOPNOTSUPP and leads to domain initialization failure.
> 
> Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
> domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
> via cfg.common.features, this keeps normal runtime behavior unchanged.
> 

Fixes: 879ced2bab1 ("iommupt: Add the AMD IOMMU v1 page table format")

> Signed-off-by: Ankit Soni <Ankit.Soni@amd.com>

Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>


-Vasant

> ---
>  drivers/iommu/generic_pt/fmt/iommu_amdv1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/generic_pt/fmt/iommu_amdv1.c b/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
> index 72a2337d0c55..61e025a85e6a 100644
> --- a/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
> +++ b/drivers/iommu/generic_pt/fmt/iommu_amdv1.c
> @@ -9,7 +9,7 @@
>  	 BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |                           \
>  	 BIT(PT_FEAT_AMDV1_FORCE_COHERENCE))
>  #define PT_FORCE_ENABLED_FEATURES                                       \
> -	(BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) | \
> +	(BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |				\
>  	 BIT(PT_FEAT_AMDV1_FORCE_COHERENCE))
>  
>  #include "iommu_template.h"
Re: [PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Jason Gunthorpe 4 weeks ago
On Wed, Mar 11, 2026 at 09:54:55PM +0530, Vasant Hegde wrote:
> 
> + Jason
> 
> On 3/9/2026 7:35 PM, Ankit Soni wrote:
> > Dynamic top is used to grow the page table levels. However, if the VA
> > size is small and the initial page table level already covers the entire
> > address space, table growth is not required. In that case, the generic
> > page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
> > error -EOPNOTSUPP and leads to domain initialization failure.
> > 
> > Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
> > domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
> > via cfg.common.features, this keeps normal runtime behavior unchanged.
> > 
> 
> Fixes: 879ced2bab1 ("iommupt: Add the AMD IOMMU v1 page table format")

No.. There is no bug here.

I don't really understand why you'd want to do this, the driver still
sets PT_FEAT_DYNAMIC_TOP, so what is the issue?

It shouldn't be removed from PT_FORCE_ENABLED_FEATURES, something else
is wrong.

Jason
Re: [PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Ankit Soni 4 weeks ago
On Wed, Mar 11, 2026 at 01:44:03PM -0300, Jason Gunthorpe wrote:
> On Wed, Mar 11, 2026 at 09:54:55PM +0530, Vasant Hegde wrote:
> > 
> > + Jason
> > 
> > On 3/9/2026 7:35 PM, Ankit Soni wrote:
> > > Dynamic top is used to grow the page table levels. However, if the VA
> > > size is small and the initial page table level already covers the entire
> > > address space, table growth is not required. In that case, the generic
> > > page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
> > > error -EOPNOTSUPP and leads to domain initialization failure.
> > > 
> > > Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
> > > domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
> > > via cfg.common.features, this keeps normal runtime behavior unchanged.
> > > 
> > 
> > Fixes: 879ced2bab1 ("iommupt: Add the AMD IOMMU v1 page table format")
> 
> No.. There is no bug here.
> 
> I don't really understand why you'd want to do this, the driver still
> sets PT_FEAT_DYNAMIC_TOP, so what is the issue?
> 
> It shouldn't be removed from PT_FORCE_ENABLED_FEATURES, something else
> is wrong.
> 
> Jason

When hw_max_vasz_lg2 = 32 and starting_level = 2, top_range.max_vasz_lg2
comes back as 32 (clamped by min(32, 39)), so it matches
common->max_vasz_lg2. The 'pt_init_common()' clears dynamic top because 
"the table can't grow beyond its current level." with next condition in
this function, domain init will fail with "-EOPNOTSUPP".

Ankit
Re: [PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Jason Gunthorpe 3 weeks, 6 days ago
On Thu, Mar 12, 2026 at 04:10:13AM +0000, Ankit Soni wrote:
> On Wed, Mar 11, 2026 at 01:44:03PM -0300, Jason Gunthorpe wrote:
> > On Wed, Mar 11, 2026 at 09:54:55PM +0530, Vasant Hegde wrote:
> > > 
> > > + Jason
> > > 
> > > On 3/9/2026 7:35 PM, Ankit Soni wrote:
> > > > Dynamic top is used to grow the page table levels. However, if the VA
> > > > size is small and the initial page table level already covers the entire
> > > > address space, table growth is not required. In that case, the generic
> > > > page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
> > > > error -EOPNOTSUPP and leads to domain initialization failure.
> > > > 
> > > > Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
> > > > domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
> > > > via cfg.common.features, this keeps normal runtime behavior unchanged.
> > > > 
> > > 
> > > Fixes: 879ced2bab1 ("iommupt: Add the AMD IOMMU v1 page table format")
> > 
> > No.. There is no bug here.
> > 
> > I don't really understand why you'd want to do this, the driver still
> > sets PT_FEAT_DYNAMIC_TOP, so what is the issue?
> > 
> > It shouldn't be removed from PT_FORCE_ENABLED_FEATURES, something else
> > is wrong.
> > 
> > Jason
> 
> When hw_max_vasz_lg2 = 32 and starting_level = 2, top_range.max_vasz_lg2
> comes back as 32 (clamped by min(32, 39)), so it matches
> common->max_vasz_lg2. The 'pt_init_common()' clears dynamic top because 
> "the table can't grow beyond its current level." with next condition in
> this function, domain init will fail with "-EOPNOTSUPP".

Ok, that is much clearer, but this is not the way to fix it.

First it needs test coverage added

And probably we should remove that if but it should be checked closely.

Jason
Re: [PATCH v3 1/2] iommu/amd: Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES
Posted by Ankit Soni 3 weeks, 6 days ago
On Thu, Mar 12, 2026 at 08:22:23AM -0300, Jason Gunthorpe wrote:
> On Thu, Mar 12, 2026 at 04:10:13AM +0000, Ankit Soni wrote:
> > On Wed, Mar 11, 2026 at 01:44:03PM -0300, Jason Gunthorpe wrote:
> > > On Wed, Mar 11, 2026 at 09:54:55PM +0530, Vasant Hegde wrote:
> > > > 
> > > > + Jason
> > > > 
> > > > On 3/9/2026 7:35 PM, Ankit Soni wrote:
> > > > > Dynamic top is used to grow the page table levels. However, if the VA
> > > > > size is small and the initial page table level already covers the entire
> > > > > address space, table growth is not required. In that case, the generic
> > > > > page table framework clears PT_FEAT_DYNAMIC_TOP, which in turn causes
> > > > > error -EOPNOTSUPP and leads to domain initialization failure.
> > > > > 
> > > > > Remove PT_FEAT_DYNAMIC_TOP from PT_FORCE_ENABLED_FEATURES, since during
> > > > > domain allocation AMD IOMMU driver explicitly sets PT_FEAT_DYNAMIC_TOP
> > > > > via cfg.common.features, this keeps normal runtime behavior unchanged.
> > > > > 
> > > > 
> > > > Fixes: 879ced2bab1 ("iommupt: Add the AMD IOMMU v1 page table format")
> > > 
> > > No.. There is no bug here.
> > > 
> > > I don't really understand why you'd want to do this, the driver still
> > > sets PT_FEAT_DYNAMIC_TOP, so what is the issue?
> > > 
> > > It shouldn't be removed from PT_FORCE_ENABLED_FEATURES, something else
> > > is wrong.
> > > 
> > > Jason
> > 
> > When hw_max_vasz_lg2 = 32 and starting_level = 2, top_range.max_vasz_lg2
> > comes back as 32 (clamped by min(32, 39)), so it matches
> > common->max_vasz_lg2. The 'pt_init_common()' clears dynamic top because 
> > "the table can't grow beyond its current level." with next condition in
> > this function, domain init will fail with "-EOPNOTSUPP".
> 
> Ok, that is much clearer, but this is not the way to fix it.
> 
> First it needs test coverage added
> 
> And probably we should remove that if but it should be checked closely.
> 
> Jason

Thanks for the heads‑up. I’ll add the test coverage and the other changes
separately.

-Ankit