:: commit e374d73265e02823909473aa32cae69b8399657a

mintsuki <mintsuki@protonmail.com> — 2021-03-17 16:56

parents: 3212155564

pmm: Fix bug with memmap_alloc_range() where the type of the new upper entry was incorrectly set

diff --git a/stage23/mm/pmm.s2.c b/stage23/mm/pmm.s2.c
index a4e180a3..a131e039 100644
--- a/stage23/mm/pmm.s2.c
+++ b/stage23/mm/pmm.s2.c
@@ -438,6 +438,7 @@ bool memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type, bool free
 
         uint64_t entry_base = memmap[i].base;
         uint64_t entry_top  = memmap[i].base + memmap[i].length;
+        uint32_t entry_type = memmap[i].type;
 
         if (base >= entry_base && base <  entry_top &&
             top  >= entry_base && top  <= entry_top) {
@@ -464,7 +465,7 @@ bool memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type, bool free
 
                 target = &memmap[memmap_entries++];
 
-                target->type   = memmap[i].type;
+                target->type   = entry_type;
                 target->base   = top;
                 target->length = entry_top - top;
             }
tab: 248 wrap: offon