:: commit 7bfa2cd775df737d4b7a366cc4f29f3317ac96a5

mintsuki <mintsuki@protonmail.com> — 2022-07-26 09:01

parents: 85603ec8db

pmm: Fix bugs introduced in 85603ec

diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index 76b2054b..1ecf2eef 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -244,7 +244,9 @@ del_mm1:
     *_count = count;
 }
 
+#if uefi == 1
 static void pmm_reclaim_uefi_mem(struct e820_entry_t *m, size_t *_count);
+#endif
 
 struct e820_entry_t *get_memmap(size_t *entries) {
 #if uefi == 1
@@ -517,6 +519,9 @@ static void pmm_reclaim_uefi_mem(struct e820_entry_t *m, size_t *_count) {
     }
 
     struct e820_entry_t *recl = ext_mem_alloc(recl_i * sizeof(struct e820_entry_t));
+    if (m == memmap) {
+        count = memmap_entries;
+    }
 
     {
         size_t recl_j = 0;
@@ -584,8 +589,10 @@ another_recl:;
 
         count = memmap_entries;
 
-        memmap = memmap_save;
-        memmap_entries = memmap_entries_save;
+        if (memmap_save != memmap) {
+            memmap = memmap_save;
+            memmap_entries = memmap_entries_save;
+        }
     }
 
     if (--recl_i > 0) {
tab: 248 wrap: offon