> From: Jason Gunthorpe <[email protected]>
> Sent: Wednesday, October 8, 2025 12:12 AM
> 
> This intends to have high coverage of the page table format functions and
> the IOMMU implementation itself, exercising the various corner cases.
> 
> The kunit tests can be run in the kunit framework, using commands like:
> 
> tools/testing/kunit/kunit.py run --build_dir build_kunit_arm64 --arch arm64 -
> -make_options LLVM=-19 --
> kunitconfig ./drivers/iommu/generic_pt/.kunitconfig
> tools/testing/kunit/kunit.py run --build_dir build_kunit_uml --
> kunitconfig ./drivers/iommu/generic_pt/.kunitconfig --kconfig_add
> CONFIG_WERROR=n --kconfig_add
> CONFIG_UML_PCI_OVER_VIRTIO_DEVICE_ID=100
> tools/testing/kunit/kunit.py run --build_dir build_kunit_x86_64 --arch x86_64
> --kunitconfig ./drivers/iommu/generic_pt/.kunitconfig
> tools/testing/kunit/kunit.py run --build_dir build_kunit_i386 --arch i386 --
> kunitconfig ./drivers/iommu/generic_pt/.kunitconfig
> tools/testing/kunit/kunit.py run --build_dir build_kunit_i386pae --arch i386 
> --
> kunitconfig ./drivers/iommu/generic_pt/.kunitconfig --kconfig_add
> CONFIG_X86_PAE=y
> 
> There are several interesting corner cases on the 32 bit platforms that
> need checking.
> 
> Like the generic tests, these are run on the format's configuration list
> using kunit "params". This also checks the core iommu parts of the page
> table code as it enters the logic through a mock iommu_domain.
> 
> The following are checked:
>  - PT_FEAT_DYNAMIC_TOP properly adds levels one by one
>  - Every page size can be iommu_map()'d, and mapping creates that size
>  - iommu_iova_to_phys() works with every page size
>  - Test converting OA -> non present -> OA when the two OAs overlap and
>    free table levels
>  - Test that unmap stops at holes, unmap doesn't split, and unmap returns
>    the right values for partial unmap requests
>  - Randomly map/unmap. Checks map with random sizes, that map fails
> when
>    hitting collisions doing nothing, unmap/map with random intersections and
>    full unmap of random sizes. Also checks iommu_iova_to_phys() with
> random
>    sizes
>  - Check for memory leaks by monitoring NR_SECONDARY_PAGETABLE
> 
> Tested-by: Alejandro Jimenez <[email protected]>
> Signed-off-by: Jason Gunthorpe <[email protected]>

Reviewed-by: Kevin Tian <[email protected]>

Reply via email to