From 09497c11197e622fc2657e82b4da7cb2e4b6bb22 Mon Sep 17 00:00:00 2001 From: Minep Date: Mon, 29 Jul 2024 01:10:38 +0100 Subject: [PATCH 1/1] fix: false positive when looking for room to host pmem_list some weird mem region reported by multiboot might be "just" enough to house pmem_list, but not considering the L0T alignment make it to retry instead of fold up instantly --- lunaix-os/arch/x86/mm/pmm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lunaix-os/arch/x86/mm/pmm.c b/lunaix-os/arch/x86/mm/pmm.c index aa35b86..8f350f4 100644 --- a/lunaix-os/arch/x86/mm/pmm.c +++ b/lunaix-os/arch/x86/mm/pmm.c @@ -17,8 +17,10 @@ pmm_arch_init_remap(struct pmem* memory, struct boot_handoff* bctx) size_t i = 0; struct boot_mmapent* ent; - for (; i < bctx->mem.mmap_len; i++) { - ent = &bctx->mem.mmap[i]; + +restart:; + while (i < bctx->mem.mmap_len) { + ent = &bctx->mem.mmap[i++]; if (free_memregion(ent) && ent->size > pool_size) { goto found; } @@ -38,7 +40,7 @@ found:; #endif if (aligned_pplist + pool_size > ent->start + ent->size) { - return 0; + goto restart; } // for x86_32, the upper bound of memory requirement for pplist -- 2.27.0