Skip to content

Boot the staged writer with kexec handover disabled - #24

Merged
parhamfa merged 1 commit into
mainfrom
claude/writer-kho-off
Nov 24, 2026
Merged

parhamfa merged 1 commit into
mainfrom
claude/writer-kho-off

Conversation

@parhamfa

@parhamfa parhamfa commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

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

  • Ubuntu's 7.0.0-1020-azure and 7.0.0-1016-aws configs set CONFIG_KEXEC_HANDOVER=y and CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y.
  • At boot, KHO reserves three scratch areas (low memory, global, per node), each sized at kho_scratch scale 200% of the memory already reserved (kernel/liveupdate/kexec_handover.c, scratch_size_update). Those pageblocks are then marked MIGRATE_CMA, so only movable pages may use them.
  • The staged initramfs is large (80 MB in the test, plus the whole CHR image in production), so the scratch areas are large. In 768 MiB: Memory: 14224K/785900K available ... 766516K reserved, later free_cma:153088 (598 MB free but movable-only), and the kernel's unmovable allocations (BTF parsing in inet_init) fail.
  • Whether the scratch areas fit depends on where KASLR places the kernel. Healthy boots log KHO: Failed to reserve scratch area, disabling kexec handover; crashed boots do not.

Evidence (temporary diagnostic workflows, since deleted)

Setup (768 MiB, SCSI, azure kernel) Boots Out-of-memory panics
As shipped (KASLR on) 100 8 (+1 other early panic)
As shipped (KASLR on), second sample 45 2
nokaslr (forces the scratch areas to fit) 45 45
nokaslr kho=off 30 0

Memory 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 from writerCmdline) appends kho=off and drops any inherited kho=. 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.
  • The staged, GRUB, and kexec writer integration tests build their command lines with install.WriterCmdline, so CI boots exactly what the installer stages. They previously hard-coded their own copy.
  • The test-only SCSI disk-probe VM (512 MiB, large initramfs) gets kho=off for 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's kho_populate ignores kho=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 and panic=-1 reboots, so the host returns to its original OS with the disk untouched.

Validation

  • go test -race ./..., go vet ./... (including -tags=integration for linux), Go formatting, ShellCheck, Linux AMD64 build.
  • Unit test covers kho=off being appended and an inherited kho=on being replaced.
  • Full GitHub QEMU workflow on this branch: all 9 jobs passed, including all BIOS/UEFI boots and every writer path booting with the installer's own command line (staged, GRUB, kexec, direct): https://github.com/parhamfa/chr-install/actions/runs/45370494927.

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

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>
@parhamfa
parhamfa merged commit e565e43 into main Nov 24, 2026
10 checks passed
@parhamfa
parhamfa deleted the claude/writer-kho-off branch November 24, 2026 11:16
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