aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_netbsd.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-03-29 17:38:20 -0400
committerAustin Clements <austin@google.com>2021-04-01 00:51:26 +0000
commitec721d92bf35cd47543acf6792acd474fdd39446 (patch)
tree9a8c2a9df49cdfb2b9b6e0364c086ebfdfa0e962 /src/runtime/os_netbsd.go
parent1f29e69bad3673aa4f9d1c4d1016170b9ced634a (diff)
downloadgo-ec721d92bf35cd47543acf6792acd474fdd39446.tar.gz
go-ec721d92bf35cd47543acf6792acd474fdd39446.zip
runtime: fix uses of ABIInternal PCs in assembly
The covers three kinds of uses: 1. Calls of closures from assembly. These are always ABIInternal calls without wrappers. I went through every indirect call in the runtime and I think mcall is the only case of assembly calling a Go closure in a way that's affected by ABIInternal. systemstack also calls a closure, but it takes no arguments. 2. Calls of Go functions that expect raw ABIInternal pointers. I also only found one of these: callbackasm1 -> cgocallback on Windows. These are trickier to find, though. 3. Finally, I found one case on NetBSD where new OS threads were directly calling the Go runtime entry-point from assembly via a PC, rather than going through a wrapper. This meant new threads may not have special registers set up. In this case, a change on all other OSes had already forced new thread entry to go through an ABI wrapper, so I just caught NetBSD up with that change. With this change, I'm able to run a "hello world" with GOEXPERIMENT=regabi,regabiargs. For #40724. Change-Id: I2a6d0e530c4fd4edf13484d923891c6160d683aa Reviewed-on: https://go-review.googlesource.com/c/go/+/305669 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime/os_netbsd.go')
-rw-r--r--src/runtime/os_netbsd.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/os_netbsd.go b/src/runtime/os_netbsd.go
index 0328fa57ae..6fbb3aa694 100644
--- a/src/runtime/os_netbsd.go
+++ b/src/runtime/os_netbsd.go
@@ -228,7 +228,11 @@ func newosproc(mp *m) {
}
}
-// netbsdMStart is the function call that starts executing a newly
+// mstart is the entry-point for new Ms.
+// It is written in assembly, uses ABI0, is marked TOPFRAME, and calls netbsdMstart0.
+func netbsdMstart()
+
+// netbsdMStart0 is the function call that starts executing a newly
// created thread. On NetBSD, a new thread inherits the signal stack
// of the creating thread. That confuses minit, so we remove that
// signal stack here before calling the regular mstart. It's a bit
@@ -236,10 +240,10 @@ func newosproc(mp *m) {
// it's a simple change that keeps NetBSD working like other OS's.
// At this point all signals are blocked, so there is no race.
//go:nosplit
-func netbsdMstart() {
+func netbsdMstart0() {
st := stackt{ss_flags: _SS_DISABLE}
sigaltstack(&st, nil)
- mstart()
+ mstart0()
}
func osinit() {