x86_64 interrupts: gpf isr and add support for the user safe memops

This commit is contained in:
Matheus
2022-12-13 23:42:50 -03:00
parent c17a2f4c6c
commit 881acb984d
4 changed files with 32 additions and 3 deletions
+2
View File
@@ -56,6 +56,8 @@ void idt_bspinit(){
idt_setentry(&idt[VECTOR_PF], asmisr_pagefault, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
idt_setentry(&idt[VECTOR_GPF], asmisr_gpf, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
idt_setentry(&idt[VECTOR_DEVUNAVAILABLE], asmisr_nm, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
idt_setentry(&idt[VECTOR_PANIC], asmisr_panic, 0x28, FLAGS_PRESENT | FLAGS_TYPE_INTERRUPT, 0);
+1
View File
@@ -14,5 +14,6 @@ extern void asmisr_ps2kbd();
extern void asmisr_timer();
extern void asmisr_simd();
extern void asmisr_nm();
extern void asmisr_gpf();
#endif
+1
View File
@@ -153,6 +153,7 @@ asmisr_panic:
jmp .hlt ; NMI stuff
except asmisr_pagefault, isr_pagefault, 0xE
except asmisr_gpf, isr_gpf, 0xD
except asmisr_nm, isr_except, 0x7
isr asmisr_general, isr_general, 0xFF
except asmisr_except, isr_except, 0xFF
+28 -3
View File
@@ -3,6 +3,9 @@
#include <kernel/vmm.h>
#include <arch/apic.h>
#include <kernel/timer.h>
#include <arch/cls.h>
#include <stdio.h>
#include <errno.h>
void isr_simd(arch_regs *reg){
@@ -21,14 +24,36 @@ void isr_general(arch_regs *reg, int n){
}
void isr_except(arch_regs *reg, int n){
printf("exception %d", n);
_panic("CPU Exception", reg);
}
void isr_pagefault(arch_regs *reg){
void isr_gpf(arch_regs* reg){
if(!vmm_dealwithrequest(reg->cr2, reg->error, reg->cs == 0x3b))
_panic("Page fault!", reg);
arch_getcls()->thread->umemoperror = EFAULT;
if(arch_getcls()->thread->umemopfailaddr == NULL)
_panic("General protection fault!", reg);
else
reg->rip = (uint64_t)arch_getcls()->thread->umemopfailaddr;
}
void isr_pagefault(arch_regs *reg){
int error = vmm_dealwithrequest(reg->cr2, reg->error, reg->cs == 0x3b);
if(error){
if(arch_getcls()->thread->umemopfailaddr == NULL){
_panic("Page fault!", reg);
}
else{
reg->rip = (uint64_t)arch_getcls()->thread->umemopfailaddr;
arch_getcls()->thread->umemoperror = error;
}
}
}