Skip to content

pkg/grub: migrate to GRUB 2.12#5710

Open
rucoder wants to merge 3 commits intolf-edge:masterfrom
rucoder:rucoder/grub-2.12
Open

pkg/grub: migrate to GRUB 2.12#5710
rucoder wants to merge 3 commits intolf-edge:masterfrom
rucoder:rucoder/grub-2.12

Conversation

@rucoder
Copy link
Copy Markdown
Contributor

@rucoder rucoder commented Mar 27, 2026

Description

Upgrade the EVE GRUB package from 2.02 and 2.06 to 2.12 for all three architectures (amd64, arm64, riscv64) using a single unified patch set.

2.12 is used by many modern distros

All patches were traced back to their original authors in https://github.com/coreos/grub and restored accordingly. The CoreOS-originated commits map as follows:

This gives a future porter a direct breadcrumb trail: they can git log those 4 coreos hashes and see exactly what upstream they need to diff against when targeting GRUB 2.14.

Key changes:

  • All archs now build from GRUB_COMMIT=grub-2.12 with a single patches-2.12/ directory — no arch-specific patch dirs needed
  • 15 shared patches carry forward all EVE-specific features: gptprio A/B boot selection, measurefs TPM measurement, dt-fixup EFI protocol, getenv EFI variable reader, probe-partuuid, watchdog-style menu timeout, search_part_{label,uuid,disk_uuid} modules
  • Includes the TPM status code improvement from pkg/grub: include EFI status code in "unknown TPM error" message #5708 (raw EFI status hex in "unknown TPM error" messages) — that PR can be closed once this lands
  • Removed legacy patch folders: patches/, patches-2.06/, patches-aarch64-2.06/, patches-riscv64-2.06/
  • coreutils added to base BUILD_PKGS (gnulib bootstrap needs join)
  • GNULIB_REVISION updated to match grub-2.12's bootstrap.conf
  • Removed modules that no longer exist in 2.12: linuxefi (merged into generic linux), verify, gcry_sha256 as standalone
  • Added search_part_uuid to GRUB_MODULES_PORT (all archs); added getenv to arm64 GRUB_MODULES

GRUB 2.12 API compatibility fixes applied to our patches:

  • grub_efi_guid_tgrub_guid_t (type renamed in 2.12)
  • grub_efi_get_variable() gained a void ** output parameter
  • efi_call_4() removed from 2.12; replaced with direct function pointer calls in fdt.c (fdt.module is only built for arm/riscv EFI, not x86, which is why this only surfaced on those targets)

Why riscv64/arm64 arch-specific patch dirs are empty:

  • riscv64 Linux loader patch: superseded by the generic loader/efi/linux.c introduced in 2.12 (handles all EFI archs)
  • riscv64 binutils 2.38 patch: upstreamed in 2.12
  • arm64 search patch: covered by the shared separate-file search_part_* modules
  • dt-fixup and cmddevice: moved to shared patches

How to test and validate this PR

Build the grub package for all three architectures:

make pkg/grub
make ZARCH=arm64 pkg/grub
make ZARCH=riscv64 pkg/grub

All three should complete with Build complete.

Boot an amd64 device or QEMU image and verify:

  • gptprio A/B partition selection works
  • measurefs extends PCR correctly with a TPM present
  • GRUB version shown at boot is 2.12

Tested: Docker build verified for amd64, arm64, riscv64. Boot tested on amd64 QEMU — system boots normally, gptprio selects correct partition.

Changelog notes

Upgraded GRUB bootloader from version 2.06 to 2.12 for all supported architectures (amd64, arm64, riscv64).

PR Backports

  • 16.0-stable: No
  • 14.5-stable: No
  • 13.4-stable: No

Checklist

  • I've provided a proper description

  • I've added the proper documentation

  • I've tested my PR on amd64 device

  • I've tested my PR on arm64 device

  • I've written the test verification instructions

  • I've set the proper labels to this PR

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

@rucoder rucoder requested a review from rene as a code owner March 27, 2026 15:59
@github-actions github-actions bot requested a review from eriknordmark March 27, 2026 15:59
@rucoder rucoder marked this pull request as draft March 27, 2026 16:07
@rucoder rucoder requested a review from shjala March 27, 2026 16:28
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.87%. Comparing base (2281599) to head (bcb52e6).
⚠️ Report is 376 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5710       +/-   ##
===========================================
+ Coverage   19.52%   29.87%   +10.34%     
===========================================
  Files          19       18        -1     
  Lines        3021     2417      -604     
===========================================
+ Hits          590      722      +132     
+ Misses       2310     1549      -761     
- Partials      121      146       +25     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kick off tests

@rucoder rucoder force-pushed the rucoder/grub-2.12 branch from 5d3f0fd to 3a42998 Compare March 29, 2026 23:14
@github-actions github-actions bot requested a review from eriknordmark March 29, 2026 23:15
@rucoder rucoder force-pushed the rucoder/grub-2.12 branch 5 times, most recently from de443ae to 9d1d88a Compare March 30, 2026 09:04
@rucoder rucoder marked this pull request as ready for review March 30, 2026 10:12
@rucoder rucoder force-pushed the rucoder/grub-2.12 branch 2 times, most recently from bcb52e6 to 981fe9c Compare April 1, 2026 11:28
rucoder and others added 3 commits April 2, 2026 08:05
Upgrade from GRUB 2.06 (amd64) / 2.06 (arm64, riscv64) to GRUB 2.12
for all architectures using a single unified patch set.

Key changes:
- All archs now use GRUB_COMMIT=grub-2.12 and GRUB_PATCHES=patches-2.12
- New patches-2.12/ with 14 shared patches (no arch-specific patch dirs
  needed: riscv64 linux loader and arm64 search are upstream in 2.12)
- coreutils added to base BUILD_PKGS (gnulib bootstrap needs `join`)
- GNULIB_REVISION updated to match grub-2.12 bootstrap.conf
- Removed modules dropped in 2.12: linuxefi (merged into linux),
  verify, gcry_sha256 (standalone)
- Added search_part_uuid to GRUB_MODULES_PORT (all archs)
- Added getenv to arm64 GRUB_MODULES (was already in amd64)
- GRUB_REPO updated to GitLab (freedesktop.org), replacing old Savannah URL

Patch set carries forward all EVE-specific features:
export-vars, cat-to-var, cmddevice, removable-drives, gpt, gptprio,
search_part_{label,uuid,disk_uuid}, watchdog timeout, measurefs,
no-measurefs-without-TPM, dt-fixup, getenv,
tpm-status-code (EFI status in unknown TPM error messages).

Dropped probe-partuuid patch: upstream GRUB 2.12 already provides
`probe --part-uuid` natively (handles both GPT and MBR); no grub.cfg
changes needed as the command syntax is identical.

API fixes for 2.12 compatibility:
- grub_efi_guid_t -> grub_guid_t (type renamed)
- grub_efi_get_variable() gained a void** output parameter
- efi_call_4() removed; replaced with direct function pointer calls
  (fdt.c: only compiled for arm/riscv EFI, not x86)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Drop patches/, patches-2.06/, patches-aarch64-2.06/, and
patches-riscv64-2.06/ — all absorbed into the new unified
patches-2.12/ set in the previous commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
- Update patch folder reference from patches/ to patches-2.12/
- List patches dropped in 2.12 (now upstream in mainline GRUB)
- Document all 15 current patches with authors and upstreaming tasks
- Add CoreOS/grub commit hashes for GPT patches (reference for future migrations)
- Note GRUB's move to GitLab at freedesktop.org (March 13, 2026)

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder force-pushed the rucoder/grub-2.12 branch from 981fe9c to fd91db7 Compare April 2, 2026 08:05
@github-actions github-actions bot requested a review from rene April 2, 2026 08:06
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.

3 participants