Skip to content

Retire a kernel downgrade's saved modules before m1n1 is rebuilt - #577

Merged
maralcbr merged 3 commits into
quattro-upstreamfrom
mac/68-downgrade-module-cleanup
Sep 26, 2026
Merged

maralcbr merged 3 commits into
quattro-upstreamfrom
mac/68-downgrade-module-cleanup

Conversation

@maralcbr

Copy link
Copy Markdown
Member

Ticket 68 (gap audit row B15): a kernel downgrade no longer leaves m1n1 with the running kernel's device trees.

The problem: after a downgrade (a channel move, a reinstall from the cache, a migration to an older Aurora), kernel-modules-hook puts the running kernel's modules back in /usr/lib/modules, owned by no package, until linux-modules-cleanup moves them at the next boot. Until then, that copy is the newest -ARCH tree. update-m1n1's ALARM default (95-m1n1-install.hook) builds m1n1 stage 2 from its device trees. update-verify then refuses the reboot, and nothing on the Mac clears it.

The fix: omarchy-mac-boot ships 11-omarchy-mac-saved-modules.hook. It runs right after kernel-modules-hook's 10-linux-modules-post.hook restores the copy, and before depmod, mkinitcpio, Limine and the m1n1 hook. It moves the copy to /usr/lib/modules/.old, as the cleanup service would at boot. It only acts when all of these hold, the same rules as mx's omarchy-apple-silicon-retire-saved-modules:

  • the tree is the running kernel's;
  • no package owns it;
  • it sits directly above a kernel this transaction installed;
  • kernel-modules-hook is installed;
  • update-m1n1 takes its device trees from the -ARCH default, with no DTBS or M1N1_UPDATE_DISABLED set.

It runs inside the transaction, so pacman's lock already covers it. It takes no lock of its own and does not rerun update-m1n1: the m1n1 hook runs after it. Every pacman path is covered: omarchy update, omarchy-reinstall-pkgs, a pacman -U from the cache, and the migration engine's transaction. mx could only cover its own update script. The cost matches mx: the running kernel cannot load new modules until the reboot, and the hook says so. Limine's install hook skips module trees no package owns, so no stale menu entry arises.

Tests:

  • test/mac-saved-modules-test.sh covers hook order and trigger, and the downgrade fixture through the real update-verify. Without the hook, update-verify refuses the running kernel's device trees. With it, update-verify passes with the reboot pending, and the copy is in .old. Cases that must be left alone are covered too, with the reason printed where a downgrade stays broken: an upgrade, a reinstall of the running kernel, an owned or intervening tree, no kernel-modules-hook, DTBS configured or m1n1 disabled, a symlink. So is a failed copy.
  • The boot package suite passes in the CI container image.
  • One-off with real pacman and the real kernel-modules-hook in an Arch container: fake linux-aurora 6.18 → 6.17 downgrade, and a stand-in m1n1 hook recording the tree update-m1n1's default takes. Without this hook it takes 6.18 (the running kernel). With it, it takes 6.17 and 6.18 ends up in .old.

Second review: no blockers. Applied: after a downgrade, the hook now says why it left the saved tree in place. That happens when the running kernel's headers still own it, or when another tree sits in between. It was silent before. Dropped a test assertion about the Limine menu that the fixture could not falsify. Limine's filter for trees no package owns is from limine-mkinitcpio-install (limine-mkinitcpio-hook 1.39.0-2).

Merged current quattro-upstream (README conflict with #535's speakersafetyd note, both kept). Independent of #576 (ticket 67); the two merge cleanly in either order.

After a downgrade, kernel-modules-hook puts the running kernel's modules back
in /usr/lib/modules until the next boot, where they are the newest -ARCH tree:
update-m1n1's default then builds m1n1 with the running kernel's device trees
and update-verify refuses the reboot, with no way out on the Mac. A pacman
hook that runs right after kernel-modules-hook's restore now moves that copy
to /usr/lib/modules/.old, as linux-modules-cleanup would at boot, only when it
is the running kernel's unowned tree directly above the kernel the
transaction installed and m1n1 takes its device trees from that default.
…wngrade-module-cleanup

# Conflicts:
#	packages/omarchy-mac/boot/README.md
A package that still owns the running kernel's tree (its headers) or another
tree between it and the installed kernel leaves m1n1 on the running kernel's
device trees; the hook now names the cause instead of exiting silently.
@maralcbr
maralcbr merged commit a21c93e into quattro-upstream Sep 26, 2026
5 checks passed
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