aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/x86/sigaltstack.c
diff options
context:
space:
mode:
authorChang S. Bae <[email protected]>2025-02-26 01:07:21 +0000
committerIngo Molnar <[email protected]>2025-02-26 12:05:28 +0000
commitdbd6b649e7d5b66c7fa95a65d67b59cf5b45f0ac (patch)
treed2869469913beefa4d2cd5272bb5760727c900e7 /tools/testing/selftests/x86/sigaltstack.c
parentMerge tag 'v6.14-rc4' into x86/fpu, to pick up fixes and refresh the branch (diff)
downloadkernel-dbd6b649e7d5b66c7fa95a65d67b59cf5b45f0ac.tar.gz
kernel-dbd6b649e7d5b66c7fa95a65d67b59cf5b45f0ac.zip
selftests/x86: Consolidate redundant signal helper functions
The x86 selftests frequently register and clean up signal handlers, but the sethandler() and clearhandler() functions have been redundantly copied across multiple .c files. Move these functions to helpers.h to enable reuse across tests, eliminating around 250 lines of duplicate code. Converge the error handling by using ksft_exit_fail_msg(), which is functionally equivalent with err() within the selftest framework. This change is a prerequisite for the upcoming xstate selftest, which requires signal handling for registering and cleaning up handlers. Signed-off-by: Chang S. Bae <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'tools/testing/selftests/x86/sigaltstack.c')
-rw-r--r--tools/testing/selftests/x86/sigaltstack.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/tools/testing/selftests/x86/sigaltstack.c b/tools/testing/selftests/x86/sigaltstack.c
index f689af75e979..0ae1b784498c 100644
--- a/tools/testing/selftests/x86/sigaltstack.c
+++ b/tools/testing/selftests/x86/sigaltstack.c
@@ -14,6 +14,8 @@
#include <sys/resource.h>
#include <setjmp.h>
+#include "helpers.h"
+
/* sigaltstack()-enforced minimum stack */
#define ENFORCED_MINSIGSTKSZ 2048
@@ -27,30 +29,6 @@ static bool sigalrm_expected;
static unsigned long at_minstack_size;
-static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
- int flags)
-{
- struct sigaction sa;
-
- memset(&sa, 0, sizeof(sa));
- sa.sa_sigaction = handler;
- sa.sa_flags = SA_SIGINFO | flags;
- sigemptyset(&sa.sa_mask);
- if (sigaction(sig, &sa, 0))
- err(1, "sigaction");
-}
-
-static void clearhandler(int sig)
-{
- struct sigaction sa;
-
- memset(&sa, 0, sizeof(sa));
- sa.sa_handler = SIG_DFL;
- sigemptyset(&sa.sa_mask);
- if (sigaction(sig, &sa, 0))
- err(1, "sigaction");
-}
-
static int setup_altstack(void *start, unsigned long size)
{
stack_t ss;