summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-07-13 20:45:29 +0200
committerRichard Braun <rbraun@sceen.net>2017-07-13 20:45:29 +0200
commitcbc33352cac34371e738d9b3b672bf252f1365e8 (patch)
tree98a6609bba323dbd09a2b8615cddc39453b916ca /kern/thread.c
parent6e08dddccb29ff35c0a18def56f6b6f05eb43bc2 (diff)
kern/thread: fix thread stack guard support
Since the introduction of the kernel VM object, page referencing has become more strict, preventing the thread stack guard code to function. Work around the issue by keeping the physical pages at the stack boundaries.
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/kern/thread.c b/kern/thread.c
index 976b464f..df32ab4c 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -1931,24 +1931,18 @@ thread_alloc_stack(void)
pmap_remove(kernel_pmap, va + PAGE_SIZE + stack_size, cpumap_all());
pmap_update(kernel_pmap);
- vm_page_free(first_page, 0);
- vm_page_free(last_page, 0);
-
- return (char *)va + PAGE_SIZE;
+ return (void *)va + PAGE_SIZE;
}
static void
thread_free_stack(void *stack)
{
size_t stack_size;
- char *va;
+ void *va;
stack_size = vm_page_round(TCB_STACK_SIZE);
- va = (char *)stack - PAGE_SIZE;
-
- vm_kmem_free_va(va, PAGE_SIZE);
- vm_kmem_free(va + PAGE_SIZE, stack_size);
- vm_kmem_free_va(va + PAGE_SIZE + stack_size, PAGE_SIZE);
+ va = (void *)stack - PAGE_SIZE;
+ vm_kmem_free(va, (PAGE_SIZE * 2) + stack_size);
}
#else /* X15_THREAD_STACK_GUARD */