Skip to content

Commit

Permalink
arm64_fpu: Remove fpu_regs from the TCB
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pussuw committed Oct 2, 2024
1 parent 24c931c commit a51641b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
5 changes: 0 additions & 5 deletions arch/arm64/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions arch/arm64/src/common/arm64_copystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
17 changes: 4 additions & 13 deletions arch/arm64/src/common/arm64_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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().
*/
Expand Down

0 comments on commit a51641b

Please sign in to comment.