Move io-pgtable-arm selftest to KUnit
Subsystems (2)
v2 cover 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/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
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
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
PATCH v2 1/3 iommu/io-pgtable-arm: Move selftests to a separate file
Clean up the io-pgtable-arm library by moving the selftests out. Next the tests will be registered with kunit.
This is useful also to factor out kernel specific code out, so it can compiled as part of the hypervisor object.
--- drivers/iommu/Makefile | 1 + drivers/iommu/io-pgtable-arm-selftests.c | 211 ++++++++++++++++++++ drivers/iommu/io-pgtable-arm.c | 243 ----------------------- drivers/iommu/io-pgtable-arm.h | 41 ++++ 4 files changed, 253 insertions(+), 243 deletions(-) create mode 100644 drivers/iommu/io-pgtable-arm-selftests.c
drivers/iommu/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o obj-$(CONFIG_IOMMU_IO_PGTABLE_ARMV7S) += io-pgtable-arm-v7s.o obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE) += io-pgtable-arm.o +obj-$(CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST) += io-pgtable-arm-selftests.o obj-$(CONFIG_IOMMU_IO_PGTABLE_DART) += io-pgtable-dart.o obj-$(CONFIG_IOMMU_IOVA) += iova.o obj-$(CONFIG_OF_IOMMU) += of_iommu.o
drivers/iommu/io-pgtable-arm-selftests.c new file +211 -0
211 lines not on this page · raw message
drivers/iommu/io-pgtable-arm.c +0 -243
265 lines not on this page · raw message
drivers/iommu/io-pgtable-arm.h +41 -0
51 lines not on this page · raw message
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH v2 1/3] iommu/io-pgtable-arm: Move selftests to a separate file
drivers/iommu/io-pgtable-arm-selftests.c line 45
Quoted 4 lines · Mostafa Saleh
drivers/iommu/io-pgtable-arm-selftests.c new file +4
-0+static void __init arm_lpae_dump_ops (struct io_pgtable_ops *ops) +{ +struct arm_lpae_io_pgtable *data =io_pgtable_ops_to_data (ops); +struct io_pgtable_cfg *cfg = &data->iop.cfg;
Can be:
struct io_pgtable_cfg *cfg =
&io_pgtable_ops_to_pgtable(pgtbl_ops)->cfg;
drivers/iommu/io-pgtable-arm-selftests.c line 51
Quoted 6 lines
drivers/iommu/io-pgtable-arm-selftests.c new file +6
-0+ +pr_err ("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n" , + cfg->pgsize_bitmap, cfg->ias); +pr_err ("data: %d levels, 0x%zx pgd_size, %u pg_shift, %u bits_per_level, pgd @ %p\n" , +ARM_LPAE_MAX_LEVELS - data->start_level,ARM_LPAE_PGD_SIZE (data), +ilog2 (ARM_LPAE_GRANULE (data)), data->bits_per_level, data->pgd);
The entire struct arm_lpae_io_pgtable is exposed to a public header just for this one print.. Seems undesirable.
Drop the print? Honestly, I prefer this, given the maturity let's not compromise modularity to print someting nobody will ever read..
Alternatively call a kunit-only exported function to do the print directly from ops so. smmuv3 has an example how to do that
Either way a precursor patch to adjust it will allow this patch to avoid publishing most stuff.
drivers/iommu/io-pgtable-arm.h line 59
Quoted 7 lines
drivers/iommu/io-pgtable-arm.h +7
-0+/* +* Calculate the right shift amount to get to the portion describing level l +* in a virtual address mapped by the pagetable in d. +*/ +#define ARM_LPAE_LVL_SHIFT (l,d) \ + (((ARM_LPAE_MAX_LEVELS - (l)) * (d)->bits_per_level) + \ + ilog2(sizeof(arm_lpae_iopte)))
Didn't see this being used?
drivers/iommu/io-pgtable-arm.h line 62
Quoted 2 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_GRANULE (d) \ + (sizeof(arm_lpae_iopte) << (d)->bits_per_level)
Only used by the above print
drivers/iommu/io-pgtable-arm.h line 64
Quoted 2 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_PGD_SIZE (d) \ + (sizeof(arm_lpae_iopte) << (d)->pgd_bits)
Only used by the above print
drivers/iommu/io-pgtable-arm.h line 67
Quoted 2 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_PTES_PER_TABLE (d) \ + (ARM_LPAE_GRANULE(d) >> ilog2(sizeof(arm_lpae_iopte)))
Didn't see this being used?
Quoted 1 line
+typedef u64
arm_lpae_iopte;
Only used by the defines and the above print.
Jason
Re: [PATCH v2 1/3] iommu/io-pgtable-arm: Move selftests to a separate file
Quoted 10 lines · Jason Gunthorpe
drivers/iommu/io-pgtable-arm-selftests.c line 45
Quoted 4 lines · Mostafa Saleh
drivers/iommu/io-pgtable-arm-selftests.c new file +4
-0+static void __init arm_lpae_dump_ops (struct io_pgtable_ops *ops) +{ +struct arm_lpae_io_pgtable *data =io_pgtable_ops_to_data (ops); +struct io_pgtable_cfg *cfg = &data->iop.cfg;Can be:
struct
io_pgtable_cfg*cfg =
&io_pgtable_ops_to_pgtable(pgtbl_ops)->cfg;
There are a bunch of other formatting issues here also, but I wanted to move the code as is, so with “--color-moved” you can see the exact difference, otherwise, it’s harder to review.
I can add a patch before to fix those + the printing as you suggested next.
Quoted 11 lines
drivers/iommu/io-pgtable-arm-selftests.c line 51
Quoted 7 lines
drivers/iommu/io-pgtable-arm-selftests.c new file +6
-0+ +pr_err ("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n" , + cfg->pgsize_bitmap, cfg->ias); +pr_err ("data: %d levels, 0x%zx pgd_size, %u pg_shift, %u bits_per_level, pgd @ %p\n" , +ARM_LPAE_MAX_LEVELS - data->start_level,ARM_LPAE_PGD_SIZE (data), +ilog2 (ARM_LPAE_GRANULE (data)), data->bits_per_level, data->pgd);The entire struct
arm_lpae_io_pgtableis exposed to a public header just for this one print.. Seems undesirable.
Quoted 8 lines
Drop the print? Honestly, I prefer this, given the maturity let's not compromise modularity to print someting nobody will ever read..
Alternatively call a kunit-only exported function to do the print directly from ops so. smmuv3 has an example how to do that
Either way a precursor patch to adjust it will allow this patch to avoid publishing most stuff.
I don’t have a strong opinion about this, but I am more inclined to keep the prints considering it’s a low-level test for the page table, and such parameters would be useful to understand the failures.
Moving arm_lpae_dump_ops() to the core library will leak the kunit struct, but we can drop the kunit_err and rely on pr_err().
I know this is not relevant to this series, but the KVM driver will need to expose arm_lpae_io_pgtable anyway.
Quoted 10 lines
drivers/iommu/io-pgtable-arm.h line 59
Quoted 8 lines
drivers/iommu/io-pgtable-arm.h +7
-0+/* +* Calculate the right shift amount to get to the portion describing level l +* in a virtual address mapped by the pagetable in d. +*/ +#define ARM_LPAE_LVL_SHIFT (l,d) \ + (((ARM_LPAE_MAX_LEVELS - (l)) * (d)->bits_per_level) + \ + ilog2(sizeof(arm_lpae_iopte)))Didn't see this being used?
Yes, my bad, I will move it and the other one back.
Thanks,
Mostafa
Quoted 21 lines
drivers/iommu/io-pgtable-arm.h line 62
Quoted 3 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_GRANULE (d) \ + (sizeof(arm_lpae_iopte) << (d)->bits_per_level)Only used by the above print
drivers/iommu/io-pgtable-arm.h line 64
Quoted 2 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_PGD_SIZE (d) \ + (sizeof(arm_lpae_iopte) << (d)->pgd_bits)Only used by the above print
drivers/iommu/io-pgtable-arm.h line 67
Quoted 2 lines
drivers/iommu/io-pgtable-arm.h +2
-0+#define ARM_LPAE_PTES_PER_TABLE (d) \ + (ARM_LPAE_GRANULE(d) >> ilog2(sizeof(arm_lpae_iopte)))Didn't see this being used?
Quoted 1 line
+typedef u64
arm_lpae_iopte;Only used by the defines and the above print.
Jason
Re: [PATCH v2 1/3] iommu/io-pgtable-arm: Move selftests to a separate file
Quoted 12 lines · Mostafa Saleh
Quoted 10 lines · Jason Gunthorpe
drivers/iommu/io-pgtable-arm-selftests.c line 45
Quoted 4 lines · Mostafa Saleh
drivers/iommu/io-pgtable-arm-selftests.c new file +4
-0+static void __init arm_lpae_dump_ops (struct io_pgtable_ops *ops) +{ +struct arm_lpae_io_pgtable *data =io_pgtable_ops_to_data (ops); +struct io_pgtable_cfg *cfg = &data->iop.cfg;Can be:
struct
io_pgtable_cfg*cfg =
&io_pgtable_ops_to_pgtable(pgtbl_ops)->cfg;
Quoted 6 lines
There are a bunch of other formatting issues here also, but I wanted to move the code as is, so with “--color-moved” you can see the exact difference, otherwise, it’s harder to review.
I can add a patch before to fix those + the printing as you suggested next.
Yeah, I brought it up because with the above you don't need arm_lpae_io_pgtable
Quoted 3 lines
I don’t have a strong opinion about this, but I am more inclined to keep the prints considering it’s a low-level test for the page table, and such parameters would be useful to understand the failures.
My general view has been that there is alot of debug prints I've added to kunits to debug them but once they are debugged I tend to drop them off as they may not be useful to debug the next issue.
Quoted 2 lines
I know this is not relevant to this series, but the KVM driver will need to expose
arm_lpae_io_pgtableanyway.
Really? That sounds like wrong layering, why does it need to break the iopgtable abstraction? :(
Jason
Re: [PATCH v2 1/3] iommu/io-pgtable-arm: Move selftests to a separate file
Quoted 31 lines · Jason Gunthorpe
Quoted 12 lines · Mostafa Saleh
Quoted 10 lines · Jason Gunthorpe
drivers/iommu/io-pgtable-arm-selftests.c line 45
Quoted 4 lines · Mostafa Saleh
drivers/iommu/io-pgtable-arm-selftests.c new file +4
-0+static void __init arm_lpae_dump_ops (struct io_pgtable_ops *ops) +{ +struct arm_lpae_io_pgtable *data =io_pgtable_ops_to_data (ops); +struct io_pgtable_cfg *cfg = &data->iop.cfg;Can be:
struct
io_pgtable_cfg*cfg =
&io_pgtable_ops_to_pgtable(pgtbl_ops)->cfg;Quoted 6 lines
There are a bunch of other formatting issues here also, but I wanted to move the code as is, so with “--color-moved” you can see the exact difference, otherwise, it’s harder to review.
I can add a patch before to fix those + the printing as you suggested next.
Yeah, I brought it up because with the above you don't need
arm_lpae_io_pgtableQuoted 3 lines
I don’t have a strong opinion about this, but I am more inclined to keep the prints considering it’s a low-level test for the page table, and such parameters would be useful to understand the failures.
My general view has been that there is alot of debug prints I've added to kunits to debug them but once they are debugged I tend to drop them off as they may not be useful to debug the next issue.
Quoted 5 lines
Quoted 2 lines
I know this is not relevant to this series, but the KVM driver will need to expose
arm_lpae_io_pgtableanyway.Really? That sounds like wrong layering, why does it need to break the iopgtable abstraction? :(
Oh, not any more actually, in my lastest version it's just exported for the selftest, sorry for the confusion.
I will respin v3 with with this patch leaving the arm_lpae_dump_ops behind, it's a bit ugly with the guards + the exports, if Robin and Will are OK with removing it we can just drop it.
Thanks,
Mostafa
Quoted 2 lines
Jason
PATCH v2 2/3 iommu/io-pgtable-arm-selftests: Modularize the test
In reply to Mostafa SalehRemove the __init constraint, as the test will be converted to KUnit, it can run on-demand after later.
Also, as KUnit can be a module, make this test modular.
--- drivers/iommu/Kconfig | 2 +- drivers/iommu/io-pgtable-arm-selftests.c | 36 +++++++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-)
drivers/iommu/Kconfig +1 -1
@@ -41,7 +41,7 @@ config IOMMU_IO_PGTABLE_LPAE up to 48-bits in size. config IOMMU_IO_PGTABLE_LPAE_SELFTEST - bool "LPAE selftests" + tristate "LPAE selftests" depends on IOMMU_IO_PGTABLE_LPAE help Enable self-tests for LPAE page table allocator. This performs
drivers/iommu/io-pgtable-arm-selftests.c +22 -14
@@ -12,34 +12,34 @@#include "io-pgtable-arm.h" -static struct io_pgtable_cfg *cfg_cookie__initdata ; +static struct io_pgtable_cfg *cfg_cookie; -static void __init dummy_tlb_flush_all (void *cookie) +static void dummy_tlb_flush_all (void *cookie) {WARN_ON (cookie != cfg_cookie); } -static void __init dummy_tlb_flush (unsigned long iova,size_t size, -size_t granule,void *cookie) +static void dummy_tlb_flush (unsigned long iova,size_t size, +size_t granule,void *cookie) {WARN_ON (cookie != cfg_cookie);WARN_ON (!(size & cfg_cookie->pgsize_bitmap)); } -static void __init dummy_tlb_add_page (struct iommu_iotlb_gather *gather, -unsigned long iova,size_t granule, -void *cookie) +static void dummy_tlb_add_page (struct iommu_iotlb_gather *gather, +unsigned long iova,size_t granule, +void *cookie) {dummy_tlb_flush (iova, granule, granule, cookie); } -static const struct iommu_flush_ops dummy_tlb_ops__initconst = { +static const struct iommu_flush_ops dummy_tlb_ops = { .tlb_flush_all = dummy_tlb_flush_all, .tlb_flush_walk = dummy_tlb_flush, .tlb_add_page = dummy_tlb_add_page, }; -static void __init arm_lpae_dump_ops (struct io_pgtable_ops *ops) +static void arm_lpae_dump_ops (struct io_pgtable_ops *ops) {struct arm_lpae_io_pgtable *data =io_pgtable_ops_to_data (ops);struct io_pgtable_cfg *cfg = &data->iop.cfg;
@@ -57,9 +57,9 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops) -EFAULT ; \ }) -static int __init arm_lpae_run_tests (struct io_pgtable_cfg *cfg) +static int arm_lpae_run_tests (struct io_pgtable_cfg *cfg) { -static const enum io_pgtable_fmt fmts[]__initconst = { +static const enum io_pgtable_fmt fmts[] = {ARM_64_LPAE_S1 ,ARM_64_LPAE_S2 , };
@@ -160,15 +160,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)return 0 ; } -static int __init arm_lpae_do_selftests (void ) +static int arm_lpae_do_selftests (void ) { -static const unsigned long pgsize[]__initconst = { +static const unsigned long pgsize[] = {SZ_4K |SZ_2M |SZ_1G ,SZ_16K |SZ_32M ,SZ_64K |SZ_512M , }; -static const unsigned int address_size[]__initconst = { +static const unsigned int address_size[] = {32 ,36 ,40 ,42 ,44 ,48 , };
@@ -208,4 +208,12 @@ static int __init arm_lpae_do_selftests(void)return fail ? -EFAULT :0 ; } + +static void arm_lpae_exit_selftests (void ) +{ +} +subsys_initcall (arm_lpae_do_selftests); +module_exit (arm_lpae_exit_selftests); +MODULE_DESCRIPTION ("io-pgtable-arm library selftest" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH v2 2/3] iommu/io-pgtable-arm-selftests: Modularize the test
Quoted 10 lines · Mostafa Saleh
Remove the
__initconstraint, as the test will be converted to KUnit, it can run on-demand after later.Also, as KUnit can be a module, make this test modular.
Signed-off-by Mostafa Saleh <[email protected]>--- drivers/iommu/Kconfig | 2 +- drivers/iommu/io-pgtable-arm-selftests.c | 36 +++++++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-)
Jason
PATCH v2 3/3 iommu/io-pgtable-arm-selftests: Use KUnit
In reply to Mostafa SalehIntegrate the selftests as part of kunit, this makes the test available through debugfs.
--- drivers/iommu/Kconfig | 2 +- drivers/iommu/io-pgtable-arm-selftests.c | 93 +++++++++++++----------- 2 files changed, 51 insertions(+), 44 deletions(-)
drivers/iommu/Kconfig +1 -1
@@ -42,7 +42,7 @@ config IOMMU_IO_PGTABLE_LPAE config IOMMU_IO_PGTABLE_LPAE_SELFTEST tristate "LPAE selftests" - depends on IOMMU_IO_PGTABLE_LPAE + depends on IOMMU_IO_PGTABLE_LPAE && KUNIT help Enable self-tests for LPAE page table allocator. This performs a series of page-table consistency checks during boot.
drivers/iommu/io-pgtable-arm-selftests.c +50 -43
197 lines not on this page · raw message
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH v2 3/3] iommu/io-pgtable-arm-selftests: Use KUnit
Quoted 15 lines · Mostafa Saleh
Integrate the selftests as part of kunit, this makes the test available through debugfs.
Suggested-by Jason Gunthorpe <[email protected]>Signed-off-by Mostafa Saleh <[email protected]>--- drivers/iommu/Kconfig | 2 +- drivers/iommu/io-pgtable-arm-selftests.c | 93 +++++++++++++----------- 2 files changed, 51 insertions(+), 44 deletions(-)drivers/iommu/Kconfig +0
-0
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 43
Quoted 2 lines
drivers/iommu/Kconfig +0
-0@@ -42,7 +42,7 @@ config IOMMU_IO_PGTABLE_LPAE config IOMMU_IO_PGTABLE_LPAE_SELFTEST
This should probably be renamed to xxx_KUNIT_TEST
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 45
Quoted 3 lines
drivers/iommu/Kconfig +1
-1tristate "LPAE selftests" - depends on IOMMU_IO_PGTABLE_LPAE + depends on IOMMU_IO_PGTABLE_LPAE && KUNIT
I wonder if it should be:
select IOMMU_IO_PGTABLE_LPAE
depends on KUNIT
default KUNIT_ALL_TESTS
?
At least the default should be there
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 48
Quoted 3 lines
drivers/iommu/Kconfig +0
-0help Enable self-tests for LPAE page table allocator. This performs a series of page-table consistency checks during boot.
"kunit tests" here as well
Quoted 1 line
-subsys_initcall(arm_lpae_do_selftests);
Oh so it does drop the initcall, the coverletter is a bit confusing then.
Jason
Re: [PATCH v2 3/3] iommu/io-pgtable-arm-selftests: Use KUnit
Quoted 17 lines · Jason Gunthorpe
Quoted 16 lines · Mostafa Saleh
Integrate the selftests as part of kunit, this makes the test available through debugfs.
Suggested-by Jason Gunthorpe <[email protected]>Signed-off-by Mostafa Saleh <[email protected]>--- drivers/iommu/Kconfig | 2 +- drivers/iommu/io-pgtable-arm-selftests.c | 93 +++++++++++++----------- 2 files changed, 51 insertions(+), 44 deletions(-)drivers/iommu/Kconfig +0
-0@@ -42,7 +42,7 @@ config IOMMU_IO_PGTABLE_LPAE
Quoted 3 lines
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 43
Quoted 1 line
drivers/iommu/Kconfig +0
-0config IOMMU_IO_PGTABLE_LPAE_SELFTESTThis should probably be renamed to
xxx_KUNIT_TEST
Will do.
Quoted 7 lines
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 45
Quoted 4 lines
drivers/iommu/Kconfig +1
-1tristate "LPAE selftests" - depends on IOMMU_IO_PGTABLE_LPAE + depends on IOMMU_IO_PGTABLE_LPAE && KUNITI wonder if it should be:
Quoted 7 lines
select
IOMMU_IO_PGTABLE_LPAE
depends on KUNIT
defaultKUNIT_ALL_TESTS?
At least the default should be there
Makes sense, will do.
Quoted 6 lines
drivers/iommu/Kconfig config IOMMU_IO_PGTABLE_LPAE · line 48
Quoted 4 lines
drivers/iommu/Kconfig +0
-0help Enable self-tests for LPAE page table allocator. This performs a series of page-table consistency checks during boot."kunit tests" here as well
Will do.
Quoted 4 lines
Quoted 2 lines
-subsys_initcall(arm_lpae_do_selftests);
Oh so it does drop the initcall, the coverletter is a bit confusing then.
Yes, I will reword the cover letter.
Thanks,
Mostafa
Quoted 4 lines
Reviewed-by Jason Gunthorpe <[email protected]>Jason
Quoted 3 lines · Mostafa Saleh
--------
- WithCONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST=y
It will automatically run at boot as before this patch series.
I would drop this kconfig, kunit does everything required including run at boot if you want.
Quoted 10 lines
- 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-selftests2) debugfs
WithCONFIG_KUNIT_DEBUGFS=yYou can run the test with # echo 1 >/sys/kernel/debug/kunit/io-pgtable-arm-test/run3) Using
kunit.py
Quoted 8 lines
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] ============================================================Suggest to include the above instruction in the commit message adding the kunit so at least it is in the history
Jason