Skip to content

feat(user): run precompiled Debian arm64 dynamic bash on Milo - #276

Merged
marcobuschini merged 1 commit into
mainfrom
263-issue-run-a-precompiled-aarch64-linux-bash-binary-on-milo
Dec 4, 2026
Merged

marcobuschini merged 1 commit into
mainfrom
263-issue-run-a-precompiled-aarch64-linux-bash-binary-on-milo

Conversation

@marcobuschini

Copy link
Copy Markdown
Member

Commitizen Summary

What Changed

  • Precompiled Debian arm64 bash Packaging (scripts/setup_debian_bash.sh, Makefile):
    • Added repeatable setup-debian-bash target producing initrds/debian-bash.cpio containing unmodified Debian Bookworm arm64 dynamically linked /bin/bash (5.2.15), /lib/ld-linux-aarch64.so.1, /lib/aarch64-linux-gnu/libc.so.6, /lib/aarch64-linux-gnu/libtinfo.so.6, minimal /etc/{passwd,group}, and /bin/test_milo + base EL0 payloads.
  • Dynamic Linker Launch in Kernel Shell (kernel/shell/shell.cpp):
    • Updated launch_initrd_shell() to parse PT_INTERP, resolve and load the dynamic interpreter via VFS + load_elf_interpreter(), populate AT_BASE, and enter EL0 with Linux AArch64 x0 = 0 (rtld_fini) ABI.
  • AArch64 FP/SIMD Context Preservation (arch/aarch64-linux-gnu/{arch.mk,boot.s,cpu_context.hpp,cpu.cpp}, drivers/ddk.mk, kernel/hal/cpu.hpp):
    • Added -mgeneral-regs-only to kernel and DDK compiler flags so EL1 never clobbers EL0 NEON/SIMD registers (fixing glibc SIMD memset corruption of libc.so.6 .bss across page faults).
    • Expanded HAL::CpuContext / AArch64CpuContext (816 bytes) and boot.s trap entry/exit macros to save/restore q0..q31, fpcr, and fpsr across traps and context switches.
  • Linux mmap/munmap Length Rounding (kernel/syscalls/MemorySyscalls.cpp, arch/aarch64-linux-gnu/user_test.s):
    • Rounded non-zero sys_mmap and sys_munmap lengths up to page_size per Linux ABI (required by glibc ld-linux-aarch64.so.1 when mapping libtinfo.so.6).
  • W^X-Compliant rt_sigreturn Trampoline Page (kernel/process/Signal.cpp, kernel/mm/AddressSpace.cpp):
    • Mapped a dedicated read+execute (User | Read | Execute, non-writable) trampoline page at user_stack_top on demand when SA_RESTORER is omitted (glibc AArch64 default), fixing SIGCHLD return UXN faults while preserving strict W^X, with refcount-clean teardown in AddressSpace::destroy().
  • Additional Distro Syscalls & Diagnostics (kernel/syscalls/{TimeSyscalls.cpp,SyscallInternal.hpp,SyscallDispatcher.cpp}):
    • Added SYS_GETTIMEOFDAY (169) and SYS_SET_ROBUST_LIST (99) plus debug logging for unhandled syscalls and mmap/munmap/mprotect errors.
  • Regression Tests (tests/host/{distro_abi_test.cpp,process_subsystem_test.cpp}):
    • Added host unit tests covering unaligned sys_mmap/sys_munmap rounding/overflow and W^X rt_sigreturn trampoline page permissions, reuse, and zero-leak teardown.

Breaking Changes

None

Verification & Quality Gates

  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings, 0 formatting violations, and 0 clang-tidy issues
  • make setup-debian-bash builds initrds/debian-bash.cpio cleanly
  • QEMU boot with INITRD=initrds/debian-bash.cpio: milo> test all passes 259/259 (failed=0)
  • QEMU milo> bash reaches interactive milo-bash# prompt (5.2.15(1)-release); verified env vars, subshells, pipes, command substitution, redirections, /bin/bash -c, and /bin/test_milo (passed=14 skipped=0 failed=0, exit 0)

Checklist

- Add scripts/setup_debian_bash.sh and Makefile setup-debian-bash target (initrds/debian-bash.cpio) packaging unmodified Debian Bookworm arm64 dynamic bash with ld-linux-aarch64.so.1, libc.so.6, libtinfo.so.6, and /bin/test_milo
- Support PT_INTERP dynamic linker loading and Linux AArch64 x0=0 entry ABI in kernel/shell/shell.cpp
- Preserve EL0 FP/SIMD state (q0..q31, fpcr, fpsr) across traps/context switches in AArch64CpuContext and compile EL1 kernel/DDK code with -mgeneral-regs-only
- Round non-zero sys_mmap and sys_munmap lengths up to page_size per Linux ABI (required by glibc ld.so)
- Map a dedicated W^X-compliant R+X sigreturn trampoline page at user_stack_top when SA_RESTORER is omitted (with refcount-clean teardown in AddressSpace::destroy)
- Add SYS_GETTIMEOFDAY (169) and SYS_SET_ROBUST_LIST (99) syscall handlers plus debug diagnostics for ENOSYS/mmap failures
- Add host regression tests for unaligned mmap/munmap rounding and the W^X sigreturn trampoline page, and update EL0 user_mm_suite

Closes #263
@marcobuschini marcobuschini linked an issue Dec 4, 2026 that may be closed by this pull request
3 tasks
@marcobuschini
marcobuschini merged commit fd800e2 into main Dec 4, 2026
5 checks passed
@marcobuschini
marcobuschini deleted the 263-issue-run-a-precompiled-aarch64-linux-bash-binary-on-milo branch December 4, 2026 15:21
@marcobuschini marcobuschini self-assigned this Dec 4, 2026
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.

[ISSUE] Run a Precompiled AArch64 Linux bash Binary on Milo

1 participant