Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jan 2023 09:39:49 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 61f5462fde6c - main - Always store the arm64 VFP context
Message-ID:  <202301180939.30I9dnU5053076@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=61f5462fde6c38c1f4f5c34a05fab506b6869375

commit 61f5462fde6c38c1f4f5c34a05fab506b6869375
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-01-18 09:30:32 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-01-18 09:31:45 +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
---
 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 12c23149ec7f..258cb5d26b13 100644
--- a/sys/arm64/arm64/exec_machdep.c
+++ b/sys/arm64/arm64/exec_machdep.c
@@ -489,30 +489,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
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301180939.30I9dnU5053076>