diff mbox series

[v1,2/7] kselftest/arm64: mte: user_mem: add tests using tag_offset

Message ID 20220125150920.23955-3-joey.gouly@arm.com (mailing list archive)
State New, archived
Headers show
Series add more tests to MTE kselftests | expand

Commit Message

Joey Gouly Jan. 25, 2022, 3:09 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c
index 3ad9d85ca9b7..d33b262ccdb0 100644
--- a/tools/testing/selftests/arm64/mte/check_user_mem.c
+++ b/tools/testing/selftests/arm64/mte/check_user_mem.c
@@ -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();