Skip to content

Commit 42af951

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd/selftest: Test u64 unaligned bitmaps
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/[email protected] Signed-off-by: Joao Martins <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent d18411e commit 42af951

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/testing/selftests/iommu/iommufd.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,9 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
17411741
self->bitmap_size =
17421742
variant->buffer_size / self->page_size / BITS_PER_BYTE;
17431743

1744-
/* Provision with an extra (MOCK_PAGE_SIZE) for the unaligned case */
1744+
/* Provision with an extra (PAGE_SIZE) for the unaligned case */
17451745
rc = posix_memalign(&self->bitmap, PAGE_SIZE,
1746-
self->bitmap_size + MOCK_PAGE_SIZE);
1746+
self->bitmap_size + PAGE_SIZE);
17471747
assert(!rc);
17481748
assert(self->bitmap);
17491749
assert((uintptr_t)self->bitmap % PAGE_SIZE == 0);
@@ -1873,6 +1873,13 @@ TEST_F(iommufd_dirty_tracking, get_dirty_bitmap)
18731873
self->bitmap + MOCK_PAGE_SIZE,
18741874
self->bitmap_size, 0, _metadata);
18751875

1876+
/* u64 unaligned bitmap */
1877+
test_mock_dirty_bitmaps(hwpt_id, variant->buffer_size,
1878+
MOCK_APERTURE_START, self->page_size,
1879+
self->bitmap + 0xff1,
1880+
self->bitmap_size, 0, _metadata);
1881+
1882+
18761883
test_ioctl_destroy(stddev_id);
18771884
test_ioctl_destroy(hwpt_id);
18781885
}
@@ -1907,6 +1914,14 @@ TEST_F(iommufd_dirty_tracking, get_dirty_bitmap_no_clear)
19071914
IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR,
19081915
_metadata);
19091916

1917+
/* u64 unaligned bitmap */
1918+
test_mock_dirty_bitmaps(hwpt_id, variant->buffer_size,
1919+
MOCK_APERTURE_START, self->page_size,
1920+
self->bitmap + 0xff1,
1921+
self->bitmap_size,
1922+
IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR,
1923+
_metadata);
1924+
19101925
test_ioctl_destroy(stddev_id);
19111926
test_ioctl_destroy(hwpt_id);
19121927
}

0 commit comments

Comments
 (0)