From 8aec2a8ce344c39a0a0cb78edacc107538094a15 Mon Sep 17 00:00:00 2001 From: Sparchatus Date: Wed, 13 Apr 2022 10:58:26 +0000 Subject: [PATCH] Bugfix: page faults during root cnode refill --- lib/aos/slot_alloc/single_slot_alloc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/aos/slot_alloc/single_slot_alloc.c b/lib/aos/slot_alloc/single_slot_alloc.c index 02f5937..7ac8e33 100644 --- a/lib/aos/slot_alloc/single_slot_alloc.c +++ b/lib/aos/slot_alloc/single_slot_alloc.c @@ -182,11 +182,18 @@ errval_t single_slot_alloc_resize(struct single_slot_allocator *this, // Refill slab allocator size_t bufgrow = SINGLE_SLOT_ALLOC_BUFLEN(grow); - void *buf = malloc(bufgrow); - if (!buf) { - return LIB_ERR_MALLOC_FAIL; + // NOTE team08: changed to not cause a pagefault because it can be called during page fault handling + struct capref slot; + err = get_default_slot_allocator()->alloc(get_default_slot_allocator(), &slot); + if (err_is_fail(err)) { + return err; } - slab_grow(&this->slab, buf, bufgrow); + slab_refill_no_pagefault(&this->slab, slot, bufgrow); + // void *buf = malloc(bufgrow); + // if (!buf) { + // return LIB_ERR_MALLOC_FAIL; + // } + // slab_grow(&this->slab, buf, bufgrow); // Update free slot metadata err = free_slots(this, this->a.nslots, grow, &this->a.mutex);