[PATCH 4/6] kselftest/arm64: Implement irritators for ZA and ZT

Mark Brown posted 6 patches 1 month ago
There is a newer version of this series
[PATCH 4/6] kselftest/arm64: Implement irritators for ZA and ZT
Posted by Mark Brown 1 month ago
Currently we don't use the irritator signal in our floating point stress
tests so when we added ZA and ZT stress tests we didn't actually bother
implementing any actual action in the handlers, we just counted the signal
deliveries. In preparation for using the irritators let's implement them,
just trivially SMSTOP and SMSTART to reset all bits in the register to 0.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/fp/za-test.S | 12 ++++--------
 tools/testing/selftests/arm64/fp/zt-test.S | 12 ++++--------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
index 1ee0ec36766d2bef92aff50a002813e76e22963c..f902e6ef9077bfa34fa7f85ce572ce3df4346789 100644
--- a/tools/testing/selftests/arm64/fp/za-test.S
+++ b/tools/testing/selftests/arm64/fp/za-test.S
@@ -148,20 +148,16 @@ function check_za
 	b	memcmp
 endfunction
 
-// Any SME register modified here can cause corruption in the main
-// thread -- but *only* the locations modified here.
+// Modify the live SME register state, signal return will undo our changes
 function irritator_handler
 	// Increment the irritation signal count (x23):
 	ldr	x0, [x2, #ucontext_regs + 8 * 23]
 	add	x0, x0, #1
 	str	x0, [x2, #ucontext_regs + 8 * 23]
 
-	// Corrupt some random ZA data
-#if 0
-	movi	v0.8b, #1
-	movi	v9.16b, #2
-	movi	v31.8b, #3
-#endif
+	// This will reset ZA to all bits 0
+	smstop
+	smstart
 
 	ret
 endfunction
diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/selftests/arm64/fp/zt-test.S
index ade9c98abcdafc2755ef4796670566d99e919e5c..c96cb7c2ad4b406c54099fe3f73917259bd947e4 100644
--- a/tools/testing/selftests/arm64/fp/zt-test.S
+++ b/tools/testing/selftests/arm64/fp/zt-test.S
@@ -117,20 +117,16 @@ function check_zt
 	b	memcmp
 endfunction
 
-// Any SME register modified here can cause corruption in the main
-// thread -- but *only* the locations modified here.
+// Modify the live SME register state, signal return will undo our changes
 function irritator_handler
 	// Increment the irritation signal count (x23):
 	ldr	x0, [x2, #ucontext_regs + 8 * 23]
 	add	x0, x0, #1
 	str	x0, [x2, #ucontext_regs + 8 * 23]
 
-	// Corrupt some random ZT data
-#if 0
-	movi	v0.8b, #1
-	movi	v9.16b, #2
-	movi	v31.8b, #3
-#endif
+	// This will reset ZT to all bits 0
+	smstop
+	smstart
 
 	ret
 endfunction

-- 
2.39.2
Re: [PATCH 4/6] kselftest/arm64: Implement irritators for ZA and ZT
Posted by Mark Rutland 2 weeks, 5 days ago
On Wed, Oct 23, 2024 at 09:38:32PM +0100, Mark Brown wrote:
> Currently we don't use the irritator signal in our floating point stress
> tests so when we added ZA and ZT stress tests we didn't actually bother
> implementing any actual action in the handlers, we just counted the signal
> deliveries. In preparation for using the irritators let's implement them,
> just trivially SMSTOP and SMSTART to reset all bits in the register to 0.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

> ---
>  tools/testing/selftests/arm64/fp/za-test.S | 12 ++++--------
>  tools/testing/selftests/arm64/fp/zt-test.S | 12 ++++--------
>  2 files changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
> index 1ee0ec36766d2bef92aff50a002813e76e22963c..f902e6ef9077bfa34fa7f85ce572ce3df4346789 100644
> --- a/tools/testing/selftests/arm64/fp/za-test.S
> +++ b/tools/testing/selftests/arm64/fp/za-test.S
> @@ -148,20 +148,16 @@ function check_za
>  	b	memcmp
>  endfunction
>  
> -// Any SME register modified here can cause corruption in the main
> -// thread -- but *only* the locations modified here.
> +// Modify the live SME register state, signal return will undo our changes
>  function irritator_handler
>  	// Increment the irritation signal count (x23):
>  	ldr	x0, [x2, #ucontext_regs + 8 * 23]
>  	add	x0, x0, #1
>  	str	x0, [x2, #ucontext_regs + 8 * 23]
>  
> -	// Corrupt some random ZA data
> -#if 0
> -	movi	v0.8b, #1
> -	movi	v9.16b, #2
> -	movi	v31.8b, #3
> -#endif
> +	// This will reset ZA to all bits 0
> +	smstop
> +	smstart
>  
>  	ret
>  endfunction
> diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/selftests/arm64/fp/zt-test.S
> index ade9c98abcdafc2755ef4796670566d99e919e5c..c96cb7c2ad4b406c54099fe3f73917259bd947e4 100644
> --- a/tools/testing/selftests/arm64/fp/zt-test.S
> +++ b/tools/testing/selftests/arm64/fp/zt-test.S
> @@ -117,20 +117,16 @@ function check_zt
>  	b	memcmp
>  endfunction
>  
> -// Any SME register modified here can cause corruption in the main
> -// thread -- but *only* the locations modified here.
> +// Modify the live SME register state, signal return will undo our changes
>  function irritator_handler
>  	// Increment the irritation signal count (x23):
>  	ldr	x0, [x2, #ucontext_regs + 8 * 23]
>  	add	x0, x0, #1
>  	str	x0, [x2, #ucontext_regs + 8 * 23]
>  
> -	// Corrupt some random ZT data
> -#if 0
> -	movi	v0.8b, #1
> -	movi	v9.16b, #2
> -	movi	v31.8b, #3
> -#endif
> +	// This will reset ZT to all bits 0
> +	smstop
> +	smstart
>  
>  	ret
>  endfunction
> 
> -- 
> 2.39.2
>