From ec09e0a89d43d67fcd85d8f4122dadc010ab227b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 22 May 2008 12:02:30 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20by=20Jan=20Kl=C3=B6tzke:=20*=20For=20vm?= =?UTF-8?q?86=20mode=20the=20kernel=20stack=20top=20is=20adjusted=20->=20d?= =?UTF-8?q?o=20not=20rely=20on=20the=20=20=20kernel=5Fstack=5Fbase=20+=20K?= =?UTF-8?q?ERNEL=5FSTACK=5FSIZE=20calculation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25608 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/arch_debug.cpp | 4 ++-- src/system/kernel/arch/x86/arch_thread.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_debug.cpp b/src/system/kernel/arch/x86/arch_debug.cpp index e0ae1302c4..855b8eaaa1 100644 --- a/src/system/kernel/arch/x86/arch_debug.cpp +++ b/src/system/kernel/arch/x86/arch_debug.cpp @@ -213,7 +213,7 @@ is_kernel_stack_address(struct thread* thread, addr_t address) return IS_KERNEL_ADDRESS(address); return address >= thread->kernel_stack_base - && address < thread->kernel_stack_base + KERNEL_STACK_SIZE; + && address < thread->kernel_stack_top; } @@ -281,7 +281,7 @@ stack_trace(int argc, char **argv) kprintf(" kernel stack: %p to %p\n", (void *)thread->kernel_stack_base, - (void *)(thread->kernel_stack_base + KERNEL_STACK_SIZE)); + (void *)(thread->kernel_stack_top)); if (thread->user_stack_base != 0) { kprintf(" user stack: %p to %p\n", (void *)thread->user_stack_base, diff --git a/src/system/kernel/arch/x86/arch_thread.cpp b/src/system/kernel/arch/x86/arch_thread.cpp index 4de532a1f8..7e528acd5a 100644 --- a/src/system/kernel/arch/x86/arch_thread.cpp +++ b/src/system/kernel/arch/x86/arch_thread.cpp @@ -92,7 +92,7 @@ find_previous_iframe(addr_t frame) // iterate backwards through the stack frames, until we hit an iframe while (frame >= thread->kernel_stack_base - && frame < thread->kernel_stack_base + KERNEL_STACK_SIZE) { + && frame < thread->kernel_stack_top) { addr_t previousFrame = *(addr_t*)frame; if ((previousFrame & ~IFRAME_TYPE_MASK) == 0) { if (previousFrame == 0) @@ -251,7 +251,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; - addr_t *kstack_top = kstack + KERNEL_STACK_SIZE / sizeof(addr_t); + addr_t *kstack_top = (addr_t *)t->kernel_stack_top; int i; TRACE(("arch_thread_initialize_kthread_stack: kstack 0x%p, start_func 0x%p, entry_func 0x%p\n", @@ -351,7 +351,7 @@ arch_thread_context_switch(struct thread *from, struct thread *to) for (i = 0; i < 11; i++) dprintf("*esp[%d] (0x%x) = 0x%x\n", i, ((unsigned int *)new_at->esp + i), *((unsigned int *)new_at->esp + i)); #endif - i386_set_tss_and_kstack(to->kernel_stack_base + KERNEL_STACK_SIZE); + i386_set_tss_and_kstack(to->kernel_stack_top); // set TLS GDT entry to the current thread - since this action is // dependent on the current CPU, we have to do it here @@ -411,7 +411,7 @@ arch_thread_enter_userspace(struct thread *t, addr_t entry, void *args1, disable_interrupts(); - i386_set_tss_and_kstack(t->kernel_stack_base + KERNEL_STACK_SIZE); + i386_set_tss_and_kstack(t->kernel_stack_top); // set the CPU dependent GDT entry for TLS set_tls_context(t); @@ -607,7 +607,7 @@ arch_restore_fork_frame(struct arch_fork_arg *arg) disable_interrupts(); - i386_set_tss_and_kstack(thread->kernel_stack_base + KERNEL_STACK_SIZE); + i386_set_tss_and_kstack(thread->kernel_stack_top); // set the CPU dependent GDT entry for TLS (set the current %fs register) set_tls_context(thread);