diff options
author | dzwdz | 2022-05-21 21:24:15 +0200 |
---|---|---|
committer | dzwdz | 2022-05-21 21:24:15 +0200 |
commit | ef52650c4a0723b242deb72ce2726f6846a6e986 (patch) | |
tree | bdf42a732d694a58cdae1ba8314ae98e096e2399 /src/kernel/arch/i386/interrupts | |
parent | e0101ecf0d2f29d8860e865e3f333803af918f2e (diff) |
kernel/i386: only map what's absolutely necessary in the user
Diffstat (limited to 'src/kernel/arch/i386/interrupts')
-rw-r--r-- | src/kernel/arch/i386/interrupts/idt.c | 2 | ||||
-rw-r--r-- | src/kernel/arch/i386/interrupts/isr_stub.s | 31 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/kernel/arch/i386/interrupts/idt.c b/src/kernel/arch/i386/interrupts/idt.c index d27bc61..d295d84 100644 --- a/src/kernel/arch/i386/interrupts/idt.c +++ b/src/kernel/arch/i386/interrupts/idt.c @@ -23,7 +23,7 @@ struct lidt_arg { uint32_t base; } __attribute__((packed)); - +__attribute__((section(".text.early"))) static struct idt_entry IDT[256]; static struct lidt_arg lidt_arg; diff --git a/src/kernel/arch/i386/interrupts/isr_stub.s b/src/kernel/arch/i386/interrupts/isr_stub.s index 8efb1b7..9a903f6 100644 --- a/src/kernel/arch/i386/interrupts/isr_stub.s +++ b/src/kernel/arch/i386/interrupts/isr_stub.s @@ -1,4 +1,4 @@ -.section .text +.section .text.early .global _isr_stubs _isr_stubs: @@ -9,25 +9,34 @@ _isr_stubs: .endr _isr_stage2: - cld + cli // convert the return address into the vector nr pop %eax add $-_isr_stubs, %eax shr $3, %eax - // disable paging, if present - // it's done here so the stuff on the stack is in the right order - mov %cr0, %ebx - push %ebx - and $0x7FFFFFFF, %ebx - mov %ebx, %cr0 + // disable paging, if present + mov %cr0, %ebx + push %ebx // push original cr0 + and $0x7FFFFFFF, %ebx + mov %ebx, %cr0 - push %eax // push the vector nr + mov %esp, %ebp + mov $_bss_end, %esp // switch to kernel stack + push %eax // push the vector nr call isr_stage3 - add $4, %esp // "pop" the vector nr - pop %eax // restore old cr0 + + mov %ebp, %esp // switch back to isr_stack + pop %eax // restore old cr0 mov %eax, %cr0 popal iret + +.align 8 +_ist_stack_btm: +// TODO overflow check +.skip 64 // seems to be enough +.global _isr_stack_top +_isr_stack_top: |