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

xiaoxiang781216 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 37709a3995f arch/tricore: Fix vfork lower context restore
37709a3995f is described below

commit 37709a3995f2da0ab055e7014cab73b94a6482b6
Author: zhangyu117 <[email protected]>
AuthorDate: Fri Nov 20 20:34:57 2026 +0800

    arch/tricore: Fix vfork lower context restore
    
    rslcx restores D0-D7 and A2-A7, but its inline asm only declared a
    memory clobber. GCC inlined tricore_fork() and kept the CSA address
    mask in D3 across rslcx. The restored D3 was then used to walk the
    parent CSA chain, corrupting the child context and causing a call
    stack underflow during vfork.
    
    Declare all registers restored by rslcx as clobbers so the compiler
    does not assume that lower-context values survive the instruction.
    The rslcx position, return-value handling and CSA/stack operations
    remain unchanged.
    
    Signed-off-by: zhangyu117 <[email protected]>
---
 arch/tricore/src/common/tricore_fork.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/tricore/src/common/tricore_fork.c 
b/arch/tricore/src/common/tricore_fork.c
index 546dabf81e0..a577d89cbf9 100644
--- a/arch/tricore/src/common/tricore_fork.c
+++ b/arch/tricore/src/common/tricore_fork.c
@@ -256,7 +256,11 @@ pid_t up_fork(bool vfork)
    * case trap because of csa_addr[0] inconsistent value
    */
 
-  __asm__ __volatile__ ("rslcx" ::: "memory");
+  __asm__ __volatile__ ("rslcx" ::: "memory",
+                        "d0", "d1", "d2", "d3",
+                        "d4", "d5", "d6", "d7",
+                        "a2", "a3", "a4", "a5",
+                        "a6", "a7");
 
   sinfo("lcsa=0x%zX pucsa=%p recalc=%p\n",
         context.lcsa[TRICORE_CSA_NEXT], context.pucsa,

Reply via email to