Skip to content

Commit

Permalink
riscv/trap: fix sp restore logic
Browse files Browse the repository at this point in the history
This fixes stack pointer restore logic to avoid parent stack corruption
by forked child in PROTECTED build.

Signed-off-by: Yanfeng Liu <[email protected]>
  • Loading branch information
yf13 authored and xiaoxiang781216 committed Jul 17, 2024
1 parent 08c4686 commit d6c67c5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/risc-v/src/common/riscv_exception_common.S
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down

0 comments on commit d6c67c5

Please sign in to comment.