Skip to content

Commit

Permalink
runtime: remove map stack version handling for openbsd
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Aaron Bieber <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
  • Loading branch information
4a6f656c committed Nov 2, 2023
1 parent 6a7ef36 commit 4e896d1
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/runtime/os_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}

Expand All @@ -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")
Expand Down

0 comments on commit 4e896d1

Please sign in to comment.