Commit 391ca7c8 authored by Yeoreum Yun's avatar Yeoreum Yun Committed by Catalin Marinas
Browse files

kselftest/arm64/mte: Preparation for mte store only test



Since ARMv8.9, FEAT_MTE_STORE_ONLY can be used to restrict raise of tag
check fault on store operation only.

This patch is preparation for testing FEAT_MTE_STORE_ONLY
It shouldn't change test result.

Signed-off-by: default avatarYeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20250618092957.2069907-8-yeoreum.yun@arm.com


Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 964a0742
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ static int check_buffer_by_byte(int mem_type, int mode)
	int i, j, item;
	bool err;

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	item = ARRAY_SIZE(sizes);

	for (i = 0; i < item; i++) {
@@ -68,7 +68,7 @@ static int check_buffer_underflow_by_byte(int mem_type, int mode,
	bool err;
	char *und_ptr = NULL;

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	item = ARRAY_SIZE(sizes);
	for (i = 0; i < item; i++) {
		ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
@@ -164,7 +164,7 @@ static int check_buffer_overflow_by_byte(int mem_type, int mode,
	size_t tagged_size, overflow_size;
	char *over_ptr = NULL;

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	item = ARRAY_SIZE(sizes);
	for (i = 0; i < item; i++) {
		ptr = (char *)mte_allocate_memory_tag_range(sizes[i], mem_type, 0,
@@ -337,7 +337,7 @@ static int check_buffer_by_block(int mem_type, int mode)
{
	int i, item, result = KSFT_PASS;

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	item = ARRAY_SIZE(sizes);
	cur_mte_cxt.fault_valid = false;
	for (i = 0; i < item; i++) {
@@ -368,7 +368,7 @@ static int check_memory_initial_tags(int mem_type, int mode, int mapping)
	int run, fd;
	int total = ARRAY_SIZE(sizes);

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < total; run++) {
		/* check initial tags for anonymous mmap */
		ptr = (char *)mte_allocate_memory(sizes[run], mem_type, mapping, false);
+2 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ static int check_child_memory_mapping(int mem_type, int mode, int mapping)
	int item = ARRAY_SIZE(sizes);

	item = ARRAY_SIZE(sizes);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < item; run++) {
		ptr = (char *)mte_allocate_memory_tag_range(sizes[run], mem_type, mapping,
							    UNDERFLOW, OVERFLOW);
@@ -109,7 +109,7 @@ static int check_child_file_mapping(int mem_type, int mode, int mapping)
	int run, fd, map_size, result = KSFT_PASS;
	int total = ARRAY_SIZE(sizes);

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < total; run++) {
		fd = create_temp_file();
		if (fd == -1)
+3 −3
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static int check_hugetlb_memory_mapping(int mem_type, int mode, int mapping, int

	map_size = default_huge_page_size();

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	map_ptr = (char *)mte_allocate_memory(map_size, mem_type, mapping, false);
	if (check_allocated_memory(map_ptr, map_size, mem_type, false) != KSFT_PASS)
		return KSFT_FAIL;
@@ -180,7 +180,7 @@ static int check_clear_prot_mte_flag(int mem_type, int mode, int mapping)
	unsigned long map_size;

	prot_flag = PROT_READ | PROT_WRITE;
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	map_size = default_huge_page_size();
	map_ptr = (char *)mte_allocate_memory_tag_range(map_size, mem_type, mapping,
							0, 0);
@@ -210,7 +210,7 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappin

	map_size = default_huge_page_size();

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	ptr = (char *)mte_allocate_memory_tag_range(map_size, mem_type, mapping,
						    0, 0);
	if (check_allocated_memory_range(ptr, map_size, mem_type,
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static int check_madvise_options(int mem_type, int mode, int mapping)
		return err;
	}

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	ptr = mte_allocate_memory(TEST_UNIT * page_sz, mem_type, mapping, true);
	if (check_allocated_memory(ptr, TEST_UNIT * page_sz, mem_type, false) != KSFT_PASS)
		return KSFT_FAIL;
+3 −3
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int check_anonymous_memory_mapping(int mem_type, int mode, int mapping, i
	int run, result, map_size;
	int item = ARRAY_SIZE(sizes);

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < item; run++) {
		map_size = sizes[run] + OVERFLOW + UNDERFLOW;
		map_ptr = (char *)mte_allocate_memory(map_size, mem_type, mapping, false);
@@ -122,7 +122,7 @@ static int check_file_memory_mapping(int mem_type, int mode, int mapping, int ta
	int total = ARRAY_SIZE(sizes);
	int result = KSFT_PASS;

	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < total; run++) {
		fd = create_temp_file();
		if (fd == -1)
@@ -161,7 +161,7 @@ static int check_clear_prot_mte_flag(int mem_type, int mode, int mapping, int at
	int total = ARRAY_SIZE(sizes);

	prot_flag = PROT_READ | PROT_WRITE;
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
	mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG, false);
	for (run = 0; run < total; run++) {
		map_size = sizes[run] + OVERFLOW + UNDERFLOW;
		ptr = (char *)mte_allocate_memory_tag_range(sizes[run], mem_type, mapping,
Loading