From 41f83a0271daab9a9bba6afbe5f7dd99000c5af5 Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 6 Apr 2023 13:48:28 +0800 Subject: [PATCH] arch/arm64: change up_saveusercontext to assembly code minidump will backtrace failure when use C code to save user context, because the stack push operation in C code can disrupt the stack information. Signed-off-by: zhangyuan21 --- arch/arm64/src/common/arm64_internal.h | 1 - arch/arm64/src/common/arm64_task_sched.c | 38 ------------------------ arch/arm64/src/common/arm64_vectors.S | 6 ++-- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/arch/arm64/src/common/arm64_internal.h b/arch/arm64/src/common/arm64_internal.h index 081908cffb..98c4e79c00 100644 --- a/arch/arm64/src/common/arm64_internal.h +++ b/arch/arm64/src/common/arm64_internal.h @@ -254,7 +254,6 @@ void arm64_secondary_start(void); void arm64_fullcontextrestore(uint64_t *restoreregs) noreturn_function; void arm64_switchcontext(uint64_t **saveregs, uint64_t *restoreregs); -void arm64_context_snapshot(void *savereg); /* Signal handling **********************************************************/ diff --git a/arch/arm64/src/common/arm64_task_sched.c b/arch/arm64/src/common/arm64_task_sched.c index bb5254345a..69f27df8c1 100644 --- a/arch/arm64/src/common/arm64_task_sched.c +++ b/arch/arm64/src/common/arm64_task_sched.c @@ -44,44 +44,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int up_saveusercontext(void *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ -#ifdef CONFIG_BUILD_FLAT - -int up_saveusercontext(void *saveregs) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - - arm64_context_snapshot(saveregs); - - leave_critical_section(flags); - return 0; -} - -#else - -int up_saveusercontext(void *saveregs) -{ - return sys_call1(SYS_save_context, (uintptr_t)saveregs); -} - -#endif - /**************************************************************************** * Name: arm64_fullcontextrestore * diff --git a/arch/arm64/src/common/arm64_vectors.S b/arch/arm64/src/common/arm64_vectors.S index 14c6f61ada..77507cfad9 100644 --- a/arch/arm64/src/common/arm64_vectors.S +++ b/arch/arm64/src/common/arm64_vectors.S @@ -60,15 +60,15 @@ ****************************************************************************/ /**************************************************************************** - * Function: arm64_context_snapshot + * Function: up_saveusercontext * * Description: * Take a snapshot of the thread GP registers context * x0 --- pointer to struct regs_context * ****************************************************************************/ -GTEXT(arm64_context_snapshot) -SECTION_FUNC(text, arm64_context_snapshot) +GTEXT(up_saveusercontext) +SECTION_FUNC(text, up_saveusercontext) str x0, [sp, #-16]! stp x0, x1, [x0, #8 * REG_X0]