From d9f759704b546a46649f8c51d5e9b63e96afdbae Mon Sep 17 00:00:00 2001 From: Ankit Soni Date: Mon, 13 Apr 2026 14:45:20 +0000 Subject: [PATCH] iommu_pt: add kunit config for 32-bit VA (amdv1_cfg_1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test coverage for small VAs (32‑bit) starting at level 2 by enabling the AMDv1 KUnit configuration. This limits level expansion because the starting level can accommodate only the maximum virtual address requested. Reviewed-by: Jason Gunthorpe Signed-off-by: Ankit Soni Reviewed-by: Vasant Hegde Signed-off-by: Joerg Roedel --- drivers/iommu/generic_pt/fmt/amdv1.h | 1 + drivers/iommu/generic_pt/kunit_iommu_pt.h | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/generic_pt/fmt/amdv1.h b/drivers/iommu/generic_pt/fmt/amdv1.h index 8d11b08291d7..1426a6758ff2 100644 --- a/drivers/iommu/generic_pt/fmt/amdv1.h +++ b/drivers/iommu/generic_pt/fmt/amdv1.h @@ -404,6 +404,7 @@ amdv1pt_iommu_fmt_hw_info(struct pt_iommu_amdv1 *table, static const struct pt_iommu_amdv1_cfg amdv1_kunit_fmt_cfgs[] = { /* Matches what io_pgtable does */ [0] = { .starting_level = 2 }, + [1] = { .starting_level = 2, .common.hw_max_vasz_lg2 = 32 }, }; #define kunit_fmt_cfgs amdv1_kunit_fmt_cfgs enum { KUNIT_FMT_FEATURES = 0 }; diff --git a/drivers/iommu/generic_pt/kunit_iommu_pt.h b/drivers/iommu/generic_pt/kunit_iommu_pt.h index e8a63c8ea850..ece1c9b8c55d 100644 --- a/drivers/iommu/generic_pt/kunit_iommu_pt.h +++ b/drivers/iommu/generic_pt/kunit_iommu_pt.h @@ -112,8 +112,9 @@ static void test_increase_level(struct kunit *test) if (IS_32BIT) kunit_skip(test, "Unable to test on 32bit"); - KUNIT_ASSERT_GT(test, common->max_vasz_lg2, - pt_top_range(common).max_vasz_lg2); + if (common->max_vasz_lg2 <= pt_top_range(common).max_vasz_lg2) + kunit_skip(test, + "max_vasz_lg2 fits in starting level, no growth possible"); /* Add every possible level to the max */ while (common->max_vasz_lg2 != pt_top_range(common).max_vasz_lg2) {