diff options
Diffstat (limited to 'kernel/cpu')
| -rw-r--r-- | kernel/cpu/idt.c | 11 | 
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index a7a93f6..474727f 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -1,6 +1,7 @@  #include <cpu/arch_inst.h>  #include <cpu/idt.h>  #include <interrupts.h> +#include <log.h>  #include <sched/scheduler.h>  #include <stdio.h> @@ -50,6 +51,14 @@ __attribute__((no_caller_saved_registers)) void EOI(u8 irq) {  }  void general_protection_fault(reg_t *regs) { +  int is_userspace = (regs->error_code & (1 << 2)); +  if (is_userspace) { +    signal_process(current_task, SIGSEGV); +    return; +  } + +  log_enable_screen(); +    klog(LOG_ERROR, "General Protetion Fault");    kprintf(" Error Code: %x\n", regs->error_code);    kprintf("Instruction Pointer: %x\n", regs->eip); @@ -90,6 +99,8 @@ void page_fault(reg_t *regs) {      return;    } +  log_enable_screen(); +    klog(LOG_ERROR, "Page Fault");    kprintf("CR2: %x\n", cr2);    if (current_task) {  |