diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/testing/selftests/arm64/fp/asm-utils-linux.S
index 9cd31dc47709..9519be4d8f1e 100644
--- a/tools/testing/selftests/arm64/fp/asm-utils-linux.S
+++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S
@@ -92,3 +92,90 @@ function exit_error
svc #0
endfunction
.globl exit_error
+
+// Install a signal handler
+//
+// w0: signal number
+// x1: sa_action
+// w2: sa_flags
+// Clobbers x0-x6,x8
+function setsignal
+ str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]!
+
+ mov w4, w0
+ mov x5, x1
+ mov w6, w2
+
+ add x0, sp, #16
+ mov x1, #sa_sz
+ bl memclr
+
+ mov w0, w4
+ add x1, sp, #16
+ str w6, [x1, #sa_flags]
+ str x5, [x1, #sa_handler]
+ mov x2, #0
+ mov x3, #sa_mask_sz
+ mov x8, #__NR_rt_sigaction
+ svc #0
+
+ cbz w0, 1f
+
+ puts "sigaction failure\n"
+ b exit_error
+
+1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16)
+ ret
+endfunction
+.globl setsignal
+
+// Programs which want to be interrupted by SIGUSR1 provide an
+// irritator_handler(), for those that don't the signal is left alone.
+.weak irritator_handler
+
+// Main program entry point. Install the signal handlers shared by the
+// programs, zeroing the signal count in x23 that the handlers maintain,
+// read and report the PID the programs use for uniqueness in x20, then
+// run the program specific main().
+.globl _start
+function _start
+ enable_gcs
+
+ mov x23, #0 // signal count
+
+ mov w0, #SIGINT
+ adr x1, terminate_handler
+ mov w2, #SA_SIGINFO
+ bl setsignal
+
+ mov w0, #SIGTERM
+ adr x1, terminate_handler
+ mov w2, #SA_SIGINFO
+ bl setsignal
+
+ // Load as a literal, adr can't reference the symbol when the
+ // program provides no handler and it resolves to 0
+ ldr x1, =irritator_handler
+ cbz x1, 1f
+ mov w0, #SIGUSR1
+ mov w2, #SA_SIGINFO
+ orr w2, w2, #SA_NODEFER
+ bl setsignal
+
+1: mov w0, #SIGUSR2
+ adr x1, tickle_handler
+ mov w2, #SA_SIGINFO
+ orr w2, w2, #SA_NODEFER
+ bl setsignal
+
+ // Obtain our PID, to ensure test pattern uniqueness between processes
+ mov x8, #__NR_getpid
+ svc #0
+ mov x20, x0
+
+ puts "PID:\t"
+ mov x0, x20
+ bl putdecn
+
+ b main
+endfunction
diff --git a/tools/testing/selftests/arm64/fp/fp-pidbench.S b/tools/testing/selftests/arm64/fp/fp-pidbench.S
index 881dfa3b342e..80f45560290d 100644
--- a/tools/testing/selftests/arm64/fp/fp-pidbench.S
+++ b/tools/testing/selftests/arm64/fp/fp-pidbench.S
@@ -28,9 +28,9 @@
puts "\n"
.endm
-// Main program entry point
-.globl _start
-function _start
+// Program specific main function
+.globl main
+function main
puts "Iterations per test: "
mov x20, #10000
lsl x20, x20, #12
diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing/selftests/arm64/fp/fpsimd-test.S
index fcbb3a872490..df040283d076 100644
--- a/tools/testing/selftests/arm64/fp/fpsimd-test.S
+++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S
@@ -148,69 +148,11 @@ function irritator_handler
ret
endfunction
+.globl irritator_handler
-// w0: signal number
-// x1: sa_action
-// w2: sa_flags
-// Clobbers x0-x6,x8
-function setsignal
- str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]!
-
- mov w4, w0
- mov x5, x1
- mov w6, w2
-
- add x0, sp, #16
- mov x1, #sa_sz
- bl memclr
-
- mov w0, w4
- add x1, sp, #16
- str w6, [x1, #sa_flags]
- str x5, [x1, #sa_handler]
- mov x2, #0
- mov x3, #sa_mask_sz
- mov x8, #__NR_rt_sigaction
- svc #0
-
- cbz w0, 1f
-
- puts "sigaction failure\n"
- b exit_error
-
-1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16)
- ret
-endfunction
-
-// Main program entry point
-.globl _start
-function _start
- enable_gcs
-
- mov x23, #0 // signal count
-
- mov w0, #SIGINT
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGTERM
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGUSR1
- adr x1, irritator_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
- mov w0, #SIGUSR2
- adr x1, tickle_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
+// Program specific main function
+.globl main
+function main
// Sanity-check and report the vector length
mov x19, #128
@@ -231,16 +173,6 @@ function _start
bl putdec
puts " bits\n"
- // Obtain our PID, to ensure test pattern uniqueness between processes
-
- mov x8, #__NR_getpid
- svc #0
- mov x20, x0
-
- puts "PID:\t"
- mov x0, x20
- bl putdecn
-
mov x22, #0 // generation number, increments per iteration
.Ltest_loop:
diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/selftests/arm64/fp/sve-test.S
index d2ed2a44bdb5..a1925761ae39 100644
--- a/tools/testing/selftests/arm64/fp/sve-test.S
+++ b/tools/testing/selftests/arm64/fp/sve-test.S
@@ -316,69 +316,11 @@ function irritator_handler
ret
endfunction
+.globl irritator_handler
-// w0: signal number
-// x1: sa_action
-// w2: sa_flags
-// Clobbers x0-x6,x8
-function setsignal
- str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]!
-
- mov w4, w0
- mov x5, x1
- mov w6, w2
-
- add x0, sp, #16
- mov x1, #sa_sz
- bl memclr
-
- mov w0, w4
- add x1, sp, #16
- str w6, [x1, #sa_flags]
- str x5, [x1, #sa_handler]
- mov x2, #0
- mov x3, #sa_mask_sz
- mov x8, #__NR_rt_sigaction
- svc #0
-
- cbz w0, 1f
-
- puts "sigaction failure\n"
- b exit_error
-
-1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16)
- ret
-endfunction
-
-// Main program entry point
-.globl _start
-function _start
- enable_gcs
-
- mov x23, #0 // Irritation signal count
-
- mov w0, #SIGINT
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGTERM
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGUSR1
- adr x1, irritator_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
- mov w0, #SIGUSR2
- adr x1, tickle_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
+// Program specific main function
+.globl main
+function main
#ifdef SSVE
puts "Streaming mode "
smstart_sm
@@ -404,16 +346,6 @@ function _start
bl putdec
puts " bits\n"
- // Obtain our PID, to ensure test pattern uniqueness between processes
-
- mov x8, #__NR_getpid
- svc #0
- mov x20, x0
-
- puts "PID:\t"
- mov x0, x20
- bl putdecn
-
#ifdef SSVE
smstart_sm // syscalls will have exited streaming mode
#endif
diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
index e1ba559b66e9..3fb9ac5c8f8b 100644
--- a/tools/testing/selftests/arm64/fp/za-test.S
+++ b/tools/testing/selftests/arm64/fp/za-test.S
@@ -161,69 +161,11 @@ function irritator_handler
ret
endfunction
+.globl irritator_handler
-// w0: signal number
-// x1: sa_action
-// w2: sa_flags
-// Clobbers x0-x6,x8
-function setsignal
- str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]!
-
- mov w4, w0
- mov x5, x1
- mov w6, w2
-
- add x0, sp, #16
- mov x1, #sa_sz
- bl memclr
-
- mov w0, w4
- add x1, sp, #16
- str w6, [x1, #sa_flags]
- str x5, [x1, #sa_handler]
- mov x2, #0
- mov x3, #sa_mask_sz
- mov x8, #__NR_rt_sigaction
- svc #0
-
- cbz w0, 1f
-
- puts "sigaction failure\n"
- b exit_error
-
-1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16)
- ret
-endfunction
-
-// Main program entry point
-.globl _start
-function _start
- enable_gcs
-
- mov x23, #0 // signal count
-
- mov w0, #SIGINT
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGTERM
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGUSR1
- adr x1, irritator_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
- mov w0, #SIGUSR2
- adr x1, tickle_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
+// Program specific main function
+.globl main
+function main
puts "Streaming mode "
smstart_za
@@ -247,15 +189,6 @@ function _start
bl putdec
puts " bits\n"
- // Obtain our PID, to ensure test pattern uniqueness between processes
- mov x8, #__NR_getpid
- svc #0
- mov x20, x0
-
- puts "PID:\t"
- mov x0, x20
- bl putdecn
-
mov x22, #0 // generation number, increments per iteration
.Ltest_loop:
rdsvl 0, 8
diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/selftests/arm64/fp/zt-test.S
index 7fbd96face01..39af1c96a4e5 100644
--- a/tools/testing/selftests/arm64/fp/zt-test.S
+++ b/tools/testing/selftests/arm64/fp/zt-test.S
@@ -130,80 +130,13 @@ function irritator_handler
ret
endfunction
+.globl irritator_handler
-// w0: signal number
-// x1: sa_action
-// w2: sa_flags
-// Clobbers x0-x6,x8
-function setsignal
- str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]!
-
- mov w4, w0
- mov x5, x1
- mov w6, w2
-
- add x0, sp, #16
- mov x1, #sa_sz
- bl memclr
-
- mov w0, w4
- add x1, sp, #16
- str w6, [x1, #sa_flags]
- str x5, [x1, #sa_handler]
- mov x2, #0
- mov x3, #sa_mask_sz
- mov x8, #__NR_rt_sigaction
- svc #0
-
- cbz w0, 1f
-
- puts "sigaction failure\n"
- b exit_error
-
-1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16)
- ret
-endfunction
-
-// Main program entry point
-.globl _start
-function _start
- enable_gcs
-
- mov x23, #0 // signal count
-
- mov w0, #SIGINT
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGTERM
- adr x1, terminate_handler
- mov w2, #SA_SIGINFO
- bl setsignal
-
- mov w0, #SIGUSR1
- adr x1, irritator_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
- mov w0, #SIGUSR2
- adr x1, tickle_handler
- mov w2, #SA_SIGINFO
- orr w2, w2, #SA_NODEFER
- bl setsignal
-
+// Program specific main function
+.globl main
+function main
smstart_za
- // Obtain our PID, to ensure test pattern uniqueness between processes
- mov x8, #__NR_getpid
- svc #0
- mov x20, x0
-
- puts "PID:\t"
- mov x0, x20
- bl putdecn
-
mov x22, #0 // generation number, increments per iteration
.Ltest_loop:
mov x0, x20
--
2.47.3