Commit 72d6771c authored by Mark Brown's avatar Mark Brown Committed by Catalin Marinas

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: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220510164520.768783-4-broonie@kernel.orgSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent ffc8274c
...@@ -49,7 +49,7 @@ static int verify_mte_pointer_validity(char *ptr, int mode) ...@@ -49,7 +49,7 @@ static int verify_mte_pointer_validity(char *ptr, int mode)
static int check_single_included_tags(int mem_type, int mode) static int check_single_included_tags(int mem_type, int mode)
{ {
char *ptr; char *ptr;
int tag, run, result = KSFT_PASS; int tag, run, ret, result = KSFT_PASS;
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false); ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE, if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
...@@ -57,7 +57,9 @@ static int check_single_included_tags(int mem_type, int mode) ...@@ -57,7 +57,9 @@ static int check_single_included_tags(int mem_type, int mode)
return KSFT_FAIL; return KSFT_FAIL;
for (tag = 0; (tag < MT_TAG_COUNT) && (result == KSFT_PASS); tag++) { for (tag = 0; (tag < MT_TAG_COUNT) && (result == KSFT_PASS); tag++) {
mte_switch_mode(mode, MT_INCLUDE_VALID_TAG(tag)); ret = mte_switch_mode(mode, MT_INCLUDE_VALID_TAG(tag));
if (ret != 0)
result = KSFT_FAIL;
/* Try to catch a excluded tag by a number of tries. */ /* Try to catch a excluded tag by a number of tries. */
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) { for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE); ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
...@@ -111,14 +113,16 @@ static int check_multiple_included_tags(int mem_type, int mode) ...@@ -111,14 +113,16 @@ static int check_multiple_included_tags(int mem_type, int mode)
static int check_all_included_tags(int mem_type, int mode) static int check_all_included_tags(int mem_type, int mode)
{ {
char *ptr; char *ptr;
int run, result = KSFT_PASS; int run, ret, result = KSFT_PASS;
ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false); ptr = (char *)mte_allocate_memory(BUFFER_SIZE + MT_GRANULE_SIZE, mem_type, 0, false);
if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE, if (check_allocated_memory(ptr, BUFFER_SIZE + MT_GRANULE_SIZE,
mem_type, false) != KSFT_PASS) mem_type, false) != KSFT_PASS)
return KSFT_FAIL; return KSFT_FAIL;
mte_switch_mode(mode, MT_INCLUDE_TAG_MASK); ret = mte_switch_mode(mode, MT_INCLUDE_TAG_MASK);
if (ret != 0)
return KSFT_FAIL;
/* Try to catch a excluded tag by a number of tries. */ /* Try to catch a excluded tag by a number of tries. */
for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) { for (run = 0; (run < RUNS) && (result == KSFT_PASS); run++) {
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE); ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
...@@ -135,13 +139,15 @@ static int check_all_included_tags(int mem_type, int mode) ...@@ -135,13 +139,15 @@ static int check_all_included_tags(int mem_type, int mode)
static int check_none_included_tags(int mem_type, int mode) static int check_none_included_tags(int mem_type, int mode)
{ {
char *ptr; char *ptr;
int run; int run, ret;
ptr = (char *)mte_allocate_memory(BUFFER_SIZE, mem_type, 0, false); ptr = (char *)mte_allocate_memory(BUFFER_SIZE, mem_type, 0, false);
if (check_allocated_memory(ptr, BUFFER_SIZE, mem_type, false) != KSFT_PASS) if (check_allocated_memory(ptr, BUFFER_SIZE, mem_type, false) != KSFT_PASS)
return KSFT_FAIL; return KSFT_FAIL;
mte_switch_mode(mode, MT_EXCLUDE_TAG_MASK); ret = mte_switch_mode(mode, MT_EXCLUDE_TAG_MASK);
if (ret != 0)
return KSFT_FAIL;
/* Try to catch a excluded tag by a number of tries. */ /* Try to catch a excluded tag by a number of tries. */
for (run = 0; run < RUNS; run++) { for (run = 0; run < RUNS; run++) {
ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE); ptr = (char *)mte_insert_tags(ptr, BUFFER_SIZE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment