Skip to content

feat(kernel): support bzImage direct boot on x86_64#6037

Draft
Manciukic wants to merge 4 commits into
firecracker-microvm:mainfrom
Manciukic:feat/bzimage-boot
Draft

feat(kernel): support bzImage direct boot on x86_64#6037
Manciukic wants to merge 4 commits into
firecracker-microvm:mainfrom
Manciukic:feat/bzimage-boot

Conversation

@Manciukic

Copy link
Copy Markdown
Contributor

Changes

Add support for booting bzImage guest kernels on x86_64, in addition to the
existing uncompressed ELF (vmlinux) images.

load_kernel now attempts the ELF loader first and, when the image is not a
valid ELF binary, falls back to the linux-loader bzImage loader. A bzImage
is entered through its 64-bit entry point (code32_start + 0x200) using the
Linux 64-bit boot protocol — the same guest CPU state already used for ELF
LinuxBoot kernels — with the one extra step of seeding the zero page from the
image's own setup header. The kernel image format is detected automatically, so
no API or configuration change is required.

Includes unit tests (loader selection, setup-header handling, invalid-image
rejection) and a functional test suite that boots real bzImage artifacts to
userspace and checks them against the equivalent vmlinux.

This builds on #6035, which added the bzImage CI artifact build.

Reason

bzImage is the format many kernel build pipelines produce by default, so
supporting it directly avoids requiring users to extract a vmlinux. Note that
bzImage is provided for compatibility; vmlinux remains recommended, as the
in-guest self-decompression costs extra boot time and memory (documented in
docs/rootfs-and-kernel-setup.md).

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@Manciukic
Manciukic force-pushed the feat/bzimage-boot branch from 3258a9f to 2d6e1df Compare July 17, 2026 15:24
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.95652% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.86%. Comparing base (5ac3f5f) to head (eac4739).

Files with missing lines Patch % Lines
src/vmm/src/arch/x86_64/mod.rs 86.95% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6037   +/-   ##
=======================================
  Coverage   82.85%   82.86%           
=======================================
  Files         277      277           
  Lines       30633    30651   +18     
=======================================
+ Hits        25381    25398   +17     
- Misses       5252     5253    +1     
Flag Coverage Δ
5.10-m5n.metal 83.11% <86.95%> (+<0.01%) ⬆️
5.10-m6a.metal 82.45% <86.95%> (+<0.01%) ⬆️
5.10-m6g.metal 79.89% <ø> (-0.01%) ⬇️
5.10-m6i.metal 83.10% <86.95%> (+<0.01%) ⬆️
5.10-m7a.metal-48xl 82.44% <86.95%> (+<0.01%) ⬆️
5.10-m7g.metal 79.90% <ø> (ø)
5.10-m7i.metal-24xl 83.07% <86.95%> (-0.01%) ⬇️
5.10-m7i.metal-48xl 83.08% <86.95%> (+<0.01%) ⬆️
5.10-m8g.metal-24xl 79.89% <ø> (-0.01%) ⬇️
5.10-m8g.metal-48xl 79.90% <ø> (+<0.01%) ⬆️
5.10-m8i.metal-48xl 83.08% <86.95%> (+<0.01%) ⬆️
5.10-m8i.metal-96xl 83.08% <86.95%> (+<0.01%) ⬆️
6.1-m5n.metal 83.12% <86.95%> (+<0.01%) ⬆️
6.1-m6a.metal 82.48% <86.95%> (+<0.01%) ⬆️
6.1-m6g.metal 79.89% <ø> (-0.01%) ⬇️
6.1-m6i.metal 83.12% <86.95%> (+<0.01%) ⬆️
6.1-m7a.metal-48xl 82.47% <86.95%> (+<0.01%) ⬆️
6.1-m7g.metal 79.89% <ø> (-0.01%) ⬇️
6.1-m7i.metal-24xl 83.13% <86.95%> (+<0.01%) ⬆️
6.1-m7i.metal-48xl 83.14% <86.95%> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 79.88% <ø> (-0.01%) ⬇️
6.1-m8g.metal-48xl 79.89% <ø> (-0.01%) ⬇️
6.1-m8i.metal-48xl 83.14% <86.95%> (-0.01%) ⬇️
6.1-m8i.metal-96xl 83.15% <86.95%> (+0.01%) ⬆️
6.18-m5n.metal 83.12% <86.95%> (+<0.01%) ⬆️
6.18-m6a.metal 82.48% <86.95%> (+<0.01%) ⬆️
6.18-m6g.metal 79.90% <ø> (ø)
6.18-m6i.metal 83.13% <86.95%> (+<0.01%) ⬆️
6.18-m7a.metal-48xl 82.47% <86.95%> (+<0.01%) ⬆️
6.18-m7g.metal 79.89% <ø> (-0.01%) ⬇️
6.18-m7i.metal-24xl 83.14% <86.95%> (+<0.01%) ⬆️
6.18-m7i.metal-48xl 83.13% <86.95%> (-0.01%) ⬇️
6.18-m8g.metal-24xl 79.89% <ø> (-0.01%) ⬇️
6.18-m8g.metal-48xl 79.89% <ø> (ø)
6.18-m8i.metal-48xl 83.14% <86.95%> (+<0.01%) ⬆️
6.18-m8i.metal-96xl 83.14% <86.95%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Manciukic
Manciukic force-pushed the feat/bzimage-boot branch 2 times, most recently from 9288234 to a20bfa1 Compare July 17, 2026 18:15
Previously only uncompressed ELF (vmlinux) kernels could boot on
x86_64. load_kernel now falls back to the linux-loader bzImage loader
when the image is not a valid ELF (InvalidElfMagicNumber).

A bzImage boots via the Linux 64-bit boot protocol at code32_start +
0x200, using the same guest CPU state as the ELF LinuxBoot path. The
only extra step is seeding the zero page with the image's own setup
header, so EntryPoint now carries that header (x86_64 only) for
configure_64bit_boot to merge into boot_params.

Enable the linux-loader "bzimage" feature. Unit tests cover bzImage
selection, ELF carrying no setup header, and rejecting invalid images.

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
Add an x86_64-only functional test, test_bzimage_boots_to_userspace,
that boots the bzImage sibling of the default guest vmlinux, confirms
the guest reaches userspace over SSH, and asserts (via the Debug log)
that Firecracker took the bzImage load path.

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
Note under Unreleased that x86_64 now supports booting bzImage guest
kernels in addition to uncompressed ELF vmlinux images.

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
Update the kernel image format statement and manual build steps to
reflect that x86_64 now supports bzImage kernels in addition to
uncompressed ELF, and note the boot time and memory trade-off.

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
@Manciukic
Manciukic force-pushed the feat/bzimage-boot branch from a20bfa1 to eac4739 Compare July 17, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant