Skip to content

Commit 306219d

Browse files
committed
kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
While the kselftest was added at the same time with the kernel support for MTE on hugetlb mappings, the tests may be run on older kernels. Skip the tests if PROT_MTE is not supported on MAP_HUGETLB mappings. Fixes: 27879e8 ("selftests: arm64: add hugetlb mte tests") Cc: Yang Shi <yang@os.amperecomputing.com> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Reviewed-by: Dev Jain <dev.jain@arm.com> Reviewed-by: Yang Shi <yang@os.amperecomputing.com> Link: https://lore.kernel.org/r/20250221093331.2184245-3-catalin.marinas@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 7ae9510 commit 306219d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/testing/selftests/arm64/mte/check_hugetlb_options.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappin
227227
int main(int argc, char *argv[])
228228
{
229229
int err;
230+
void *map_ptr;
231+
unsigned long map_size;
230232

231233
err = mte_default_setup();
232234
if (err)
@@ -243,6 +245,15 @@ int main(int argc, char *argv[])
243245
return KSFT_FAIL;
244246
}
245247

248+
/* Check if MTE supports hugetlb mappings */
249+
map_size = default_huge_page_size();
250+
map_ptr = mmap(NULL, map_size, PROT_READ | PROT_MTE,
251+
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
252+
if (map_ptr == MAP_FAILED)
253+
ksft_exit_skip("PROT_MTE not supported with MAP_HUGETLB mappings\n");
254+
else
255+
munmap(map_ptr, map_size);
256+
246257
/* Set test plan */
247258
ksft_set_plan(12);
248259

0 commit comments

Comments
 (0)