Bugfix Allow other threads to continue even if one fails paging

This commit is contained in:
Sparchatus 2022-05-02 09:02:47 +00:00
parent cd53dfd7f3
commit 5c6d186a3c

View File

@ -126,29 +126,35 @@ static void pt_exception_handler(enum exception_type type, int subtype,
}
if (vaddr_reg == NULL) {
debug_printf("[pt_exception_handler] page_addr = 0x%x\n", page_addr);
thread_mutex_unlock(&st->lock);
USER_PANIC("[pt_exception_handler][ERROR] Page fault ouside valid virtual address space");
}
if (vaddr_reg->free) {
debug_printf("[pt_exception_handler] page_addr = 0x%x, base = 0x%x, size = 0x%x\n", 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");
}
if (!vaddr_reg->heap) {
thread_mutex_unlock(&st->lock);
USER_PANIC("[ERROR] Page fault in allocated address space but outside heap");
}
if (is_mapped(st, page_addr)) {
// Page has already been mapped by another thread before we took the lock.
thread_mutex_unlock(&st->lock);
return;
}
struct capref frame;
err = frame_alloc(&frame, BASE_PAGE_SIZE, NULL);
if (err_is_fail(err)) {
thread_mutex_unlock(&st->lock);
USER_PANIC_ERR(err, "Failed to allocate frame in page fault handler");
}
err = _paging_map_fixed_attr(st, page_addr, frame, BASE_PAGE_SIZE, VREGION_FLAGS_READ_WRITE);
if (err_is_fail(err)) {
thread_mutex_unlock(&st->lock);
USER_PANIC_ERR(err, "Failed to map frame in page fault handler");
}