This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch releases/12.6 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2fa7b9cc34e62ce23d00a32af21e325b807f2d98 Author: Yanfeng Liu <yfliu2...@qq.com> AuthorDate: Tue Jul 16 14:41:04 2024 +0800 riscv/trap: fix sp restore logic This fixes stack pointer restore logic to avoid parent stack corruption by forked child in PROTECTED build. Signed-off-by: Yanfeng Liu <yfliu2...@qq.com> --- arch/risc-v/src/common/riscv_exception_common.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/risc-v/src/common/riscv_exception_common.S b/arch/risc-v/src/common/riscv_exception_common.S index 9035947031..7bcf2d2d72 100644 --- a/arch/risc-v/src/common/riscv_exception_common.S +++ b/arch/risc-v/src/common/riscv_exception_common.S @@ -231,7 +231,11 @@ return_from_exception: load_ctx sp +#ifdef CONFIG_ARCH_KERNEL_STACK REGLOAD sp, REG_SP(sp) /* restore original sp */ +#else + addi sp, sp, XCPTCONTEXT_SIZE +#endif /* Return from exception */