Skip to content

linux: enable EFI_ZBOOT for generic compression support#239721

Merged
flokli merged 2 commits intoNixOS:stagingfrom
RaitoBezarius:zboot
Jul 3, 2024
Merged

linux: enable EFI_ZBOOT for generic compression support#239721
flokli merged 2 commits intoNixOS:stagingfrom
RaitoBezarius:zboot

Conversation

@RaitoBezarius
Copy link
Member

Description of changes

Starting 6.1, it is possible to have generic compression for aarch64 and riscv64 via CONFIG_EFI_ZBOOT which implements apparently its own decompression.

https://lwn.net/Articles/907679/

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: kernel The Linux kernel label Jun 25, 2023
@RaitoBezarius
Copy link
Member Author

I am testing this by cross compiling a RISCV64 kernel first.

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. labels Jun 25, 2023
@RaitoBezarius RaitoBezarius changed the base branch from master to staging June 25, 2023 12:13
@RaitoBezarius RaitoBezarius requested a review from K900 June 25, 2023 12:13
@alyssais
Copy link
Member

aarch64 and riscv64

And loongarch!

@alyssais
Copy link
Member

alyssais commented Jun 25, 2023

Needs unixtools.hexdump in nativeBuildInputs, at least for 6.3+.

@RaitoBezarius
Copy link
Member Author

@alyssais Were you able to measure the reduced size? I don't know if I'm holding this wrong but I cannot see anything else than Image being produced for aarch64 or riscv64 with the same size.

@arianvp
Copy link
Member

arianvp commented Jun 26, 2023

I think we also need to change the target here to bzImage (or zImage ?):

target = "Image";

@RaitoBezarius
Copy link
Member Author

I think we also need to change the target here to bzImage (or zImage ?):

target = "Image";

Yeah, actually, I am planning for a bigger refactor of that.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pi4-broken-on-23-11-uefi-zfs-root/36375/4

@ius
Copy link
Contributor

ius commented Dec 3, 2023

@alyssais Were you able to measure the reduced size? I don't know if I'm holding this wrong but I cannot see anything else than Image being produced for aarch64 or riscv64 with the same size.

For reference, some numbers for my Aarch64 cross compiled kernel:

  • Image: 56M
  • vmlinuz.efi 15M

This would be really useful for undersized /boot partitions.

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@zzywysm
Copy link
Contributor

zzywysm commented Jun 2, 2024

Commenting because this is important and shouldn't be marked stale.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2024
@flokli
Copy link
Member

flokli commented Jun 30, 2024

I'm also interested in this, as rust-hypervisor is not happy with the too large kernels we currently produce. I summarized the situation in https://b.tvl.fyi/issues/407.

@flokli
Copy link
Member

flokli commented Jul 1, 2024

I'm also interested in this, as rust-hypervisor is not happy with the too large kernels we currently produce. I summarized the situation in https://b.tvl.fyi/issues/407.

I was just dumb, and used the wrong kernel output (from the dev output). ${myKernel}/${stdenv.hostPlatform.linux-kernel.target} actually has a somewhat reasonable size on aarch64-linux too. This is probably still important to get the number down further?

Starting 6.1, it is possible to have generic compression for aarch64 and riscv64
via CONFIG_EFI_ZBOOT which implements apparently its own decompression.

https://lwn.net/Articles/907679/
@fpletz
Copy link
Member

fpletz commented Jul 3, 2024

I've been successfully EFI booting my Pinebook Pro with Tow-Boot, systemd-boot and zboot. 🚀 These were the changes needed if somebody wants to test on another aarch64 machine: master...fpletz:nixpkgs:arm64-zboot

To get this PR through the the door, I have fixed the formatting issue, rebased and added a commit restricting EFI_ZBOOT to aarch64 for now since I have tested the kernel builds correctly both the Image and the vmlinuz.efi. This is needed since otherwise the x86 build breaks. We should add new systems when they have been tested and thus not inadvertently break kernel builds of non-release architectures.

Current file sizes for aarch64:

70M	/boot/EFI/nixos/jvs0n8skfvzxixbaw74qmjz3df6m0znf-linux-6.9.7-Image.efi
17M	/boot/EFI/nixos/qgx88i268aq4ra1sd6xjzhdmsmxybny3-linux-6.9.7-vmlinuz.efi.efi

The extra .efi is added by systemd-boot-builder.py. 😏

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jul 3, 2024
@ofborg ofborg bot removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. labels Jul 3, 2024
Enabling EFI_ZBOOT fails at least the x86 builds. More compatible
platforms can be added after testing.
@flokli flokli merged commit 61f45c3 into NixOS:staging Jul 3, 2024
@flokli
Copy link
Member

flokli commented Jul 3, 2024

Thanks for carrying this over the finish line! 🎉

@arianvp
Copy link
Member

arianvp commented Feb 12, 2025

But this PR as is doesn't do anything as we still make install the uncompressed kernel I think? We need to make sure we do make vmlinuz.efi as opposed to make Image on aarch64

#287122 fixes that iirc

@arianvp
Copy link
Member

arianvp commented Feb 12, 2025

Ah #324419 is the follow-up. I missed that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

Comments