Repository navigation
Boot the staged writer with kexec handover disabled - #24
Merged
Merged
Conversation
Ubuntu 26.04's 7.0 kernels enable kexec handover (KHO) by default. At boot KHO reserves three scratch areas, each twice the memory already in use, and hands them to the page allocator as CMA, which only movable pages may use. The staged initramfs carries the whole CHR image, so the reservation grows with it: with an 80 MB initramfs in 768 MiB, about 600 MB became movable-only and the kernel panicked out of memory about two seconds into boot, before the writer started. Whether the scratch areas fit depends on where KASLR places the kernel, so it failed 8 of 100 boots with KASLR and 45 of 45 with nokaslr. WriterCmdline now appends kho=off (and drops any inherited kho=). With nokaslr plus kho=off, 30 of 30 boots succeeded. The integration tests now build their writer command lines with WriterCmdline so they boot exactly what the installer stages, and the SCSI disk-probe VM gets kho=off for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The writer test VM intermittently panicked out of memory about two seconds into boot ("System is deadlocked on memory"), which failed the first v1.2.6 release attempt: https://github.com/parhamfa/chr-install/actions/runs/45218705699/attempts/1. The cause is not test-only. Ubuntu 26.04's 7.0 kernels enable kexec handover (KHO) by default, and KHO starves the staged writer of ordinary memory. This PR boots the staged writer with
kho=off.Root cause
CONFIG_KEXEC_HANDOVER=yandCONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y.kho_scratchscale 200% of the memory already reserved (kernel/liveupdate/kexec_handover.c,scratch_size_update). Those pageblocks are then markedMIGRATE_CMA, so only movable pages may use them.Memory: 14224K/785900K available ... 766516K reserved, laterfree_cma:153088(598 MB free but movable-only), and the kernel's unmovable allocations (BTF parsing ininet_init) fail.KHO: Failed to reserve scratch area, disabling kexec handover; crashed boots do not.Evidence (temporary diagnostic workflows, since deleted)
nokaslr(forces the scratch areas to fit)nokaslr kho=offMemory size alone is not the trigger: the same initramfs booted 6/6 at 512, 640, 704, 768, and 1024 MiB in a sweep where KHO happened not to fit. The installer's own memory guard (
validateInitramfsMemory: unpacked + compressed + 384 MiB = 607 MiB for this initramfs) does not account for KHO.Change
install.WriterCmdline(exported fromwriterCmdline) appendskho=offand drops any inheritedkho=. The writer boot never performs a handover itself, so it loses nothing. Kernels without KHO (Debian 12/13, Ubuntu 22.04/24.04) pass the unknown parameter to init as an environment variable, which the initramfs ignores.install.WriterCmdline, so CI boots exactly what the installer stages. They previously hard-coded their own copy.kho=offfor the same reason.Known gap (not fixed here)
On the kexec path, kexec-tools 2.0.32 defaults to
kexec_file_load, which passes the running host's KHO scratch areas to the next kernel (kho_fill_kimage), and the receiving kernel'skho_populateignoreskho=off. An Ubuntu 26.04 host whose own boot managed to reserve scratch could therefore still hand a small writer boot a large movable-only region. This was not reproduced: the diagnostic VM for it failed for an unrelated reason (outer VM could not find its disk at 3 GiB). The crash happens before the writer runs andpanic=-1reboots, so the host returns to its original OS with the disk untouched.Validation
go test -race ./...,go vet ./...(including-tags=integrationfor linux), Go formatting, ShellCheck, Linux AMD64 build.kho=offbeing appended and an inheritedkho=onbeing replaced.Scope
No change to disk selection, image preparation, networking, or the memory guard. Release needed for users to get it (installer.sh pulls releases/latest).
🤖 Generated with Claude Code