This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new c1f3245167 riscv-v/fork.S: Fix clobbering of s0 in fork()
c1f3245167 is described below

commit c1f32451679f3f73170f23b0846e12dacff1da60
Author: Ville Juven <[email protected]>
AuthorDate: Thu May 30 15:11:24 2024 +0300

    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.
---
 arch/risc-v/src/common/fork.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/risc-v/src/common/fork.S b/arch/risc-v/src/common/fork.S
index 37d4bc9cfe..9070e93b21 100644
--- a/arch/risc-v/src/common/fork.S
+++ b/arch/risc-v/src/common/fork.S
@@ -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 */

Reply via email to