From 70dcf02781595b40ec8ebc5d3291b3999a8862ea Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 14 Jan 2006 20:36:01 +0000 Subject: [PATCH] make the initial kernel_stack large enough to have enough space for the fx savings area svn path=/trunk/; revision=20864 --- reactos/ntoskrnl/ke/i386/main_asm.S | 2 +- reactos/ntoskrnl/ke/i386/thread.c | 4 +++- reactos/ntoskrnl/ke/main.c | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/ke/i386/main_asm.S b/reactos/ntoskrnl/ke/i386/main_asm.S index 58ae7a2ba6f..a7baf975e50 100644 --- a/reactos/ntoskrnl/ke/i386/main_asm.S +++ b/reactos/ntoskrnl/ke/i386/main_asm.S @@ -35,7 +35,7 @@ _NtProcessStartup: .m1: /* Load the initial kernel stack */ lea _kernel_stack, %eax - add $0x1000, %eax + add $0x2000, %eax and $0xFFFFE000, %eax add $(0x3000 - SIZEOF_FX_SAVE_AREA), %eax movl %eax, %esp diff --git a/reactos/ntoskrnl/ke/i386/thread.c b/reactos/ntoskrnl/ke/i386/thread.c index 7a9e8bbd90d..8d760db24d7 100644 --- a/reactos/ntoskrnl/ke/i386/thread.c +++ b/reactos/ntoskrnl/ke/i386/thread.c @@ -122,10 +122,12 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PKKINIT_FRAME InitFrame; InitFrame = (PKKINIT_FRAME)((ULONG_PTR)Thread->InitialStack - sizeof(KKINIT_FRAME)); DPRINT("Setting up a kernel thread with the Frame at: %x\n", InitFrame); - +extern ULONG kernel_stack[]; /* Setup the Fx Area */ FxSaveArea = &InitFrame->FxSaveArea; + DbgPrint("->a Ldr: %d kernel_stack:0%p r0x%p InitialStack: %p Initframe: %p-%p FxSav: %p-%p\n", KeLoaderBlock.ModsCount, &kernel_stack, PAGE_ROUND_UP(&kernel_stack), Thread->InitialStack, InitFrame, (ULONG_PTR)InitFrame + sizeof(KKINIT_FRAME), FxSaveArea, (ULONG_PTR)FxSaveArea + sizeof(FX_SAVE_AREA)); RtlZeroMemory(FxSaveArea, sizeof(FX_SAVE_AREA)); + DbgPrint("->b Ldr: %d kernel_stack:0%p r0x%p InitialStack: %p Initframe: %p-%p FxSav: %p-%p\n", KeLoaderBlock.ModsCount, &kernel_stack, PAGE_ROUND_UP(&kernel_stack), Thread->InitialStack, InitFrame, (ULONG_PTR)InitFrame + sizeof(KKINIT_FRAME), FxSaveArea, (ULONG_PTR)FxSaveArea + sizeof(FX_SAVE_AREA)); Thread->NpxState = NPX_STATE_INVALID; /* Setup the Stack for KiThreadStartup and Context Switching */ diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 48bbab706e8..e138bd3deda 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -48,9 +48,9 @@ PVOID KeRaiseUserExceptionDispatcher = NULL; ULONG KeLargestCacheLine = 0x40; /* FIXME: Arch-specific */ -/* We allocate 4 pages, but we only use 3. The 4th is to guarantee page alignment */ -ULONG kernel_stack[4096]; -ULONG double_trap_stack[4096]; +/* We allocate 5 pages, but we only use 4. The 5th is to guarantee page alignment */ +ULONG kernel_stack[5120]; +ULONG double_trap_stack[5120]; /* These point to the aligned 3 pages */ ULONG init_stack; @@ -155,10 +155,11 @@ _main(ULONG MultiBootMagic, PIMAGE_OPTIONAL_HEADER OptHead; CHAR* s; - /* Set up the Stacks (Initial Kernel Stack and Double Trap Stack)*/ - trap_stack = PAGE_ROUND_UP(&double_trap_stack); + /* Set up the Stacks (Initial Kernel Stack and Double Trap Stack) + and save a page for the fx savings area */ + trap_stack = PAGE_ROUND_UP(&double_trap_stack) + PAGE_SIZE; trap_stack_top = trap_stack + 3 * PAGE_SIZE; - init_stack = PAGE_ROUND_UP(&kernel_stack); + init_stack = PAGE_ROUND_UP(&kernel_stack) + PAGE_SIZE; init_stack_top = init_stack + 3 * PAGE_SIZE; /* Copy the Loader Block Data locally since Low-Memory will be wiped */