Skip to content

Commit

Permalink
iommufd/selftest: Test u64 unaligned bitmaps
Browse files Browse the repository at this point in the history
Exercise the dirty tracking bitmaps with byte unaligned addresses in
addition to the PAGE_SIZE unaligned bitmaps, using a address towards the
end of the page boundary.

In doing so, increase the tailroom we allocate for the bitmap from
MOCK_PAGE_SIZE(2K) into PAGE_SIZE(4K), such that we can test end of bitmap
boundary.

Link: https://lore.kernel.org/r/20240202133415.23819-4-joao.m.martins@oracle.com
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
  • Loading branch information
Joao Martins authored and Jason Gunthorpe committed Feb 6, 2024
1 parent d18411e commit 42af951
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tools/testing/selftests/iommu/iommufd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1741,9 +1741,9 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
self->bitmap_size =
variant->buffer_size / self->page_size / BITS_PER_BYTE;

/* Provision with an extra (MOCK_PAGE_SIZE) for the unaligned case */
/* Provision with an extra (PAGE_SIZE) for the unaligned case */
rc = posix_memalign(&self->bitmap, PAGE_SIZE,
self->bitmap_size + MOCK_PAGE_SIZE);
self->bitmap_size + PAGE_SIZE);
assert(!rc);
assert(self->bitmap);
assert((uintptr_t)self->bitmap % PAGE_SIZE == 0);
Expand Down Expand Up @@ -1873,6 +1873,13 @@ TEST_F(iommufd_dirty_tracking, get_dirty_bitmap)
self->bitmap + MOCK_PAGE_SIZE,
self->bitmap_size, 0, _metadata);

/* u64 unaligned bitmap */
test_mock_dirty_bitmaps(hwpt_id, variant->buffer_size,
MOCK_APERTURE_START, self->page_size,
self->bitmap + 0xff1,
self->bitmap_size, 0, _metadata);


test_ioctl_destroy(stddev_id);
test_ioctl_destroy(hwpt_id);
}
Expand Down Expand Up @@ -1907,6 +1914,14 @@ TEST_F(iommufd_dirty_tracking, get_dirty_bitmap_no_clear)
IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR,
_metadata);

/* u64 unaligned bitmap */
test_mock_dirty_bitmaps(hwpt_id, variant->buffer_size,
MOCK_APERTURE_START, self->page_size,
self->bitmap + 0xff1,
self->bitmap_size,
IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR,
_metadata);

test_ioctl_destroy(stddev_id);
test_ioctl_destroy(hwpt_id);
}
Expand Down

0 comments on commit 42af951

Please sign in to comment.