Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make go-bootstrap work with MAP_STACK.
- Loading branch information
Showing
7 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
lang/go-bootstrap/patches/patch-src_runtime_defs_openbsd_386_h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$OpenBSD: patch-src_runtime_defs_openbsd_386_h,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/defs_openbsd_386.h | ||
--- src/runtime/defs_openbsd_386.h.orig | ||
+++ src/runtime/defs_openbsd_386.h | ||
@@ -14,6 +14,7 @@ enum { | ||
MAP_ANON = 0x1000, | ||
MAP_PRIVATE = 0x2, | ||
MAP_FIXED = 0x10, | ||
+ MAP_STACK = 0x4000, | ||
|
||
MADV_FREE = 0x6, | ||
|
13 changes: 13 additions & 0 deletions
13
lang/go-bootstrap/patches/patch-src_runtime_defs_openbsd_amd64_h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$OpenBSD: patch-src_runtime_defs_openbsd_amd64_h,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/defs_openbsd_amd64.h | ||
--- src/runtime/defs_openbsd_amd64.h.orig | ||
+++ src/runtime/defs_openbsd_amd64.h | ||
@@ -14,6 +14,7 @@ enum { | ||
MAP_ANON = 0x1000, | ||
MAP_PRIVATE = 0x2, | ||
MAP_FIXED = 0x10, | ||
+ MAP_STACK = 0x4000, | ||
|
||
MADV_FREE = 0x6, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$OpenBSD: patch-src_runtime_malloc_h,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/malloc.h | ||
--- src/runtime/malloc.h.orig | ||
+++ src/runtime/malloc.h | ||
@@ -197,6 +197,7 @@ struct MLink | ||
// if accessed. Used only for debugging the runtime. | ||
|
||
void* runtime·sysAlloc(uintptr nbytes, uint64 *stat); | ||
+void runtime·sysMarkStack(void *v, uintptr nbytes); | ||
void runtime·SysFree(void *v, uintptr nbytes, uint64 *stat); | ||
void runtime·SysUnused(void *v, uintptr nbytes); | ||
void runtime·SysUsed(void *v, uintptr nbytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$OpenBSD: patch-src_runtime_mem_openbsd_c,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/mem_openbsd.c | ||
--- src/runtime/mem_openbsd.c.orig | ||
+++ src/runtime/mem_openbsd.c | ||
@@ -27,6 +27,17 @@ runtime·sysAlloc(uintptr n, uint64 *stat) | ||
return v; | ||
} | ||
|
||
+#pragma textflag NOSPLIT | ||
+void | ||
+runtime·sysMarkStack(void *v, uintptr n) | ||
+{ | ||
+ void *p; | ||
+ | ||
+ p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_ANON|MAP_PRIVATE|MAP_STACK, -1, 0); | ||
+ if (p == ((void *)-1) || p != v) | ||
+ runtime·throw("runtime: failed to mark stack"); | ||
+} | ||
+ | ||
void | ||
runtime·SysUnused(void *v, uintptr n) | ||
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$OpenBSD: patch-src_runtime_os_openbsd_c,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/os_openbsd.c | ||
--- src/runtime/os_openbsd.c.orig | ||
+++ src/runtime/os_openbsd.c | ||
@@ -167,7 +167,7 @@ runtime·newosproc(M *mp, void *stk) | ||
|
||
param.tf_tcb = (byte*)&mp->tls[0]; | ||
param.tf_tid = (int32*)&mp->procid; | ||
- param.tf_stack = stk; | ||
+ param.tf_stack = (void*)((uintptr)stk - 8); | ||
|
||
oset = runtime·sigprocmask(SIG_SETMASK, sigset_all); | ||
ret = runtime·tfork(¶m, sizeof(param), mp, mp->g0, runtime·mstart); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
$OpenBSD: patch-src_runtime_stack_c,v 1.1 2018/04/05 17:47:30 jsing Exp $ | ||
|
||
Index: src/runtime/stack.c | ||
--- src/runtime/stack.c.orig | ||
+++ src/runtime/stack.c | ||
@@ -67,6 +67,7 @@ poolalloc(uint8 order) | ||
s = runtime·MHeap_AllocStack(&runtime·mheap, StackCacheSize >> PageShift); | ||
if(s == nil) | ||
runtime·throw("out of memory"); | ||
+ runtime·sysMarkStack((void *)(s->start << PageShift), s->npages << PageShift); | ||
if(s->ref != 0) | ||
runtime·throw("bad ref"); | ||
if(s->freelist != nil) | ||
@@ -246,6 +247,7 @@ runtime·stackalloc(uint32 n) | ||
s = runtime·MHeap_AllocStack(&runtime·mheap, ROUND(n, PageSize) >> PageShift); | ||
if(s == nil) | ||
runtime·throw("out of memory"); | ||
+ runtime·sysMarkStack((void *)(s->start << PageShift), s->npages << PageShift); | ||
v = (byte*)(s->start<<PageShift); | ||
} | ||
|