From 958e3639d26ddb2171856427744b6e1308451155 Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Wed, 27 Nov 2024 11:44:24 +0000 Subject: [PATCH] fix(bitmap): Correct the bitmap_base for MMU systems In mmu-based systems, the vm_image_size is already encompassed in the image_size. Signed-off-by: Miguel Silva --- src/core/mem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/mem.c b/src/core/mem.c index 5903eaad4..6a6e977a1 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -139,7 +139,6 @@ void* mem_alloc_page(size_t num_pages, enum AS_SEC sec, bool phys_aligned) static bool root_pool_set_up_bitmap(paddr_t load_addr, struct page_pool* root_pool) { size_t image_size = (size_t)(&_image_end - &_image_start); - size_t vm_image_size = (size_t)(&_vm_image_end - &_vm_image_start); size_t cpu_size = platform.cpu_num * mem_cpu_boot_alloc_size(); size_t bitmap_num_pages = @@ -147,7 +146,13 @@ static bool root_pool_set_up_bitmap(paddr_t load_addr, struct page_pool* root_po if (root_pool->size <= bitmap_num_pages) { return false; } + +#ifdef MEM_PROT_MMU + size_t vm_image_size = (size_t)(&_vm_image_end - &_vm_image_start); size_t bitmap_base = load_addr + image_size + vm_image_size + cpu_size; +#else + size_t bitmap_base = load_addr + image_size + cpu_size; +#endif struct ppages bitmap_pp = mem_ppages_get(bitmap_base, bitmap_num_pages); bitmap_t* root_bitmap = (bitmap_t*)mem_alloc_map(&cpu()->as, SEC_HYP_GLOBAL, &bitmap_pp,