Skip to content

Commit 376ce8b

Browse files
misalehwilldeacon
authored andcommitted
iommu/io-pgtable-arm: Add coverage for different OAS in selftest
Run selftests with different OAS values intead of hardcoding it to 48 bits. We always keep OAS >= IAS to make the config valid for stage-2. This can be further improved, if we split IAS/OAS configuration for stage-1 and stage-2 (to use input sizes compatible with VA_BITS as SMMUv3 does, or IAS > OAS which is valid for stage-1). However, that adds more complexity, and the current change improves coverage and makes it possible to test all concatenation cases. Signed-off-by: Mostafa Saleh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 4dcac84 commit 376ce8b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,15 +1385,14 @@ static int __init arm_lpae_do_selftests(void)
13851385
SZ_64K | SZ_512M,
13861386
};
13871387

1388-
static const unsigned int ias[] __initconst = {
1388+
static const unsigned int address_size[] __initconst = {
13891389
32, 36, 40, 42, 44, 48,
13901390
};
13911391

1392-
int i, j, pass = 0, fail = 0;
1392+
int i, j, k, pass = 0, fail = 0;
13931393
struct device dev;
13941394
struct io_pgtable_cfg cfg = {
13951395
.tlb = &dummy_tlb_ops,
1396-
.oas = 48,
13971396
.coherent_walk = true,
13981397
.iommu_dev = &dev,
13991398
};
@@ -1402,15 +1401,19 @@ static int __init arm_lpae_do_selftests(void)
14021401
set_dev_node(&dev, NUMA_NO_NODE);
14031402

14041403
for (i = 0; i < ARRAY_SIZE(pgsize); ++i) {
1405-
for (j = 0; j < ARRAY_SIZE(ias); ++j) {
1406-
cfg.pgsize_bitmap = pgsize[i];
1407-
cfg.ias = ias[j];
1408-
pr_info("selftest: pgsize_bitmap 0x%08lx, IAS %u\n",
1409-
pgsize[i], ias[j]);
1410-
if (arm_lpae_run_tests(&cfg))
1411-
fail++;
1412-
else
1413-
pass++;
1404+
for (j = 0; j < ARRAY_SIZE(address_size); ++j) {
1405+
/* Don't use ias > oas as it is not valid for stage-2. */
1406+
for (k = 0; k <= j; ++k) {
1407+
cfg.pgsize_bitmap = pgsize[i];
1408+
cfg.ias = address_size[k];
1409+
cfg.oas = address_size[j];
1410+
pr_info("selftest: pgsize_bitmap 0x%08lx, IAS %u OAS %u\n",
1411+
pgsize[i], cfg.ias, cfg.oas);
1412+
if (arm_lpae_run_tests(&cfg))
1413+
fail++;
1414+
else
1415+
pass++;
1416+
}
14141417
}
14151418
}
14161419

0 commit comments

Comments
 (0)