[PATCH v2 02/11] kselftest/arm64: Factor shared signal handlers out of fp-stress loads

From: Mark Brown

Date: Thu Nov 05 2026 - 09:36:02 EST


The assembly programs run by fp-stress all have identical signal
handlers for cleanly exiting the program and simply count signal
deliveries, consolidate them into a single copy in asm-utils-linux.S.

No functional change.

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
tools/testing/selftests/arm64/fp/asm-utils-linux.S | 43 ++++++++++++++++++++++
tools/testing/selftests/arm64/fp/fpsimd-test.S | 28 --------------
tools/testing/selftests/arm64/fp/sve-test.S | 28 --------------
tools/testing/selftests/arm64/fp/za-test.S | 28 --------------
tools/testing/selftests/arm64/fp/zt-test.S | 28 --------------
5 files changed, 43 insertions(+), 112 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/testing/selftests/arm64/fp/asm-utils-linux.S
index e6c22b41dc5e..3effeb1fbf50 100644
--- a/tools/testing/selftests/arm64/fp/asm-utils-linux.S
+++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S
@@ -6,6 +6,7 @@

#include <asm/unistd.h>
#include "assembler.h"
+#include "asm-offsets.h"

// Print a single character x0 to stdout
// Clobbers x0-x2,x8
@@ -41,3 +42,45 @@ function puts
ret
endfunction
.globl puts
+
+// Signal handler which reports a clean exit and terminates the program.
+// The tests keep their iteration count in x22 and their signal count in
+// x23, report those from the interrupted context.
+//
+// w0: signal number
+// x2: ucontext
+function terminate_handler
+ mov w21, w0
+ mov x20, x2
+
+ puts "Terminated by signal "
+ mov w0, w21
+ bl putdec
+ puts ", no error, iterations="
+ ldr x0, [x20, #ucontext_regs + 8 * 22]
+ bl putdec
+ puts ", signals="
+ ldr x0, [x20, #ucontext_regs + 8 * 23]
+ bl putdecn
+
+ mov x0, #0
+ mov x8, #__NR_exit
+ svc #0
+endfunction
+.globl terminate_handler
+
+// Signal handler which only records that the program was interrupted.
+// The tests keep their signal count in x23, update that in the
+// interrupted context.
+//
+// w0: signal number
+// x2: ucontext
+function tickle_handler
+ // Increment the signal count (x23):
+ ldr x0, [x2, #ucontext_regs + 8 * 23]
+ add x0, x0, #1
+ str x0, [x2, #ucontext_regs + 8 * 23]
+
+ ret
+endfunction
+.globl tickle_handler
diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing/selftests/arm64/fp/fpsimd-test.S
index f89d67894c2e..9db7b5419397 100644
--- a/tools/testing/selftests/arm64/fp/fpsimd-test.S
+++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S
@@ -149,34 +149,6 @@ function irritator_handler
ret
endfunction

-function tickle_handler
- // Increment the signal count (x23):
- ldr x0, [x2, #ucontext_regs + 8 * 23]
- add x0, x0, #1
- str x0, [x2, #ucontext_regs + 8 * 23]
-
- ret
-endfunction
-
-function terminate_handler
- mov w21, w0
- mov x20, x2
-
- puts "Terminated by signal "
- mov w0, w21
- bl putdec
- puts ", no error, iterations="
- ldr x0, [x20, #ucontext_regs + 8 * 22]
- bl putdec
- puts ", signals="
- ldr x0, [x20, #ucontext_regs + 8 * 23]
- bl putdecn
-
- mov x0, #0
- mov x8, #__NR_exit
- svc #0
-endfunction
-
// w0: signal number
// x1: sa_action
// w2: sa_flags
diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/selftests/arm64/fp/sve-test.S
index 7ef7835389e7..2aadb5c3c0f3 100644
--- a/tools/testing/selftests/arm64/fp/sve-test.S
+++ b/tools/testing/selftests/arm64/fp/sve-test.S
@@ -317,34 +317,6 @@ function irritator_handler
ret
endfunction

-function tickle_handler
- // Increment the signal count (x23):
- ldr x0, [x2, #ucontext_regs + 8 * 23]
- add x0, x0, #1
- str x0, [x2, #ucontext_regs + 8 * 23]
-
- ret
-endfunction
-
-function terminate_handler
- mov w21, w0
- mov x20, x2
-
- puts "Terminated by signal "
- mov w0, w21
- bl putdec
- puts ", no error, iterations="
- ldr x0, [x20, #ucontext_regs + 8 * 22]
- bl putdec
- puts ", signals="
- ldr x0, [x20, #ucontext_regs + 8 * 23]
- bl putdecn
-
- mov x0, #0
- mov x8, #__NR_exit
- svc #0
-endfunction
-
// w0: signal number
// x1: sa_action
// w2: sa_flags
diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
index 9c33e13e9dc4..84e63e510f23 100644
--- a/tools/testing/selftests/arm64/fp/za-test.S
+++ b/tools/testing/selftests/arm64/fp/za-test.S
@@ -162,34 +162,6 @@ function irritator_handler
ret
endfunction

-function tickle_handler
- // Increment the signal count (x23):
- ldr x0, [x2, #ucontext_regs + 8 * 23]
- add x0, x0, #1
- str x0, [x2, #ucontext_regs + 8 * 23]
-
- ret
-endfunction
-
-function terminate_handler
- mov w21, w0
- mov x20, x2
-
- puts "Terminated by signal "
- mov w0, w21
- bl putdec
- puts ", no error, iterations="
- ldr x0, [x20, #ucontext_regs + 8 * 22]
- bl putdec
- puts ", signals="
- ldr x0, [x20, #ucontext_regs + 8 * 23]
- bl putdecn
-
- mov x0, #0
- mov x8, #__NR_exit
- svc #0
-endfunction
-
// w0: signal number
// x1: sa_action
// w2: sa_flags
diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/selftests/arm64/fp/zt-test.S
index a8df05771670..afcadb5aff23 100644
--- a/tools/testing/selftests/arm64/fp/zt-test.S
+++ b/tools/testing/selftests/arm64/fp/zt-test.S
@@ -131,34 +131,6 @@ function irritator_handler
ret
endfunction

-function tickle_handler
- // Increment the signal count (x23):
- ldr x0, [x2, #ucontext_regs + 8 * 23]
- add x0, x0, #1
- str x0, [x2, #ucontext_regs + 8 * 23]
-
- ret
-endfunction
-
-function terminate_handler
- mov w21, w0
- mov x20, x2
-
- puts "Terminated by signal "
- mov w0, w21
- bl putdec
- puts ", no error, iterations="
- ldr x0, [x20, #ucontext_regs + 8 * 22]
- bl putdec
- puts ", signals="
- ldr x0, [x20, #ucontext_regs + 8 * 23]
- bl putdecn
-
- mov x0, #0
- mov x8, #__NR_exit
- svc #0
-endfunction
-
// w0: signal number
// x1: sa_action
// w2: sa_flags

--
2.47.3