1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-07 13:14:51 +00:00

Reduce an arm64 VFP critical section

In set_fpcontext we only need a critical section around vfp_discard.
The remainder of the code can run without it.

While here add an assert to check the passed in thread is the
current thread as the code already this.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D38000
This commit is contained in:
Andrew Turner 2023-01-18 09:30:36 +00:00
parent 61f5462fde
commit a85cf421d1

View File

@ -519,8 +519,7 @@ set_fpcontext(struct thread *td, mcontext_t *mcp)
#ifdef VFP
struct pcb *curpcb;
critical_enter();
MPASS(td == curthread);
if ((mcp->mc_flags & _MC_FP_VALID) != 0) {
curpcb = curthread->td_pcb;
@ -528,7 +527,9 @@ set_fpcontext(struct thread *td, mcontext_t *mcp)
* Discard any vfp state for the current thread, we
* are about to override it.
*/
critical_enter();
vfp_discard(td);
critical_exit();
KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate,
("Called set_fpcontext while the kernel is using the VFP"));
@ -538,8 +539,6 @@ set_fpcontext(struct thread *td, mcontext_t *mcp)
curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr;
curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK;
}
critical_exit();
#endif
}