You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/03/23 10:08:49 UTC

[incubator-nuttx] 02/03: arm/vfork: update the SP to stack top

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

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

commit a770ff20174c4d8fdcf60f8147f768d65a367292
Author: chao.an <an...@xiaomi.com>
AuthorDate: Fri Mar 18 21:54:01 2022 +0800

    arm/vfork: update the SP to stack top
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 arch/arm/src/common/arm_vfork.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/common/arm_vfork.c b/arch/arm/src/common/arm_vfork.c
index f265aaf..edad4cc 100644
--- a/arch/arm/src/common/arm_vfork.c
+++ b/arch/arm/src/common/arm_vfork.c
@@ -137,10 +137,18 @@ pid_t up_vfork(const struct vfork_s *context)
    * effort is overkill.
    */
 
-  newtop = STACK_ALIGN_DOWN((uint32_t)child->cmn.stack_base_ptr +
-                                      child->cmn.adj_stack_size -
-                                      XCPTCONTEXT_SIZE);
+  newtop = (uint32_t)child->cmn.stack_base_ptr +
+                     child->cmn.adj_stack_size;
+
   newsp = newtop - stackutil;
+
+  /* Move the register context to newtop. */
+
+  memcpy((void *)(newsp - XCPTCONTEXT_SIZE),
+         child->cmn.xcp.regs, XCPTCONTEXT_SIZE);
+
+  child->cmn.xcp.regs = (void *)(newsp - XCPTCONTEXT_SIZE);
+
   memcpy((void *)newsp, (const void *)context->sp, stackutil);
 
   /* Was there a frame pointer in place before? */