diff options
author | dzwdz | 2022-05-29 21:21:46 +0200 |
---|---|---|
committer | dzwdz | 2022-05-29 21:21:46 +0200 |
commit | c3e611ecf1e0f6ac5790e56bb0b21d30f5253d15 (patch) | |
tree | e47b9d9ba7489c7510498895620217c9e6514e5b /src/kernel/arch | |
parent | a6ed7a20a823e67c19b93309706c57ddee1933c6 (diff) |
kernel: fix overlapping interrupt / regular stacks
Diffstat (limited to 'src/kernel/arch')
-rw-r--r-- | src/kernel/arch/i386/boot.s | 2 | ||||
-rw-r--r-- | src/kernel/arch/i386/gdt/gdt.c | 4 | ||||
-rw-r--r-- | src/kernel/arch/i386/interrupts/isr_stub.s | 9 |
3 files changed, 7 insertions, 8 deletions
diff --git a/src/kernel/arch/i386/boot.s b/src/kernel/arch/i386/boot.s index 24c076f..743c6d6 100644 --- a/src/kernel/arch/i386/boot.s +++ b/src/kernel/arch/i386/boot.s @@ -2,7 +2,7 @@ .global _start .type _start, @function _start: - mov $_bss_end, %esp // the stack is at the top of bss + mov $_stack_top, %esp call sysenter_setup push %ebx // address of the Multiboot struct call kmain_early diff --git a/src/kernel/arch/i386/gdt/gdt.c b/src/kernel/arch/i386/gdt/gdt.c index f016caa..3662bf6 100644 --- a/src/kernel/arch/i386/gdt/gdt.c +++ b/src/kernel/arch/i386/gdt/gdt.c @@ -4,7 +4,7 @@ #include <stdbool.h> #include <stdint.h> -extern char _isr_stack_top; +extern char _isr_mini_stack; struct gdt_entry { uint64_t limit_low : 16; @@ -83,7 +83,7 @@ static void gdt_prepare(void) { // tss memset(&TSS, 0, sizeof(TSS)); TSS.ss0 = SEG_r0data << 3; // kernel data segment - TSS.esp0 = (uintptr_t) &_isr_stack_top; + TSS.esp0 = (uintptr_t) &_isr_mini_stack; GDT[SEG_TSS] = (struct gdt_entry) { .limit_low = sizeof(TSS), diff --git a/src/kernel/arch/i386/interrupts/isr_stub.s b/src/kernel/arch/i386/interrupts/isr_stub.s index 9a903f6..c09d4b2 100644 --- a/src/kernel/arch/i386/interrupts/isr_stub.s +++ b/src/kernel/arch/i386/interrupts/isr_stub.s @@ -23,11 +23,11 @@ _isr_stage2: mov %ebx, %cr0 mov %esp, %ebp - mov $_bss_end, %esp // switch to kernel stack + mov $_isr_big_stack, %esp push %eax // push the vector nr call isr_stage3 - mov %ebp, %esp // switch back to isr_stack + mov %ebp, %esp pop %eax // restore old cr0 mov %eax, %cr0 @@ -35,8 +35,7 @@ _isr_stage2: iret .align 8 -_ist_stack_btm: // TODO overflow check .skip 64 // seems to be enough -.global _isr_stack_top -_isr_stack_top: +.global _isr_mini_stack +_isr_mini_stack: |