grub2/0413-Revert-arm64-Use-proper-memory-type-for-kernel-alloc.patch
Hans de Goede 55c5cc0645 EFI arm64 loader fixes
The Fedora 44 change to make aarch64 live isos just work on WoA laptops:
https://fedoraproject.org/wiki/Changes/Automatic_DTB_selection_for_aarch64_EFI_systems

uses the auto DTB selection build into the systemd-stub. The modified
kernel image is in essence an incomplete UKI containing just a UKI
boot-stub and the DTBs, but not an initrd nor a kernel commandline.
The host generated initrd and host specific commandline will still be
supplied by GRUB as usual, including allowing the user to make changes
to the commandline through GRUB.

Currently Fedora's grub fails to boot the UKI-light kernel images used
for this change.

This is caused by a set of Fedora downstream GRUB changes which replace
calling EFI boot services load_image + start_image with code to manually
load the PE binary and jump to the entry point.

This change adds 8 (partial) reverts, reverting to the grub mainline code
for starting EFI PE binaries on aarch64. Note the code changes only
influence aarch64, which is why some of the reverts are partial since some
of the code is also used on i386/x86_64 builds.

On top of these reverts there are 2 bugfixes and a commit disabling most of
the generic grub-core/loader/efi/linux.c code on i386/x86_64 since that is
unused on i386/x86_64.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
2026-01-21 19:52:02 +01:00

54 lines
1.9 KiB
Diff

From ddb21e0868f309a780f495ce25b14a866328001e Mon Sep 17 00:00:00 2001
From: Hans de Goede <johannes.goede@oss.qualcomm.com>
Date: Thu, 4 Dec 2025 21:25:54 +0100
Subject: [PATCH 413/419] Revert "arm64: Use proper memory type for kernel
allocation"
This fully reverts commit ba84a3e50533138afe65c5b87b13cf8a0df90393.
Note the modifed code is not used on x86 (#ifdef !x86).
This is part of a series of reverts to move non x86 vmlinuz loading back
to using EFI boot services load_image + start_image calls.
The current DYI approach breaks booting kernel EFI binaries which have
the stubble stub for automatic DTB loading.
Switching back to EFI boot services load_image + start_image fixes this
and also brings Fedora's grub inline with how upstream grub is loading
and booting kernels on arm64 platforms.
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
grub-core/loader/efi/linux.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
index aa7d0f5dd..32406a3b4 100644
--- a/grub-core/loader/efi/linux.c
+++ b/grub-core/loader/efi/linux.c
@@ -25,9 +25,7 @@
#include <grub/loader.h>
#include <grub/mm.h>
#include <grub/types.h>
-#include <grub/efi/api.h>
#include <grub/efi/efi.h>
-#include <grub/cpu/efi/memory.h>
#include <grub/efi/fdtload.h>
#include <grub/efi/memory.h>
#include <grub/efi/linux.h>
@@ -878,10 +876,7 @@ fallback:
grub_loader_unset();
kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1);
- kernel_alloc_addr = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
- kernel_alloc_pages,
- GRUB_EFI_ALLOCATE_MAX_ADDRESS,
- GRUB_EFI_LOADER_CODE);
+ kernel_alloc_addr = grub_efi_allocate_any_pages (kernel_alloc_pages);
grub_dprintf ("linux", "kernel numpages: %d\n", kernel_alloc_pages);
if (!kernel_alloc_addr)
{
--
2.52.0