Skip to content

Commit

Permalink
riscv-v/fork.S: Fix clobbering of s0 in fork()
Browse files Browse the repository at this point in the history
Value of s0 (callee-saved) must be preserved through the call, use
a0 (caller-saved) to calculate the original SP instead.
  • Loading branch information
pussuw authored and xiaoxiang781216 committed May 30, 2024
1 parent 275ec71 commit c1f3245
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/risc-v/src/common/fork.S
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ up_fork:
REGSTORE s0, FORK_S0_OFFSET(sp)
#endif

addi s0, sp, FORK_SIZEOF
REGSTORE s0, FORK_SP_OFFSET(sp) /* original SP */
addi a0, sp, FORK_SIZEOF
REGSTORE a0, FORK_SP_OFFSET(sp) /* original SP */
REGSTORE x1, FORK_RA_OFFSET(sp) /* return address */

/* Floating point registers */
Expand Down

0 comments on commit c1f3245

Please sign in to comment.