summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-10-26 20:30:24 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-10-26 20:30:24 +0000
commitde979dcf7ac047a8b1d687912e3f2849ae6b127d (patch)
tree671a6fa9d99a13ddee35565d1012b3169e1ef9a9 /sys
parentc16d88bf4bfc8e8526f12a85971a6f35865648c5 (diff)
Load %mxcsr when initializing the FPU on machines that support SSE.
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/isa/npx.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c
index 3f12236881b..5cf28f5d05b 100644
--- a/sys/arch/i386/isa/npx.c
+++ b/sys/arch/i386/isa/npx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npx.c,v 1.45 2009/10/03 21:51:01 kettenis Exp $ */
+/* $OpenBSD: npx.c,v 1.46 2009/10/26 20:30:23 kettenis Exp $ */
/* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
#if 0
@@ -605,6 +605,7 @@ x86fpflags_to_siginfo(u_int32_t flags)
int
npxdna_xmm(struct cpu_info *ci)
{
+ union savefpu *addr;
struct proc *p;
int s;
@@ -661,8 +662,12 @@ npxdna_xmm(struct cpu_info *ci)
splx(s);
uvmexp.fpswtch++;
+ addr = &p->p_addr->u_pcb.pcb_savefpu;
+
if ((p->p_md.md_flags & MDP_USEDFPU) == 0) {
- fldcw(&p->p_addr->u_pcb.pcb_savefpu.sv_xmm.sv_env.en_cw);
+ fldcw(&addr->sv_xmm.sv_env.en_cw);
+ if (i386_has_sse || i386_has_sse2)
+ ldmxcsr(&addr->sv_xmm.sv_env.en_mxcsr);
p->p_md.md_flags |= MDP_USEDFPU;
} else {
static double zero = 0.0;
@@ -673,7 +678,7 @@ npxdna_xmm(struct cpu_info *ci)
*/
fnclex();
__asm __volatile("ffree %%st(7)\n\tfld %0" : : "m" (zero));
- fxrstor(&p->p_addr->u_pcb.pcb_savefpu.sv_xmm);
+ fxrstor(&addr->sv_xmm);
}
return (1);