diff --git a/lib/aos/paging.c b/lib/aos/paging.c index 2a63f53..7b14290 100644 --- a/lib/aos/paging.c +++ b/lib/aos/paging.c @@ -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"); }