summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-01-19 08:04:02 +0000
committerkib <kib@FreeBSD.org>2016-01-19 08:04:02 +0000
commitbee088bb002995f262c87caa5031f31856cc73a6 (patch)
treeeb4209dc3e7180efcc0a30e5cfaf68e9da769ea3 /sys/amd64
parentd365b696370c6679f5167321df50c03ca9497e1a (diff)
downloadFreeBSD-src-bee088bb002995f262c87caa5031f31856cc73a6.zip
FreeBSD-src-bee088bb002995f262c87caa5031f31856cc73a6.tar.gz
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@yahoo.com PR: 206370 MFC after: 2 weeks
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/fpu.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index 562951e..91ceab2 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -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
OpenPOWER on IntegriCloud