[RFC PATCH 9/9] x86/efi: Free unused tail of the EFI memory map
From: Ard Biesheuvel
Date: Fri Mar 06 2026 - 11:01:34 EST
From: Ard Biesheuvel <ardb@xxxxxxxxxx>
After moving the relevant entries to the start of the map, the remainder
can be handed back to the page allocator.
Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
---
arch/x86/platform/efi/quirks.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index d7a64b404bea..4d94b1e82c28 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -475,10 +475,15 @@ static int __init efi_free_boot_services(void)
}
data.size = new_md - efi.memmap.map;
+ md = efi.memmap.map_end;
if (efi_memmap_install(&data) != 0)
pr_err("Could not install new EFI memmap\n");
+ /* Free the part of the memory map allocation that has become unused */
+ free_reserved_area(new_md, md, -1, NULL);
+ freed += (void *)md - new_md;
+
if (freed)
pr_info("Freeing EFI boot services memory: %ldK\n", freed / SZ_1K);
--
2.53.0.473.g4a7958ca14-goog