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 jerpelea committed Jul 24, 2024
1 parent 32d4131 commit 59bfed0
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 59bfed0

Please sign in to comment.