:: commit b30da71874c0a9c46a3c69145c2266569a9fb046

Kacper Słomiński <kacper.slominski72@gmail.com> — 2024-06-11 19:54

parents: b76556afbe

pmm: Allocate memory from UEFI with EfiLoaderCode type

On AArch64 EfiLoaderData is remapped as non-executable, which means we couldn't
use it for the kernel in the Linux boot protocol.
diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index a5dbd514..68ed801d 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -405,13 +405,13 @@ void init_memmap(void) {
 
         EFI_PHYSICAL_ADDRESS base = untouched_memmap[i].base;
 
-        status = gBS->AllocatePages(AllocateAddress, EfiLoaderData,
+        status = gBS->AllocatePages(AllocateAddress, EfiLoaderCode,
                                     untouched_memmap[i].length / 4096, &base);
 
         if (status) {
             for (size_t j = 0; j < untouched_memmap[i].length; j += 4096) {
                 base = untouched_memmap[i].base + j;
-                status = gBS->AllocatePages(AllocateAddress, EfiLoaderData, 1, &base);
+                status = gBS->AllocatePages(AllocateAddress, EfiLoaderCode, 1, &base);
                 if (status) {
                     memmap_alloc_range(base, 4096, MEMMAP_EFI_RECLAIMABLE, MEMMAP_USABLE, true, false, false);
                 }
tab: 248 wrap: offon