Skip to content

Commit c1f3245

Browse files
pussuwxiaoxiang781216
authored andcommitted
riscv-v/fork.S: Fix clobbering of s0 in fork()
Value of s0 (callee-saved) must be preserved through the call, use a0 (caller-saved) to calculate the original SP instead.
1 parent 275ec71 commit c1f3245

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/risc-v/src/common/fork.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ up_fork:
117117
REGSTORE s0, FORK_S0_OFFSET(sp)
118118
#endif
119119

120-
addi s0, sp, FORK_SIZEOF
121-
REGSTORE s0, FORK_SP_OFFSET(sp) /* original SP */
120+
addi a0, sp, FORK_SIZEOF
121+
REGSTORE a0, FORK_SP_OFFSET(sp) /* original SP */
122122
REGSTORE x1, FORK_RA_OFFSET(sp) /* return address */
123123

124124
/* Floating point registers */

0 commit comments

Comments
 (0)