diff --git a/src/pkg/runtime/os_plan9.h b/src/pkg/runtime/os_plan9.h index ce746b3f3d1..7002897efa3 100644 --- a/src/pkg/runtime/os_plan9.h +++ b/src/pkg/runtime/os_plan9.h @@ -18,6 +18,7 @@ int32 runtime·plan9_semrelease(uint32 *addr, int32 count); int32 runtime·notify(void (*fn)(void*, byte*)); int32 runtime·noted(int32); void runtime·gonote(void*, byte*); +void runtime·setfpmasks(void); /* open */ enum diff --git a/src/pkg/runtime/sys_plan9_386.s b/src/pkg/runtime/sys_plan9_386.s index cdcf0b27982..1b4d52be1f2 100644 --- a/src/pkg/runtime/sys_plan9_386.s +++ b/src/pkg/runtime/sys_plan9_386.s @@ -110,3 +110,7 @@ TEXT runtime·rfork(SB),7,$0 CALL SI // fn() CALL runtime·exit(SB) RET + +// Only used by the 64-bit runtime. +TEXT runtime·setfpmasks(SB),7,$0 + RET diff --git a/src/pkg/runtime/sys_plan9_amd64.s b/src/pkg/runtime/sys_plan9_amd64.s index f376620924c..d2ccfb23287 100644 --- a/src/pkg/runtime/sys_plan9_amd64.s +++ b/src/pkg/runtime/sys_plan9_amd64.s @@ -121,3 +121,12 @@ TEXT runtime·rfork(SB),7,$0 // This is needed by asm_amd64.s TEXT runtime·settls(SB),7,$0 RET + +TEXT runtime·setfpmasks(SB),7,$8 + STMXCSR 0(SP) + MOVL 0(SP), AX + ANDL $~0x3F, AX + ORL $(0x3F<<7), AX + MOVL AX, 0(SP) + LDMXCSR 0(SP) + RET diff --git a/src/pkg/runtime/thread_plan9.c b/src/pkg/runtime/thread_plan9.c index 5098864680b..6fd1ba72251 100644 --- a/src/pkg/runtime/thread_plan9.c +++ b/src/pkg/runtime/thread_plan9.c @@ -14,6 +14,9 @@ int32 runtime·postnote(int32, int8*); void runtime·minit(void) { + // Mask all SSE floating-point exceptions + // when running on the 64-bit kernel. + runtime·setfpmasks(); } static int32