From 291aeabb8aa8840b003f17fee57a8995ebecbae9 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 28 Aug 2011 08:42:39 -0700 Subject: [PATCH] Fix huge bug! Idle task could handle its stack pointer wrong! => depending on the config file and the started apps, we got different failure --- arch/x86/kernel/entry.asm | 2 +- arch/x86/kernel/gdt.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 8fd0e8c3..8d34dff9 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -63,7 +63,7 @@ SECTION .text ALIGN 4 stublet: ; initialize stack pointer. - mov esp, default_stack_pointer + mov esp, [default_stack_pointer] ; initialize cpu features call cpu_init ; interpret multiboot information diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index f6667c60..12631a65 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -28,10 +28,10 @@ gdt_ptr_t gp; static tss_t task_state_segments[MAX_TASKS] __attribute__ ((aligned (PAGE_SIZE))); -static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE), section (".data"))); +static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE))) = {[0 ... MAX_TASKS-1][0 ... KERNEL_STACK_SIZE-1] = 0xCD}; +uint32_t default_stack_pointer = (uint32_t) kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t); // currently, our kernel has full access to the ioports static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, 0}}; -unsigned char* default_stack_pointer __attribute__ ((section (".data"))) = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t); /* * This is defined in entry.asm. We use this to properly reload