From cbc33352cac34371e738d9b3b672bf252f1365e8 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 13 Jul 2017 20:45:29 +0200 Subject: 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. --- kern/thread.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'kern/thread.c') 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 */ -- cgit v1.2.3