From 3b7528c89c595d4d3a24d0d9915321d7a8eac6ac Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 28 Jan 2009 20:35:16 +0000 Subject: Use a different value for the initial control word for the FPU state for 32-bit processes. The value matches the initial setting used by FreeBSD/i386. Otherwise, 32-bit binaries using floating point would use a slightly different initial state when run on FreeBSD/amd64. MFC after: 1 week --- sys/amd64/amd64/fpu.c | 5 +++++ sys/amd64/include/fpu.h | 1 + 2 files changed, 6 insertions(+) (limited to 'sys/amd64') diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 513b36b..d051713 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -391,6 +391,7 @@ fpudna() { struct pcb *pcb; register_t s; + u_short control; if (PCPU_GET(fpcurthread) == curthread) { printf("fpudna: fpcurthread == curthread %d times\n", @@ -421,6 +422,10 @@ fpudna() * explicitly load sanitized registers. */ fxrstor(&fpu_cleanstate); + if (pcb->pcb_flags & PCB_32BIT) { + control = __INITIAL_FPUCW_I386__; + fldcw(&control); + } pcb->pcb_flags |= PCB_FPUINITDONE; } else fxrstor(&pcb->pcb_save); diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h index 88932ed..9b99fd8 100644 --- a/sys/amd64/include/fpu.h +++ b/sys/amd64/include/fpu.h @@ -92,6 +92,7 @@ struct savefpu { * SSE2 based math. For FreeBSD/amd64, we go with the default settings. */ #define __INITIAL_FPUCW__ 0x037F +#define __INITIAL_FPUCW_I386__ 0x127F #define __INITIAL_MXCSR__ 0x1F80 #define __INITIAL_MXCSR_MASK__ 0xFFBF -- cgit v1.1