Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jul 2015 17:27:44 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285014 - head/sys/arm64/arm64
Message-ID:  <201507011727.t61HRiKB047198@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Wed Jul  1 17:27:44 2015
New Revision: 285014
URL: https://svnweb.freebsd.org/changeset/base/285014

Log:
  Fix the logic for when to restore the VFP registers. It should restore
  them when a different thread last used them, or when the thread was last
  run on a different cpu.
  
  Obtained from:	ABT Systems Ltd
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/vfp.c

Modified: head/sys/arm64/arm64/vfp.c
==============================================================================
--- head/sys/arm64/arm64/vfp.c	Wed Jul  1 17:19:51 2015	(r285013)
+++ head/sys/arm64/arm64/vfp.c	Wed Jul  1 17:27:44 2015	(r285014)
@@ -95,6 +95,9 @@ vfp_save_state(struct thread *td)
 	 */
 	cpacr = READ_SPECIALREG(cpacr_el1);
 	if ((cpacr & CPACR_FPEN_MASK) == CPACR_FPEN_TRAP_NONE) {
+		KASSERT(PCPU_GET(fpcurthread) == td,
+		    ("Storing an invalid VFP state"));
+
 		vfp_state = td->td_pcb->pcb_vfp;
 		__asm __volatile(
 		    "mrs	%0, fpcr		\n"
@@ -142,7 +145,12 @@ vfp_restore_state(void)
 
 	vfp_enable();
 
-	if (PCPU_GET(fpcurthread) != curthread && cpu != curpcb->pcb_vfpcpu) {
+	/*
+	 * If the previous thread on this cpu to use the VFP was not the
+	 * current threas, or the current thread last used it on a different
+	 * cpu we need to restore the old state.
+	 */
+	if (PCPU_GET(fpcurthread) != curthread || cpu != curpcb->pcb_vfpcpu) {
 
 		vfp_state = curthread->td_pcb->pcb_vfp;
 		fpcr = curthread->td_pcb->pcb_fpcr;



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