Nicer paging panics

This commit is contained in:
Sparchatus 2022-05-20 06:32:09 +00:00
parent cdd9d3f75e
commit 937c6fb701

View File

@ -108,7 +108,9 @@ static void pt_exception_handler(enum exception_type type, int subtype,
// abort on NULL pointer dereference
if(addr < (void *) VADDR_LOWEST_NON_NULL) {
USER_PANIC("[ERROR] NULL pointer dereference");
static char str[256];
snprintf(str, sizeof(str), "[ERROR] NULL pointer dereference: addr=%p, ip=%p\n", addr, ip);
USER_PANIC(str);
}
lvaddr_t page_addr = ROUND_DOWN((lvaddr_t)addr, BASE_PAGE_SIZE);
@ -125,19 +127,22 @@ static void pt_exception_handler(enum exception_type type, int subtype,
}
}
if (vaddr_reg == NULL) {
debug_printf("[pt_exception_handler] type=%s, addr=%p, ip=%p, page_addr=0x%x\n", pt_exception_type_to_string(type, subtype), addr, ip, page_addr);
thread_mutex_unlock(&st->lock);
USER_PANIC("[pt_exception_handler][ERROR] Page fault ouside valid virtual address space");
static char str[256];
snprintf(str, sizeof(str), "[ERROR] Page fault ouside valid virtual address space: type=%s, addr=%p, ip=%p, page_addr=0x%x\n", pt_exception_type_to_string(type, subtype), addr, ip, page_addr);
USER_PANIC(str);
}
if (vaddr_reg->free) {
debug_printf("[pt_exception_handler] type=%s, addr=%p, ip=%p, page_addr=0x%x, base=0x%x, size=0x%x\n", pt_exception_type_to_string(type, subtype), addr, ip, page_addr, vaddr_reg->base, vaddr_reg->size);
thread_mutex_unlock(&st->lock);
USER_PANIC("[pt_exception_handler][ERROR] Page fault ouside allocated address space");
static char str[256];
snprintf(str, sizeof(str), "[ERROR] Page fault ouside allocated address space: type=%s, addr=%p, ip=%p, page_addr=0x%x, base=0x%x, size=0x%x\n", pt_exception_type_to_string(type, subtype), addr, ip, page_addr, vaddr_reg->base, vaddr_reg->size);
USER_PANIC(str);
}
if (!vaddr_reg->heap) {
debug_printf("[pt_exception_handler] type=%s, addr=%p, ip=%p\n", pt_exception_type_to_string(type, subtype), addr, ip);
thread_mutex_unlock(&st->lock);
USER_PANIC("[ERROR] Page fault in allocated address space but outside heap");
static char str[256];
snprintf(str, sizeof(str), "[ERROR] Page fault in allocated address space but outside heap: type=%s, addr=%p, ip=%p\n", pt_exception_type_to_string(type, subtype), addr, ip);
USER_PANIC(str);
}
if (is_mapped(st, page_addr)) {