]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mask SSE exceptions on plan9/amd64
authorAkshat Kumar <seed@mail.nanosouffle.net>
Fri, 5 Oct 2012 20:23:30 +0000 (16:23 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 5 Oct 2012 20:23:30 +0000 (16:23 -0400)
The Go run-time assumes that all SSE floating-point exceptions
are masked so that Go programs are not broken by such invalid
operations. By default, the 64-bit version of the Plan 9 kernel
masks only some SSE floating-point exceptions. Here, we mask
them all on a per-thread basis.

R=rsc, rminnich, minux.ma
CC=golang-dev
https://golang.org/cl/6592056

src/pkg/runtime/os_plan9.h
src/pkg/runtime/sys_plan9_386.s
src/pkg/runtime/sys_plan9_amd64.s
src/pkg/runtime/thread_plan9.c

index ce746b3f3d147a35e8c5a611e30ac1c8657a739d..7002897efa3f9bf62b0f501f549a1334cea3b365 100644 (file)
@@ -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
index cdcf0b27982c75a119e0212687af5f65d44b4e43..1b4d52be1f243fecee45a92aa82537861e32bef8 100644 (file)
@@ -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
index f376620924c4acfb2760b785ac8804f53f6949a3..d2ccfb2328796d090ac4f80f646b30bc29de77bc 100644 (file)
@@ -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
index 5098864680b28c6ad5d3d284fdb8e7d70a0812e8..6fd1ba72251532fd4fb0f0a358e48db4279584e8 100644 (file)
@@ -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