svn commit: r294311 - head/sys/amd64/amd64

Konstantin Belousov kib at FreeBSD.org
Tue Jan 19 08:04:04 UTC 2016


Author: kib
Date: Tue Jan 19 08:04:02 2016
New Revision: 294311
URL: https://svnweb.freebsd.org/changeset/base/294311

Log:
  Clear whole XMM register file instead of only XMM0.  Also clear x87
  registers.  This brings amd64 on par with i386, providing consistent
  initial FPU state.
  
  Note that we do not clear any extended state, at least because kernel
  does not understand extended state structure and consequences of zero
  overwrite after fninit()/fpusave().
  
  Submitted by:	joss.upton at yahoo.com
  PR:	206370
  MFC after:	2 weeks

Modified:
  head/sys/amd64/amd64/fpu.c

Modified: head/sys/amd64/amd64/fpu.c
==============================================================================
--- head/sys/amd64/amd64/fpu.c	Tue Jan 19 06:07:39 2016	(r294310)
+++ head/sys/amd64/amd64/fpu.c	Tue Jan 19 08:04:02 2016	(r294311)
@@ -318,13 +318,15 @@ fpuinitstate(void *arg __unused)
 		cpu_mxcsr_mask = 0xFFBF;
 
 	/*
-	 * The fninit instruction does not modify XMM registers.  The
-	 * fpusave call dumped the garbage contained in the registers
-	 * after reset to the initial state saved.  Clear XMM
-	 * registers file image to make the startup program state and
-	 * signal handler XMM register content predictable.
+	 * The fninit instruction does not modify XMM registers or x87
+	 * registers (MM/ST).  The fpusave call dumped the garbage
+	 * contained in the registers after reset to the initial state
+	 * saved.  Clear XMM and x87 registers file image to make the
+	 * startup program state and signal handler XMM/x87 register
+	 * content predictable.
 	 */
-	bzero(&fpu_initialstate->sv_xmm[0], sizeof(struct xmmacc));
+	bzero(fpu_initialstate->sv_fp, sizeof(fpu_initialstate->sv_fp));
+	bzero(fpu_initialstate->sv_xmm, sizeof(fpu_initialstate->sv_xmm));
 
 	/*
 	 * Create a table describing the layout of the CPU Extended


More information about the svn-src-head mailing list