]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mlock top of signal stack on both amd64 and 386
authorAustin Clements <austin@google.com>
Mon, 9 Dec 2019 03:24:10 +0000 (22:24 -0500)
committerAustin Clements <austin@google.com>
Mon, 9 Dec 2019 14:41:00 +0000 (14:41 +0000)
CL 209899 worked around an issue that corrupts vector registers in
recent versions of the Linux kernel by mlocking the top page of every
signal stack on amd64. However, the underlying issue also affects the
XMM registers on 386. This CL applies the mlock fix to both amd64 and
386.

Fixes #35777 (again).

Change-Id: I9886f2dc4c23625421296bd5518d5fd3288bfe48
Reviewed-on: https://go-review.googlesource.com/c/go/+/210345
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/defs_linux_386.go
src/runtime/os_linux_386.go [deleted file]
src/runtime/os_linux_x86.go [moved from src/runtime/os_linux_amd64.go with 98% similarity]
src/runtime/sys_linux_386.s

index ba349845cfd3d66d5b5e973825e1350c07b584c7..ba5ef18e02b0a089ba8da312380a001abf11ea62 100644 (file)
@@ -227,3 +227,14 @@ type sockaddr_un struct {
        family uint16
        path   [108]byte
 }
+
+const __NEW_UTS_LEN = 64
+
+type new_utsname struct {
+       sysname    [__NEW_UTS_LEN + 1]byte
+       nodename   [__NEW_UTS_LEN + 1]byte
+       release    [__NEW_UTS_LEN + 1]byte
+       version    [__NEW_UTS_LEN + 1]byte
+       machine    [__NEW_UTS_LEN + 1]byte
+       domainname [__NEW_UTS_LEN + 1]byte
+}
diff --git a/src/runtime/os_linux_386.go b/src/runtime/os_linux_386.go
deleted file mode 100644 (file)
index 9be88a5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-func osArchInit() {}
similarity index 98%
rename from src/runtime/os_linux_amd64.go
rename to src/runtime/os_linux_x86.go
index cbfcf2e40ab42e63f81c8e0a7e5c637c4988987c..61c51f23274d7be25f8b716ab7cb30d4a948389b 100644 (file)
@@ -2,6 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build linux
+// +build 386 amd64
+
 package runtime
 
 //go:noescape
index 373d9d3bc2bef93bd9b39488b3e39bf98a66fc50..8e05acf89485a029d4abe98679eb56722adbb5e7 100644 (file)
@@ -39,6 +39,8 @@
 #define SYS_socketcall         102
 #define SYS_setittimer         104
 #define SYS_clone              120
+#define SYS_uname              122
+#define SYS_mlock              150
 #define SYS_sched_yield        158
 #define SYS_nanosleep          162
 #define SYS_rt_sigreturn       173
@@ -776,3 +778,20 @@ TEXT runtime·sbrk0(SB),NOSPLIT,$0-4
        INVOKE_SYSCALL
        MOVL    AX, ret+0(FP)
        RET
+
+// func uname(utsname *new_utsname) int
+TEXT ·uname(SB),NOSPLIT,$0-8
+       MOVL    $SYS_uname, AX
+       MOVL    utsname+0(FP), BX
+       INVOKE_SYSCALL
+       MOVL    AX, ret+4(FP)
+       RET
+
+// func mlock(addr, len uintptr) int
+TEXT ·mlock(SB),NOSPLIT,$0-12
+       MOVL    $SYS_mlock, AX
+       MOVL    addr+0(FP), BX
+       MOVL    len+4(FP), CX
+       INVOKE_SYSCALL
+       MOVL    AX, ret+8(FP)
+       RET