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 <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-07-16 14:41:04 +08:00 committed by Xiang Xiao
parent 08c4686f47
commit d6c67c555f

View File

@ -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 */