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:
