git: 622875663c82 - stable/13 - Always store the arm64 VFP context
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 May 2023 15:46:00 UTC
The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=622875663c82c4493da3cd27870f0a3dcb21c4fb commit 622875663c82c4493da3cd27870f0a3dcb21c4fb Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2023-01-18 09:30:32 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2023-05-15 10:54:40 +0000 Always store the arm64 VFP context If a thread enters a kernel FP context the PCB_FP_STARTED may be unset when calling get_fpcontext even if the VFP unit has been used by the current thread. Reduce the use of this flag to just decide when to store the VFP state. While here add an assert to check the assumption that the passed in thread is the current thread and remove the unneeded critical section. The latter is unneeded as the only place we would need it is in vfp_save_state and this already has a critical section when needed. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D37998 (cherry picked from commit 61f5462fde6c38c1f4f5c34a05fab506b6869375) --- sys/arm64/arm64/exec_machdep.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c index a55048461682..fab0ee2ba993 100644 --- a/sys/arm64/arm64/exec_machdep.c +++ b/sys/arm64/arm64/exec_machdep.c @@ -482,30 +482,27 @@ get_fpcontext(struct thread *td, mcontext_t *mcp) #ifdef VFP struct pcb *curpcb; - critical_enter(); + MPASS(td == curthread); curpcb = curthread->td_pcb; - if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) { /* * If we have just been running VFP instructions we will * need to save the state to memcpy it below. */ vfp_save_state(td, curpcb); - - KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, - ("Called get_fpcontext while the kernel is using the VFP")); - KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, - ("Non-userspace FPU flags set in get_fpcontext")); - memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs, - sizeof(mcp->mc_fpregs.fp_q)); - mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr; - mcp->mc_fpregs.fp_sr = curpcb->pcb_fpustate.vfp_fpsr; - mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; - mcp->mc_flags |= _MC_FP_VALID; } - critical_exit(); + KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, + ("Called get_fpcontext while the kernel is using the VFP")); + KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, + ("Non-userspace FPU flags set in get_fpcontext")); + memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs, + sizeof(mcp->mc_fpregs.fp_q)); + mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr; + mcp->mc_fpregs.fp_sr = curpcb->pcb_fpustate.vfp_fpsr; + mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; + mcp->mc_flags |= _MC_FP_VALID; #endif }