mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ankit Soni <Ankit.Soni@amd.com>
To: <iommu@lists.linux.dev>
Cc: <vasant.hegde@amd.com>, <suravee.suthikulpanit@amd.com>,
	<joro@8bytes.org>, <will@kernel.org>, <robin.murphy@arm.com>,
	<linux-kernel@vger.kernel.org>, <jgg@ziepe.ca>
Subject: [PATCH v4 1/3] iommu_pt: support small VA for AMDv1
Date: Wed, 1 Apr 2026 14:43:55 +0000	[thread overview]
Message-ID: <62cb55fdc5e08dceeb6d740cb73f75c6bce36226.1775045213.git.Ankit.Soni@amd.com> (raw)
In-Reply-To: <cover.1775045213.git.Ankit.Soni@amd.com>

When hardware/VM request a small VA limit, the generic page table code
clears PT_FEAT_DYNAMIC_TOP. This later causes domain initialization to 
fail with -EOPNOTSUPP.
To properly enforce the domain VA limit, clamp amdv1pt_possible_sizes
using the requested max_vasz_lg2.

Signed-off-by: Ankit Soni <Ankit.Soni@amd.com>
---
 drivers/iommu/generic_pt/fmt/amdv1.h | 4 +++-
 drivers/iommu/generic_pt/iommu_pt.h  | 4 ----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/generic_pt/fmt/amdv1.h b/drivers/iommu/generic_pt/fmt/amdv1.h
index 3b2c41d9654d..bc04d482c12f 100644
--- a/drivers/iommu/generic_pt/fmt/amdv1.h
+++ b/drivers/iommu/generic_pt/fmt/amdv1.h
@@ -156,6 +156,7 @@ static inline unsigned int amdv1pt_num_items_lg2(const struct pt_state *pts)
 static inline pt_vaddr_t amdv1pt_possible_sizes(const struct pt_state *pts)
 {
 	unsigned int isz_lg2 = pt_table_item_lg2sz(pts);
+	pt_vaddr_t raw;
 
 	if (!amdv1pt_can_have_leaf(pts))
 		return 0;
@@ -168,8 +169,9 @@ static inline pt_vaddr_t amdv1pt_possible_sizes(const struct pt_state *pts)
 	 * 512GB Pages are not supported due to a hardware bug.
 	 * Otherwise every power of two size is supported.
 	 */
-	return GENMASK_ULL(min(51, isz_lg2 + amdv1pt_num_items_lg2(pts) - 1),
+	raw = GENMASK_ULL(min(51, isz_lg2 + amdv1pt_num_items_lg2(pts) - 1),
 			   isz_lg2) & ~SZ_512G;
+	return fvalog2_mod(raw, pts->range->common->max_vasz_lg2);
 }
 #define pt_possible_sizes amdv1pt_possible_sizes
 
diff --git a/drivers/iommu/generic_pt/iommu_pt.h b/drivers/iommu/generic_pt/iommu_pt.h
index 3e33fe64feab..a3dc5cf14aeb 100644
--- a/drivers/iommu/generic_pt/iommu_pt.h
+++ b/drivers/iommu/generic_pt/iommu_pt.h
@@ -1125,10 +1125,6 @@ static int pt_init_common(struct pt_common *common)
 	if (PT_WARN_ON(top_range.top_level > PT_MAX_TOP_LEVEL))
 		return -EINVAL;
 
-	if (top_range.top_level == PT_MAX_TOP_LEVEL ||
-	    common->max_vasz_lg2 == top_range.max_vasz_lg2)
-		common->features &= ~BIT(PT_FEAT_DYNAMIC_TOP);
-
 	if (top_range.max_vasz_lg2 == PT_VADDR_MAX_LG2)
 		common->features |= BIT(PT_FEAT_FULL_VA);
 
-- 
2.43.0


  reply	other threads:[~2026-04-01 14:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 14:43 [PATCH v4 0/3] Respect VASIZE for address limits Ankit Soni
2026-04-01 14:43 ` Ankit Soni [this message]
2026-04-06 13:28   ` [PATCH v4 1/3] iommu_pt: support small VA for AMDv1 Jason Gunthorpe
2026-04-07 14:54     ` Ankit Soni
2026-04-01 14:43 ` [PATCH v4 2/3] iommu_pt: add kunit config for 32-bit VA (amdv1_cfg_1) Ankit Soni
2026-04-06 13:28   ` Jason Gunthorpe
2026-04-01 14:43 ` [PATCH v4 3/3] iommu/amd: Adhere to IVINFO[VASIZE] for address limits Ankit Soni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62cb55fdc5e08dceeb6d740cb73f75c6bce36226.1775045213.git.Ankit.Soni@amd.com \
    --to=ankit.soni@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®