:: commit 163647f12935706c5c4043711408eba192a2ecda

mintsuki <mintsuki@protonmail.com> — 2024-10-15 21:14

parents: 04883abb0c

mm/pmm: Ignore UEFI memory map entries of length 0. Fixes #417

diff --git a/common/lib/misc.c b/common/lib/misc.c
index 88bea2de..614842bf 100644
--- a/common/lib/misc.c
+++ b/common/lib/misc.c
@@ -268,6 +268,10 @@ retry:
         EFI_MEMORY_DESCRIPTOR *orig_entry = (void *)efi_mmap + i * efi_desc_size;
         EFI_MEMORY_DESCRIPTOR *new_entry = (void *)efi_copy + efi_copy_i * efi_desc_size;
 
+        if (orig_entry->NumberOfPages == 0) {
+            continue;
+        }
+
         memcpy(new_entry, orig_entry, efi_desc_size);
 
         uint64_t base = orig_entry->PhysicalStart;
diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index d929037e..eb08f204 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -332,6 +332,10 @@ void init_memmap(void) {
     for (size_t i = 0; i < entry_count; i++) {
         EFI_MEMORY_DESCRIPTOR *entry = (void *)efi_mmap + i * efi_desc_size;
 
+        if (entry->NumberOfPages == 0) {
+            continue;
+        }
+
         uint32_t our_type;
         switch (entry->Type) {
             case EfiReservedMemoryType:
tab: 248 wrap: offon