diff mbox series

[v1,1/5] selftests/arm64: Log errors in verify_mte_pointer_validity()

Message ID 20220510164520.768783-2-broonie@kernel.org (mailing list archive)
State Accepted
Commit 9a5681710740e496ee8b08004ddf2c212b76b36a
Headers show
Series selftests/arm64: MTE check_tags_inclusion cleanups | expand

Commit Message

Mark Brown May 10, 2022, 4:45 p.m. UTC
When we detect a problem in verify_mte_pointer_validity() while checking
tags we don't log what the problem was which makes debugging harder. Add
some diagnostics.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 .../selftests/arm64/mte/check_tags_inclusion.c       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Shuah Khan May 10, 2022, 5:15 p.m. UTC | #1
On 5/10/22 10:45 AM, Mark Brown wrote:
> When we detect a problem in verify_mte_pointer_validity() while checking
> tags we don't log what the problem was which makes debugging harder. Add
> some diagnostics.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>   .../selftests/arm64/mte/check_tags_inclusion.c       | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
> index deaef1f61076..b906914997ce 100644
> --- a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
> +++ b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
> @@ -25,8 +25,11 @@ static int verify_mte_pointer_validity(char *ptr, int mode)
>   	/* Check the validity of the tagged pointer */
>   	memset((void *)ptr, '1', BUFFER_SIZE);
>   	mte_wait_after_trig();
> -	if (cur_mte_cxt.fault_valid)
> +	if (cur_mte_cxt.fault_valid) {
> +		ksft_print_msg("Unexpected fault recorded for %p-%p in mode %x\n",
> +			       ptr, ptr + BUFFER_SIZE, mode);
>   		return KSFT_FAIL;
> +	}
>   	/* Proceed further for nonzero tags */
>   	if (!MT_FETCH_TAG((uintptr_t)ptr))
>   		return KSFT_PASS;
> @@ -34,10 +37,13 @@ static int verify_mte_pointer_validity(char *ptr, int mode)
>   	/* Check the validity outside the range */
>   	ptr[BUFFER_SIZE] = '2';
>   	mte_wait_after_trig();
> -	if (!cur_mte_cxt.fault_valid)
> +	if (!cur_mte_cxt.fault_valid) {
> +		ksft_print_msg("No valid fault recorded for %p in mode %x\n",
> +			       ptr, mode);
>   		return KSFT_FAIL;
> -	else
> +	} else {
>   		return KSFT_PASS;
> +	}
>   }
>   
>   static int check_single_included_tags(int mem_type, int mode)
> 

Nice. Thanks for the patch.

It would be a nice addition to print mode names as strings to make
it easy to understand. Could done in a future patch. e,g: MTE_NONE_ERR etc.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
index deaef1f61076..b906914997ce 100644
--- a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
+++ b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
@@ -25,8 +25,11 @@  static int verify_mte_pointer_validity(char *ptr, int mode)
 	/* Check the validity of the tagged pointer */
 	memset((void *)ptr, '1', BUFFER_SIZE);
 	mte_wait_after_trig();
-	if (cur_mte_cxt.fault_valid)
+	if (cur_mte_cxt.fault_valid) {
+		ksft_print_msg("Unexpected fault recorded for %p-%p in mode %x\n",
+			       ptr, ptr + BUFFER_SIZE, mode);
 		return KSFT_FAIL;
+	}
 	/* Proceed further for nonzero tags */
 	if (!MT_FETCH_TAG((uintptr_t)ptr))
 		return KSFT_PASS;
@@ -34,10 +37,13 @@  static int verify_mte_pointer_validity(char *ptr, int mode)
 	/* Check the validity outside the range */
 	ptr[BUFFER_SIZE] = '2';
 	mte_wait_after_trig();
-	if (!cur_mte_cxt.fault_valid)
+	if (!cur_mte_cxt.fault_valid) {
+		ksft_print_msg("No valid fault recorded for %p in mode %x\n",
+			       ptr, mode);
 		return KSFT_FAIL;
-	else
+	} else {
 		return KSFT_PASS;
+	}
 }
 
 static int check_single_included_tags(int mem_type, int mode)