From 65f10ab06b9918ee971ec14a3d18db9f27da99c9 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 24 Apr 2025 11:32:03 -0400 Subject: make 0x80 ring3, add kernel mem ctx switch in idt handler --- kernel/cpu/idt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'kernel/cpu/idt.c') diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index bf4b499..8bddc21 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "idt.h" #include "pic.h" @@ -66,6 +67,9 @@ void idt_init(void) entry->isr_mid = (isr >> 16) & 0xffff; entry->isr_high = (isr >> 32) & 0xffffffff; entry->reserved = 0; + + if (vector == 0x80) + entry->flags |= RING3; } __asm__ volatile("lidt %0" : : "m"(idtr)); @@ -116,6 +120,9 @@ void idt_exception_handler(uint64_t exception, uint64_t code, { uint64_t cr2; + // make sure were in the kernel memory context + mem_ctx_switch(kernel_mem_ctx); + switch (exception) { case EX_PAGE_FAULT: // page faults store the offending address in cr2 -- cgit v1.2.3-freya