git: 85fb40bad584 - main - loader.efi: Use EfiLoaderData memory type for ram disks

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 24 Sep 2026 07:01:26 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=85fb40bad584e7d8c503e5a99bb81cc2d3cf9fee

commit 85fb40bad584e7d8c503e5a99bb81cc2d3cf9fee
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-09-24 06:48:16 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-09-24 06:59:42 +0000

    loader.efi: Use EfiLoaderData memory type for ram disks
    
    For the images we read into the memory, use EfiLoaderData memory type
    instead of EfiReservedMemoryType. The kernel handles the former properly
    and won't reallocate it. While the latter isn't necessarily mapped,
    which can cause ram disks to fault when loaded. memdisk_uefi.efi
    used the latter type, but also registered the device as an ACPI
    RAM disk, which we don't do.
    
    Fixes: afee781523e45
    Sponsored by: Netflix
---
 stand/efi/loader/decompress.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/stand/efi/loader/decompress.c b/stand/efi/loader/decompress.c
index e10daaa423ad..fbf800f87862 100644
--- a/stand/efi/loader/decompress.c
+++ b/stand/efi/loader/decompress.c
@@ -19,7 +19,14 @@
 
 #define ULL(x) ((unsigned long long)(x))
 
-static EFI_MEMORY_TYPE mem_type = EfiReservedMemoryType;
+/*
+ * While memdisk_uefi.efi used EfiReservedMemoryType, we need to use
+ * EfiLoaderData instead, the standard memory type the loader uses to pass
+ * memory to the kernel. This is also safe if we're chain booting to another efi
+ * progarm since the memory will be available to that program. The other type
+ * isn't necessarily in the pmap, so the md driver fails.
+ */
+static EFI_MEMORY_TYPE mem_type = EfiLoaderData;
 
 struct decomp_state
 {