iommufd/selftest: Fix dirty bitmap tests with u8 bitmaps
authorJoao Martins <joao.m.martins@oracle.com>
Thu, 27 Jun 2024 11:00:55 +0000 (12:00 +0100)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 28 Jun 2024 16:12:22 +0000 (13:12 -0300)
commitec61f820a2ff07d1717583bd57d6ee45d2763a6e
treeeebf6fcc5f0082f34843f33ea453a825b520cb92
parentf2661062f16b2de5d7b6a5c42a9a5c96326b8454
iommufd/selftest: Fix dirty bitmap tests with u8 bitmaps

With 64k base pages, the first 128k iova length test requires less than a
byte for a bitmap, exposing a bug in the tests that assume that bitmaps are
at least a byte.

Rather than dealing with bytes, have _test_mock_dirty_bitmaps() pass the
number of bits. The caller functions are adjusted to also use bits as well,
and converting to bytes when clearing, allocating and freeing the bitmap.

Link: https://lore.kernel.org/r/20240627110105.62325-2-joao.m.martins@oracle.com
Reported-by: Matt Ochs <mochs@nvidia.com>
Fixes: a9af47e382a4 ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP")
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Matt Ochs <mochs@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
tools/testing/selftests/iommu/iommufd.c
tools/testing/selftests/iommu/iommufd_utils.h