From: Jan Janssen Date: Sun, 16 Oct 2022 07:36:21 +0000 (+0200) Subject: stub: Fix booting with old kernels X-Git-Tag: v252-rc2~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d388f3d7237c5bd37ecb1187acf81c07b4dce8ae;p=thirdparty%2Fsystemd.git stub: Fix booting with old kernels This fixes a regression introduced in e1636807 that removed setting this value as it seemingly was not used by the kernel and would actively break above 4G boots. But old kernels (4.18 in particular) will not boot properly if it is not filled out by us. The original issue was using the truncated value to then jump into the kernel entry point, which we do not do anymore. So setting this value again on newer kernels is fine. --- diff --git a/src/boot/efi/linux_x86.c b/src/boot/efi/linux_x86.c index 83bd7b2c319..c664abd4613 100644 --- a/src/boot/efi/linux_x86.c +++ b/src/boot/efi/linux_x86.c @@ -107,6 +107,10 @@ static void linux_efi_handover(EFI_HANDLE image, uintptr_t kernel, BootParams *p kernel += (params->hdr.setup_sects + 1) * KERNEL_SECTOR_SIZE; /* 32bit entry address. */ + /* Old kernels needs this set, while newer ones seem to ignore this. Note that this gets truncated on + * above 4G boots, which is fine as long as we do not use the value to jump to kernel entry. */ + params->hdr.code32_start = kernel; + #ifdef __x86_64__ kernel += KERNEL_SECTOR_SIZE; /* 64bit entry address. */ #endif