Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 947935 - sys-kernel/gentoo-kernel: consider enabling ZBOOT by default on ARM64 for better systemd-boot compatibility
Summary: sys-kernel/gentoo-kernel: consider enabling ZBOOT by default on ARM64 for bet...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: ARM64 Linux
: Normal minor
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-12 07:53 UTC by Marek Bartosiewicz
Modified: 2025-01-13 11:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Bartosiewicz 2025-01-12 07:53:46 UTC
I recently acquired ARM64 laptop with UEFI (Lenovo Yoga Slim7x). Based on my (little) experience with this platform, ARM64 cannot boot (directly) compressed Linux images. And as I'm an user of systemd-boot and Gentoo's distribution kernel on AMD64 I "found out" about this during kernel installation.

Please see this as reference:
https://forums.gentoo.org/viewtopic-p-8773246.html
https://github.com/ironrobin/archiso-x13s/issues/7

My workaround as of now is to change line 43 in dist-kernel-utils.eclass
https://gitweb.gentoo.org/repo/gentoo.git/tree/eclass/dist-kernel-utils.eclass#n43

from:
echo arch/${ARCH}/boot/Image.gz

to:
echo arch/${ARCH}/boot/Image

This installs uncompressed ARM64 image for systemd-boot and it works.
It would be nice (on ARM64 platform) to honor maybe "systemd-boot" USE flag and copy uncompressed kernel?
Comment 1 Marek Bartosiewicz 2025-01-12 08:02:09 UTC
Please note that setting CONFIG_EFI_ZBOOT kernel option also works around this issue, it seems that this compressed kernel has some kind of stub that uncompresses it:

arm64|riscv)
	if [[ ${KERNEL_EFI_ZBOOT} ]]; then
		echo arch/${ARCH}/boot/vmlinuz.efi
	else
Comment 2 Nowa Ammerlaan gentoo-dev 2025-01-12 20:37:04 UTC
Just to double check, this is gentoo-kernel you are using right? Gentoo-kernel-bin should work since these images are built with the secureboot flag enabled, and this flag also enables ZBOOT.

For gentoo-kernel you can enable ZBOOT manually, as you already found out.

I suppose we could change the default setting for ZBOOT to be on always, I'm a bit worried about breaking something for someone though.

Changing the install hook for systemd-boot to uncompress compressed kernel images on arm64 we would have to request upstream at systemd, that is where this script originates.
Comment 3 Marek Bartosiewicz 2025-01-13 05:43:48 UTC
Yes, this is about gentoo-kernel.

Please also note this comment: https://github.com/systemd/systemd/issues/23788#issuecomment-1205588818
Again, I have too little experience on ARM64.

>> Changing the install hook for systemd-boot to uncompress compressed kernel

Well, you don't need that, uncompressed kernel is already there, at
arch/${ARCH}/boot/Image
Comment 4 Nowa Ammerlaan gentoo-dev 2025-01-13 08:50:11 UTC
(In reply to Marek Bartosiewicz from comment #3)
> > Changing the install hook for systemd-boot to uncompress compressed kernel
> 
> Well, you don't need that, uncompressed kernel is already there, at
> arch/${ARCH}/boot/Image

Yes, but it is my understanding that grub does support the compressed image, which means this would have to be conditional to the used layout, and therefore it would have to be done in the installkernel hook instead of the eclass.
Comment 5 Marek Bartosiewicz 2025-01-13 09:15:52 UTC
I'm not a developer, but I wonder why another variable couldn't be used to pass USE systemd-boot from kernel-build.eclass to dist-kernel-utils.eclass?
And then select arch/${ARCH}/boot/Image?

Sorry if my questions seem naive :)
Comment 6 Nowa Ammerlaan gentoo-dev 2025-01-13 09:49:21 UTC
(In reply to Marek Bartosiewicz from comment #5)
> I'm not a developer, but I wonder why another variable couldn't be used to
> pass USE systemd-boot from kernel-build.eclass to dist-kernel-utils.eclass?
> And then select arch/${ARCH}/boot/Image?
> 
> Sorry if my questions seem naive :)

It's not really practical to duplicate the logic for reading install.conf into the eclass. Furthermore, installkernel should function properly by itself without relying on the eclass because it is also called by manually managed kernels (make install).

Anyway, enabling ZBOOT is the better/easier solution here, this also saves space on your ESP or /boot partition. We already have support for that, it is just that the ZBOOT is not enabled by default in the current config. So the question then becomes if we want to change this default.
Comment 7 Marek Bartosiewicz 2025-01-13 10:57:04 UTC
>> installkernel should function properly by itself without relying on the eclass because it is also called by manually managed kernels (make install).

There's another can of worms wrt to devicetree file (yes, the script fails on dtb with gentoo-sources and git-sources).
Comment 8 Nowa Ammerlaan gentoo-dev 2025-01-13 11:04:51 UTC
(In reply to Marek Bartosiewicz from comment #7)
> >> installkernel should function properly by itself without relying on the eclass because it is also called by manually managed kernels (make install).
> 
> There's another can of worms wrt to devicetree file (yes, the script fails
> on dtb with gentoo-sources and git-sources).

What's the error?
Comment 9 Marek Bartosiewicz 2025-01-13 11:16:24 UTC
I've just reported it here: https://bugs.gentoo.org/948033