Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Apr 2015 14:18:26 +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: r281554 - head/sys/arm64/arm64
Message-ID:  <201504151418.t3FEIQrs095983@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Wed Apr 15 14:18:25 2015
New Revision: 281554
URL: https://svnweb.freebsd.org/changeset/base/281554

Log:
  Ensure the userland thread and floating-point state has been saved before
  copying the pcb. These values may have been changed just before the call
  to fork and without a call to cpu_switch, where they would have been saved.
  
  Sponsored by:	The FreeBSD Foundation

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

Modified: head/sys/arm64/arm64/vm_machdep.c
==============================================================================
--- head/sys/arm64/arm64/vm_machdep.c	Wed Apr 15 11:48:41 2015	(r281553)
+++ head/sys/arm64/arm64/vm_machdep.c	Wed Apr 15 14:18:25 2015	(r281554)
@@ -47,6 +47,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/pcb.h>
 #include <machine/frame.h>
 
+#ifdef VFP
+#include <machine/vfp.h>
+#endif
+
 /*
  * Finish a fork operation, with process p2 nearly set up.
  * Copy and update the pcb, set up the stack so that the child
@@ -61,6 +65,19 @@ cpu_fork(struct thread *td1, struct proc
 	if ((flags & RFPROC) == 0)
 		return;
 
+	if (td1 == curthread) {
+		/*
+		 * Save the tpidr_el0 and the vfp state, these normally happen
+		 * in cpu_switch, but if userland changes these then forks
+		 * this may not have happened.
+		 */
+		td1->td_pcb->pcb_tpidr_el0 = READ_SPECIALREG(tpidr_el0);
+#ifdef VFP
+		if ((td1->td_pcb->pcb_fpflags & PCB_FP_STARTED) != 0)
+			vfp_save_state(td1);
+#endif
+	}
+
 	pcb2 = (struct pcb *)(td2->td_kstack +
 	    td2->td_kstack_pages * PAGE_SIZE) - 1;
 



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