Skip to content

Commit 72d6771

Browse files
brooniectmarinas
authored andcommitted
selftests/arm64: Check failures to set tags in check_tags_inclusion
The MTE check_tags_inclusion test uses the mte_switch_mode() helper but ignores the return values it generates meaning we might not be testing the things we're trying to test, fail the test if it reports an error. The helper will log any errors it returns. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent ffc8274 commit 72d6771

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ static int verify_mte_pointer_validity(char *ptr, int mode)
4949
static int check_single_included_tags(int mem_type, int mode)
5050
{
5151
char *ptr;
52-
int tag, run, result = KSFT_PASS;
52+
int tag, run, ret, result = KSFT_PASS;
5353

5454
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
5555
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
5656
mem_type, false) != KSFT_PASS)
5757
return KSFT_FAIL;
5858

5959
for (tag = 0; (tag < MT_TAG_COUNT) && (result == KSFT_PASS); tag++) {
60-
mte_switch_mode(mode, MT_INCLUDE_VALID_TAG(tag));
60+
ret = mte_switch_mode(mode, MT_INCLUDE_VALID_TAG(tag));
61+
if (ret != 0)
62+
result = KSFT_FAIL;
6163
/* Try to catch a excluded tag by a number of tries. */
6264
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
6365
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
@@ -111,14 +113,16 @@ static int check_multiple_included_tags(int mem_type, int mode)
111113
static int check_all_included_tags(int mem_type, int mode)
112114
{
113115
char *ptr;
114-
int run, result = KSFT_PASS;
116+
int run, ret, result = KSFT_PASS;
115117

116118
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
117119
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
118120
mem_type, false) != KSFT_PASS)
119121
return KSFT_FAIL;
120122

121-
mte_switch_mode(mode, MT_INCLUDE_TAG_MASK);
123+
ret = mte_switch_mode(mode, MT_INCLUDE_TAG_MASK);
124+
if (ret != 0)
125+
return KSFT_FAIL;
122126
/* Try to catch a excluded tag by a number of tries. */
123127
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
124128
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
@@ -135,13 +139,15 @@ static int check_all_included_tags(int mem_type, int mode)
135139
static int check_none_included_tags(int mem_type, int mode)
136140
{
137141
char *ptr;
138-
int run;
142+
int run, ret;
139143

140144
ptr = (char *)mte_allocate_memory(BUFFER_SIZE, mem_type, 0, false);
141145
if (check_allocated_memory(ptr, BUFFER_SIZE, mem_type, false) != KSFT_PASS)
142146
return KSFT_FAIL;
143147

144-
mte_switch_mode(mode, MT_EXCLUDE_TAG_MASK);
148+
ret = mte_switch_mode(mode, MT_EXCLUDE_TAG_MASK);
149+
if (ret != 0)
150+
return KSFT_FAIL;
145151
/* Try to catch a excluded tag by a number of tries. */
146152
for (run = 0; run < RUNS; run++) {
147153
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);

0 commit comments

Comments
 (0)