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

(nuttx) branch master updated: arm64_fpu: Remove fpu_regs from the TCB

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 30aa947b95 arm64_fpu: Remove fpu_regs from the TCB
30aa947b95 is described below

commit 30aa947b95b98c479b9ac8f755ff438aeab94655
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Wed Oct 2 10:16:47 2024 +0300

    arm64_fpu: Remove fpu_regs from the TCB
    
    Since FPU is now always saved into the current process stack location
    upon exception entry, there is no need to keep fpu_regs (or saved_fpu_regs)
    in the TCB.
---
 arch/arm64/include/irq.h                |  5 -----
 arch/arm64/src/common/arm64_copystate.c |  5 +++--
 arch/arm64/src/common/arm64_fork.c      | 17 ++++-------------
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/arch/arm64/include/irq.h b/arch/arm64/include/irq.h
index 1f8b45a7b7..b4ce09ce28 100644
--- a/arch/arm64/include/irq.h
+++ b/arch/arm64/include/irq.h
@@ -268,11 +268,6 @@ struct xcptcontext
 
   uint64_t *saved_reg;
 
-#ifdef CONFIG_ARCH_FPU
-  uint64_t *fpu_regs;
-  uint64_t *saved_fpu_regs;
-#endif
-
   /* Extra fault address register saved for common paging logic.  In the
    * case of the pre-fetch abort, this value is the same as regs[REG_ELR];
    * For the case of the data abort, this value is the value of the fault
diff --git a/arch/arm64/src/common/arm64_copystate.c b/arch/arm64/src/common/arm64_copystate.c
index fbb04f2c73..4d06f2ddaf 100644
--- a/arch/arm64/src/common/arm64_copystate.c
+++ b/arch/arm64/src/common/arm64_copystate.c
@@ -102,14 +102,15 @@ int arm64_syscall_save_context(uint64_t * regs)
 
 #ifdef CONFIG_ARCH_FPU
   rtcb      = (struct tcb_s *)f_regs->regs[REG_X1];
-  p_save += XCPTCONTEXT_GP_SIZE;
+  p_save += XCPTCONTEXT_GP_REGS;
   if (rtcb_cur == rtcb)
     {
       arch_save_fpucontext(p_save);
     }
   else
     {
-      p_fpu = (uint64_t *)rtcb->xcp.fpu_regs;
+      p_fpu = (uint64_t *)rtcb->xcp.regs;
+      p_fpu += XCPTCONTEXT_GP_REGS;
       for (i = 0; i < XCPTCONTEXT_FPU_REGS; i++)
         {
           p_save[i] = p_fpu[i];
diff --git a/arch/arm64/src/common/arm64_fork.c b/arch/arm64/src/common/arm64_fork.c
index faddc4d4d3..a23600950c 100644
--- a/arch/arm64/src/common/arm64_fork.c
+++ b/arch/arm64/src/common/arm64_fork.c
@@ -130,9 +130,6 @@ pid_t arm64_fork(const struct fork_s *context)
   uint64_t stackutil;
   char   *stack_ptr;
   struct regs_context  *pforkctx;
-#ifdef CONFIG_ARCH_FPU
-  struct fpu_reg       *pfpuctx;
-#endif
 
   /* Allocate and initialize a TCB for the child task. */
 
@@ -189,16 +186,6 @@ pid_t arm64_fork(const struct fork_s *context)
 
   stack_ptr = (char *)newsp;
 
-#ifdef CONFIG_ARCH_FPU
-  pfpuctx      = STACK_PTR_TO_FRAME(struct fpu_reg, stack_ptr);
-
-  child->cmn.xcp.fpu_regs = (uint64_t *)pfpuctx;
-  memcpy(pfpuctx, &context->fpu, sizeof(struct fpu_reg));
-
-  stack_ptr  = (char *)pfpuctx;
-
-#endif
-
   pforkctx      = STACK_PTR_TO_FRAME(struct regs_context, stack_ptr);
 
   pforkctx->regs[REG_X0]   = 0;
@@ -247,6 +234,10 @@ pid_t arm64_fork(const struct fork_s *context)
 
   child->cmn.xcp.regs = (uint64_t *)pforkctx;
 
+#ifdef CONFIG_ARCH_FPU
+  memcpy(&pforkctx->fpu_regs, &context->fpu, sizeof(struct fpu_reg));
+#endif
+
   /* And, finally, start the child task.  On a failure, nxtask_start_fork()
    * will discard the TCB by calling nxtask_abort_fork().
    */