diff --git a/stage23/mm/pmm.s2.c b/stage23/mm/pmm.s2.c index 522ea467..2f444937 100644 --- a/stage23/mm/pmm.s2.c +++ b/stage23/mm/pmm.s2.c @@ -276,6 +276,9 @@ void init_memmap(void) { #endif #if uefi == 1 +extern symbol ImageBase; +extern symbol _edata; + void init_memmap(void) { EFI_STATUS status; @@ -382,6 +385,12 @@ void init_memmap(void) { memcpy(untouched_memmap, memmap, memmap_entries * sizeof(struct e820_entry_t)); untouched_memmap_entries = memmap_entries; + // Allocate bootloader itself + memmap_alloc_range((uintptr_t)ImageBase, (uintptr_t)_edata - (uintptr_t)ImageBase, + MEMMAP_BOOTLOADER_RECLAIMABLE, false, true, false, true); + + sanitise_entries(memmap, &memmap_entries, false); + return; fail: