|author||Ori Bernstein <email@example.com>||2018-04-22 19:29:39 -0700|
|committer||Ori Bernstein <firstname.lastname@example.org>||2018-04-22 19:29:39 -0700|
Add a special exit stack to our thread library.
Because OpenBSD wants a valid stack pointer in any code that enters the kernel, unmapping our stack as part of exiting the process is rather unreliable. This change allocates a stack page that we can switch to when a thread is deallocating itself, which keeps the kernel happy.
Diffstat (limited to 'lib/thread/exit+openbsd-x64.s')
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/thread/exit+openbsd-x64.s b/lib/thread/exit+openbsd-x64.s
index 23f92b5..6421cc3 100644
@@ -10,6 +10,13 @@ thread$exit:
andq $~0xfff,%rdi /* align it */
+ Because OpenBSD wants a valid stack whenever
+ we enter the kernel, we need to toss a preallocated
+ stack pointer into %rsp.
+ movq thread$exitstk,%rsp
/* munmap(base, size) */
movq $73,%rax /* munmap */
movq -8(%rdi),%rsi /* size */