Subject: [PATCH] stub: load kernel in 64k aligned memory

From: Agathe Porte <[email-masked]>
Date: Tue, 2 Jun 2026 14:53:49 +0200

This workaround allows to have the kernel aligned on a 64k boundary and
get rid of the following error message:

	FIRMWARE BUG: kernel image not aligned on 64k boundary

It is not a proper fix though, because it hardcodes the value. The
correct way to proceed would be to extract the SectionAlignment of the
kernel ELF data in the .linux section and align to it directly.

Signed-off-by: Agathe Porte <[email-masked]>
---
 src/boot/linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/boot/linux.c b/src/boot/linux.c
index b1f38e597d..65100116ca 100644
--- a/src/boot/linux.c
+++ b/src/boot/linux.c
@@ -265,8 +265,8 @@ EFI_STATUS linux_exec(
                 return log_error_status(err, "Cannot read sections: %m");
 
         /* Do we need to ensure under 4gb address on x86? */
-        _cleanup_pages_ Pages loaded_kernel_pages = xmalloc_pages(
-                        AllocateAnyPages, EfiLoaderCode, EFI_SIZE_TO_PAGES(kernel_size_in_memory), 0);
+        _cleanup_pages_ Pages loaded_kernel_pages = xmalloc_aligned_pages(
+                        AllocateAnyPages, EfiLoaderCode, EFI_SIZE_TO_PAGES(kernel_size_in_memory), 0x10000, 0);
 
         uint8_t* loaded_kernel = PHYSICAL_ADDRESS_TO_POINTER(loaded_kernel_pages.addr);
         FOREACH_ARRAY(h, headers, n_headers) {
-- 
2.53.0