aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2023-01-18 09:30:36 +0000
committerAndrew Turner <andrew@FreeBSD.org>2023-01-18 09:31:50 +0000
commita85cf421d1bfec7e753bfee781355785b00d89d4 (patch)
treee2196e0392d5818c0438e948188851c073e8f7b2
parent61f5462fde6c38c1f4f5c34a05fab506b6869375 (diff)
downloadsrc-a85cf421d1bfec7e753bfee781355785b00d89d4.tar.gz
src-a85cf421d1bfec7e753bfee781355785b00d89d4.zip
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
-rw-r--r--sys/arm64/arm64/exec_machdep.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c
index 258cb5d26b13..27ee2f80858d 100644
--- a/sys/arm64/arm64/exec_machdep.c
+++ b/sys/arm64/arm64/exec_machdep.c
@@ -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
}