From d3f89c26618a280e3207cb6cb88f58ce0d69d3a1 Mon Sep 17 00:00:00 2001 From: wangchengdong Date: Tue, 23 Dec 2025 10:48:46 +0800 Subject: [PATCH] arch/arm64: Add support to disable signals actions related data struct Add support to disable signals actions related struct Co-authored-by: guoshichao Signed-off-by: Chengdong Wang --- arch/arm64/include/irq.h | 10 ++++++---- arch/arm64/src/common/CMakeLists.txt | 11 ++++++++--- arch/arm64/src/common/Make.defs | 10 ++++++++-- arch/arm64/src/common/arm64_signal_dispatch.c | 4 ++-- arch/arm64/src/common/arm64_syscall.c | 6 ++---- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/arch/arm64/include/irq.h b/arch/arm64/include/irq.h index 773097ff06d..1779009d9aa 100644 --- a/arch/arm64/include/irq.h +++ b/arch/arm64/include/irq.h @@ -259,6 +259,11 @@ extern "C" struct xcptcontext { +#ifdef CONFIG_ENABLE_ALL_SIGNALS + /* task context, for signal process */ + + uint64_t *saved_regs; + #ifdef CONFIG_BUILD_KERNEL /* This is the saved address to use when returning from a user-space * signal handler. @@ -267,6 +272,7 @@ struct xcptcontext uintptr_t sigreturn; #endif +#endif /* CONFIG_ENABLE_ALL_SIGNALS */ /* task stack reg context */ uint64_t *regs; @@ -274,10 +280,6 @@ struct xcptcontext uint64_t *initregs; #endif - /* task context, for signal process */ - - uint64_t *saved_regs; - #ifdef CONFIG_ARCH_FPU uint64_t *fpu_regs; uint64_t *saved_fpu_regs; diff --git a/arch/arm64/src/common/CMakeLists.txt b/arch/arm64/src/common/CMakeLists.txt index 4a8c826755b..335cf602a48 100644 --- a/arch/arm64/src/common/CMakeLists.txt +++ b/arch/arm64/src/common/CMakeLists.txt @@ -32,7 +32,6 @@ list(APPEND SRCS arm64_initialize.c arm64_initialstate.c arm64_boot.c) list(APPEND SRCS arm64_nputs.c arm64_createstack.c) list(APPEND SRCS arm64_releasestack.c arm64_stackframe.c arm64_usestack.c) list(APPEND SRCS arm64_exit.c arm64_fork.c) -list(APPEND SRCS arm64_schedulesigaction.c arm64_sigdeliver.c) list(APPEND SRCS arm64_getintstack.c arm64_registerdump.c) list(APPEND SRCS arm64_perf.c arm64_tcbinfo.c) @@ -44,6 +43,10 @@ list(APPEND SRCS arm64_syscall.c) # Use common heap allocation for now (may need to be customized later) list(APPEND SRCS arm64_allocateheap.c) +if(CONFIG_ENABLE_ALL_SIGNALS) + list(APPEND SRCS arm64_schedulesigaction.c arm64_sigdeliver.c) +endif() + if(NOT CONFIG_ARCH_IDLE_CUSTOM) list(APPEND SRCS arm64_idle.c) endif() @@ -89,8 +92,10 @@ if(CONFIG_SMP) endif() if(CONFIG_BUILD_KERNEL) - list(APPEND SRCS arm64_task_start.c arm64_pthread_start.c - arm64_signal_dispatch.c) + list(APPEND SRCS arm64_task_start.c arm64_pthread_start.c) + if(CONFIG_ENABLE_ALL_SIGNALS) + list(APPEND SRCS arm64_signal_dispatch.c) + endif() endif() if(CONFIG_ARCH_KERNEL_STACK) diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs index 2d8b1759e55..7a782b3faa0 100644 --- a/arch/arm64/src/common/Make.defs +++ b/arch/arm64/src/common/Make.defs @@ -39,7 +39,6 @@ CMN_CSRCS = arm64_initialize.c arm64_initialstate.c arm64_boot.c CMN_CSRCS += arm64_nputs.c arm64_createstack.c CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c CMN_CSRCS += arm64_exit.c arm64_fork.c -CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c CMN_CSRCS += arm64_perf.c arm64_tcbinfo.c @@ -50,6 +49,10 @@ CMN_CSRCS += arm64_syscall.c CMN_CSRCS += arm64_modifyreg8.c arm64_modifyreg16.c arm64_modifyreg32.c CMN_CSRCS += arm64_hwdebug.c +ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) +CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c +endif + # Use common heap allocation for now (may need to be customized later) CMN_CSRCS += arm64_allocateheap.c @@ -99,7 +102,10 @@ CMN_CSRCS += arm64_smpcall.c endif ifeq ($(CONFIG_BUILD_KERNEL),y) -CMN_CSRCS += arm64_task_start.c arm64_pthread_start.c arm64_signal_dispatch.c +CMN_CSRCS += arm64_task_start.c arm64_pthread_start.c + ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) + CMN_CSRCS += arm64_signal_dispatch.c + endif endif ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) diff --git a/arch/arm64/src/common/arm64_signal_dispatch.c b/arch/arm64/src/common/arm64_signal_dispatch.c index 2c4bdc90a41..79dcf447582 100644 --- a/arch/arm64/src/common/arm64_signal_dispatch.c +++ b/arch/arm64/src/common/arm64_signal_dispatch.c @@ -31,7 +31,7 @@ #include "arm64_internal.h" -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) +#ifdef __KERNEL__ /**************************************************************************** * Public Functions @@ -75,4 +75,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, (uintptr_t)info, (uintptr_t)ucontext); } -#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ +#endif /* __KERNEL__ */ diff --git a/arch/arm64/src/common/arm64_syscall.c b/arch/arm64/src/common/arm64_syscall.c index 8e4335a1aed..87bf4072b81 100644 --- a/arch/arm64/src/common/arm64_syscall.c +++ b/arch/arm64/src/common/arm64_syscall.c @@ -218,7 +218,7 @@ uint64_t *arm64_syscall(uint64_t *regs) restore_critical_section(tcb, cpu); break; -#ifdef CONFIG_BUILD_KERNEL +#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ENABLE_ALL_SIGNALS) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, @@ -285,9 +285,7 @@ uint64_t *arm64_syscall(uint64_t *regs) #endif } break; -#endif -#ifdef CONFIG_BUILD_KERNEL /* R0=SYS_signal_handler_return: This a user signal handler callback * * void signal_handler_return(void); @@ -317,7 +315,7 @@ uint64_t *arm64_syscall(uint64_t *regs) #endif } break; -#endif +#endif /* CONFIG_BUILD_KERNEL && CONFIG_ENABLE_ALL_SIGNALS */ default: {