@@ -84,8 +84,10 @@ static int check_usermem_access_fault_helper(int mem_type, int mode, int mapping
return err;
}
-static int check_usermem_access_fault(int mem_type, int mode, int mapping) {
- return check_usermem_access_fault_helper(mem_type, mode, mapping, page_sz, 0);
+static int check_usermem_access_fault(int mem_type, int mode, int mapping,
+ int tag_offset) {
+ return check_usermem_access_fault_helper(mem_type, mode, mapping,
+ tag_offset, 0);
}
int main(int argc, char *argv[])
@@ -105,17 +107,27 @@ int main(int argc, char *argv[])
mte_register_signal(SIGSEGV, mte_default_handler);
/* Set test plan */
- ksft_set_plan(4);
-
- evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE),
- "Check memory access from kernel in sync mode, private mapping and mmap memory\n");
- evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED),
- "Check memory access from kernel in sync mode, shared mapping and mmap memory\n");
-
- evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE),
- "Check memory access from kernel in async mode, private mapping and mmap memory\n");
- evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED),
- "Check memory access from kernel in async mode, shared mapping and mmap memory\n");
+ ksft_set_plan(8);
+
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz),
+ "Check memory access from kernel in sync mode, private mapping and mmap memory (tag_offset: page_sz)\n");
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz),
+ "Check memory access from kernel in sync mode, shared mapping and mmap memory (tag_offset: page_sz)\n");
+
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz),
+ "Check memory access from kernel in async mode, private mapping and mmap memory (tag_offset: page_sz)\n");
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz),
+ "Check memory access from kernel in async mode, shared mapping and mmap memory (tag_offset: page_sz)\n");
+
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, MT_GRANULE_SIZE),
+ "Check memory access from kernel in sync mode, private mapping and mmap memory (tag_offset: MT_GRANULE_SIZE)\n");
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, MT_GRANULE_SIZE),
+ "Check memory access from kernel in sync mode, shared mapping and mmap memory (tag_offset: MT_GRANULE_SIZE)\n");
+
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, MT_GRANULE_SIZE),
+ "Check memory access from kernel in async mode, private mapping and mmap memory (tag_offset: MT_GRANULE_SIZE)\n");
+ evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, MT_GRANULE_SIZE),
+ "Check memory access from kernel in async mode, shared mapping and mmap memory (tag_offset: MT_GRANULE_SIZE)\n");
mte_restore_setup();
ksft_print_cnts();
Add some tests that place the different tag at MT_GRANULE_SIZE to check that less than a full page can also be read. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> --- .../selftests/arm64/mte/check_user_mem.c | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-)