]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: remove map stack version handling for openbsd
authorJoel Sing <joel@sing.id.au>
Mon, 30 Oct 2023 13:25:52 +0000 (00:25 +1100)
committerJoel Sing <joel@sing.id.au>
Thu, 2 Nov 2023 08:05:10 +0000 (08:05 +0000)
OpenBSD 6.3 is more than five years old and has not been supported for
the last four years (only 7.3 and 7.4 are currently supported). As such,
remove special handling of MAP_STACK for 6.3 and earlier.

Change-Id: I1086c910bbcade7fb3938bb1226813212794b587
Reviewed-on: https://go-review.googlesource.com/c/go/+/538458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Aaron Bieber <aaron@bolddaemon.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

src/runtime/os_openbsd.go

index dd7436885da809ff24d62f3657346a105a0824c4..c3204ec38126aeca115fa4b7ee106352caf3d08a 100644 (file)
@@ -147,7 +147,6 @@ func semawakeup(mp *m) {
 func osinit() {
        ncpu = getncpu()
        physPageSize = getPageSize()
-       haveMapStack = getOSRev() >= 201805 // OpenBSD 6.3
 }
 
 var urandom_dev = []byte("/dev/urandom\x00")
@@ -264,15 +263,7 @@ func validSIGPROF(mp *m, c *sigctxt) bool {
        return true
 }
 
-var haveMapStack = false
-
 func osStackAlloc(s *mspan) {
-       // OpenBSD 6.4+ requires that stacks be mapped with MAP_STACK.
-       // It will check this on entry to system calls, traps, and
-       // when switching to the alternate system stack.
-       //
-       // This function is called before s is used for any data, so
-       // it's safe to simply re-map it.
        osStackRemap(s, _MAP_STACK)
 }
 
@@ -282,13 +273,6 @@ func osStackFree(s *mspan) {
 }
 
 func osStackRemap(s *mspan, flags int32) {
-       if !haveMapStack {
-               // OpenBSD prior to 6.3 did not have MAP_STACK and so
-               // the following mmap will fail. But it also didn't
-               // require MAP_STACK (obviously), so there's no need
-               // to do the mmap.
-               return
-       }
        a, err := mmap(unsafe.Pointer(s.base()), s.npages*pageSize, _PROT_READ|_PROT_WRITE, _MAP_PRIVATE|_MAP_ANON|_MAP_FIXED|flags, -1, 0)
        if err != 0 || uintptr(a) != s.base() {
                print("runtime: remapping stack memory ", hex(s.base()), " ", s.npages*pageSize, " a=", a, " err=", err, "\n")