[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250917191143.3847487-1-smostafa@google.com>
Date: Wed, 17 Sep 2025 19:11:37 +0000
From: Mostafa Saleh <smostafa@...gle.com>
To: iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: robin.murphy@....com, will@...nel.org, joro@...tes.org, jgg@...pe.ca,
praan@...gle.com, Mostafa Saleh <smostafa@...gle.com>
Subject: [PATCH v2 0/3] Move io-pgtable-arm selftest to KUnit
This is a small series to clean up the io-pgtable-arm library.
The first patch was originally part of the SMMUv3 KVM driver support[1],
which needed to factor out the kernel code from the io-pgtable-arm
library, and based on Jason’s suggestion this can be taken out as a
cleanup, and a step further to convert it to kunit.
The first patch just moves the code to a new file with no other changes,
so it can be easier to review with “--color-moved”
The second patch converts the sefltest to be modular, that is useful as
kunit can be a module and it can run anytime after boot.
The third patch registers the test using kunit, and converges some of
the APIs, some notes about that:
Granularity of tests:
---------------------
To make the series easier to review, the series changes the test to run in
kunit without making intrusive changes to the test itself.
It’s possible to refactor the tests to have smaller granularity (although
I think that would make it less efficient as we might create the same io-pgtable
config multiple times) and integrate them in kunit as multiple tests, that
change would be more intrusive, if you think that is the right approach,
I can add a couple of more patches re-writing the tests.
Other changes:
--------------
- Also, to make the test changes minimal, and the fail messages similar,
“KUNIT_FAIL()” is used to fail all tests instead of using KUNIT specific
assertions.
- Instead of using faux device, we rely on kunit_device_register()
- The WARN is removed when a test fails, as that doesn’t seem to be a pattern
used with kunit.
Testing:
--------
- With CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST=y
It will automatically run at boot as before this patch series.
- Otherwise with CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST=m:
1) on module load:
Once the module load the self test will run
# modprobe io-pgtable-arm-selftests
2) debugfs
With CONFIG_KUNIT_DEBUGFS=y You can run the test with
# echo 1 > /sys/kernel/debug/kunit/io-pgtable-arm-test/run
3) Using kunit.py
You can also use the helper script which uses Qemu in the background
# ./tools/testing/kunit/kunit.py run --build_dir build_kunit_arm64 --arch arm64 \
--make_options LLVM=1 --kunitconfig ./kunit/kunitconfig
[18:01:09] ============= io-pgtable-arm-test (1 subtest) ==============
[18:01:09] [PASSED] arm_lpae_do_selftests
[18:01:09] =============== [PASSED] io-pgtable-arm-test ===============
[18:01:09] ============================================================
A failure at the test with the new implementation look as
[ 66.624469] # arm_lpae_do_selftests: EXPECTATION FAILED at drivers/iommu/io-pgtable-arm-selftests.c:154
[ 66.624505] # arm_lpae_do_selftests: selftest: test failed for fmt idx 0
[ 66.624524] # arm_lpae_do_selftests: cfg: pgsize_bitmap 0x20010000, ias 48-bit
[ 66.624669] # arm_lpae_do_selftests: data: 3 levels, 0x200 pgd_size, 16 pg_shift, 13 bits_per_level, pgd @ 00000000f200237d
Main changes in v2:
-------------------
- Make the test modular
v1: https://lore.kernel.org/linux-iommu/20250917140216.2199055-1-smostafa@google.com/
[1] https://lore.kernel.org/all/20250819215156.2494305-5-smostafa@google.com/
Mostafa Saleh (3):
iommu/io-pgtable-arm: Move selftests to a separate file
iommu/io-pgtable-arm-selftests: Modularize the test
iommu/io-pgtable-arm-selftests: Use KUnit
drivers/iommu/Kconfig | 4 +-
drivers/iommu/Makefile | 1 +
drivers/iommu/io-pgtable-arm-selftests.c | 226 +++++++++++++++++++++
drivers/iommu/io-pgtable-arm.c | 243 -----------------------
drivers/iommu/io-pgtable-arm.h | 41 ++++
5 files changed, 270 insertions(+), 245 deletions(-)
create mode 100644 drivers/iommu/io-pgtable-arm-selftests.c
--
2.51.0.384.g4c02a37b29-goog
Powered by blists - more mailing lists