Skip to content

Commit d64c805

Browse files
misalehwilldeacon
authored andcommitted
iommu/io-pgtable-arm: Add self test for the last page in the IAS
Add a case in the selftests that can detect some bugs with concatenated page tables, where it maps the biggest supported page size at the end of the IAS, this test would fail without the previous fix. Signed-off-by: Mostafa Saleh <smostafa@google.com> Link: https://lore.kernel.org/r/20241024162516.2005652-3-smostafa@google.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent d71fa84 commit d64c805

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,23 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
13941394
iova += SZ_1G;
13951395
}
13961396

1397+
/*
1398+
* Map/unmap the last largest supported page of the IAS, this can
1399+
* trigger corner cases in the concatednated page tables.
1400+
*/
1401+
mapped = 0;
1402+
size = 1UL << __fls(cfg->pgsize_bitmap);
1403+
iova = (1UL << cfg->ias) - size;
1404+
if (ops->map_pages(ops, iova, iova, size, 1,
1405+
IOMMU_READ | IOMMU_WRITE |
1406+
IOMMU_NOEXEC | IOMMU_CACHE,
1407+
GFP_KERNEL, &mapped))
1408+
return __FAIL(ops, i);
1409+
if (mapped != size)
1410+
return __FAIL(ops, i);
1411+
if (ops->unmap_pages(ops, iova, size, 1, NULL) != size)
1412+
return __FAIL(ops, i);
1413+
13971414
free_io_pgtable_ops(ops);
13981415
}
13991416

0 commit comments

Comments
 (0)