fix(rootfs/qemu-static): use direct armhf exec probe instead of broken arch-test gate#117
fix(rootfs/qemu-static): use direct armhf exec probe instead of broken arch-test gate#117iav wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a8209d26d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4a8209d to
934a2f0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 934a2f0769
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
934a2f0 to
d5b76d4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5b76d4f23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d5b76d4 to
4be6288
Compare
Problem
prepare_host_binfmt_qemu_cross_arm64_host_armhf_target(added in6755e9190, 2024-12-28, for Apple Silicon) gates onarch-test arm. On success → skip qemu-arm import; on failure → write a hand-rolled/usr/share/binfmts/qemu-armmagic with interpreter/usr/bin/qemu-arm-staticand enable it.This is broken on most modern aarch64 hosts:
arch-test armprobes ARMv5 EABI. Current toolchains and the kernel's COMPAT layer target armhf (EABI v5+); the two surfaces diverge.arch-test armreturns failure even withCONFIG_COMPAT=yand a fully-working COMPAT path. The gate then unconditionally routes every aarch64 host through the Apple-Silicon import branch — qemu-arm gets registered, mmdebstrap and chroot apt-get / dpkg --configure / customize_image run through qemu-user-static emulation, ~10× slower than native.update-binfmts --enable qemu-armat function entry could re-enable a pre-existing registration even on hosts the operator deliberately wanted to keep without qemu.Codex (#117 P1 round 1) also flagged: the hand-rolled descriptor overwrites a packaged
/usr/share/binfmts/qemu-arm(resolute'sqemu-user-binfmtships/usr/bin/qemu-armwithout-static) → enable fails → armhf builds break on resolute Apple-Silicon-like hosts.Empirically: helios4
BUILD_MINIMAL=yes RELEASE=trixie PREFER_DOCKER=yesfinishes in 1:07 min on Hetzner CAX21 when qemu-arm stays unregistered (mmdebstrap native via binfmt_elf), vs ~10× longer when emulation routes mmdebstrap.Fix
Replace the single
arch-test armgate with a 4-tier detection that picks the safest path on each host:/usr/share/binfmts/qemu-armexists (packaged byqemu-user-binfmton resolute, or by qemu-user-static install):update-binfmts --enable qemu-arm— loads the packaged descriptor into the kernel. Preserves the packaged interpreter path. Hard-error if enable fails (descriptor present but broken — host needs operator attention)./proc/sys/fs/binfmt_misc/qemu-armexists without descriptor: trust ifenabled, hard-error if disabled (no descriptor to re-enable from).exec /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 --help(ld-linux-armhf is shipped bygcc-arm-linux-gnueabihf, an armbian aarch64 host build dep). Authoritative test ofCONFIG_COMPATfunctionality. If succeeds → kernel runs armhf natively → no qemu setup needed./usr/share/binfmts/qemu-armmagic with/usr/bin/qemu-arm-static, import, enable — the original behaviour, now only reached when actually needed.Also removed the unconditional
update-binfmts --enable qemu-arm "|| true"at function entry — its job is subsumed by step (1).Empirical validation
opts_n+=("COMPAT" "COMPAT_VDSO" "ARM64_32BIT_EL0")):ld-linux-armhf.so.3execs withExec format error; probe correctly fails → step (4) fires./usr/share/binfmts/qemu-armwith/usr/bin/qemu-arm-static): step (1) early-returns, descriptor md5 unchanged before/after, kernel entry left enabled.Test plan
qemu-user-binfmtpackage — covered by inspection (step 1 enables packaged descriptor). No resolute Apple Silicon hardware available; happy to defer to community verification.Assisted-by: Claude:claude-opus-4.7