This document preserves the full subsystem feature overview, directory layout, toolchain/host prerequisites, build/test commands, interactive shell commands, and roadmap details for milo.
-
AArch64 Reference Target & Portable HAL (
arch/,kernel/hal/,kernel/core/):- Exception entry (
_start),VBAR_EL1vector table dispatch, FP/SIMD enablement, and kernel/user context switching (cpu_switch_context,enter_user_mode,enter_user_context,return_to_kernel,kernel_thread_trampoline). - 4-level AArch64 MMU page tables (
TTBR0_EL1/TTBR1_EL1) with hybrid 2 MiB block / 4 KiB page RAM mapping,W^XandPXN/UXNenforcement, lazy demand-zero paging, and Copy-on-Write (CoW) page fault resolution. - FDT/DTB memory region,
/memreserve/,linux,initrd-*, andvirtio,mmiodiscovery, GICv2 interrupt controller (gicv2), ARM Generic Timer (100 Hz preemptive tick), PL011 MMIO UART console driver,SplitVirtqueue,VirtioMmioTransport, andvirtio_blkblock driver. - Freestanding trait helpers (
Kernel::Traits::is_bool/is_bool_v).
- Exception entry (
-
Freestanding C++20 & Synchronization (
kernel/runtime/,kernel/sync/):- Compiled with
-std=c++20 -ffreestanding -fno-exceptions -fno-rttiand strict warning/static-analysis gates (clang-format,clang-tidy). Kernel::Sync::IrqGuard: zero-overhead RAII interrupt-masking guard.
- Compiled with
-
Memory Management (
kernel/mm/):MM::Page&MM::PageFrameAllocator: FDT-driven physical memory discovery (with/memreserve/carveouts and discontiguous bank gaps) and atomic reference counting (page_get/page_put) for CoW sharing.MM::KernelHeap: 8-class slab allocator (16 B - 2048 B) paired with a compound multi-page allocator backingkmalloc/kzalloc/krealloc/kfreeandoperator new/delete.MM::AddressSpace: isolated user page tables,clone(),map_demand_zero(), and validatedcopy_from_user/copy_to_usertransfers.
-
Processes, Scheduling & Signals (
kernel/process/):- Encapsulated
Processclass with preemptive round-robinSchedulerand intrusiveWaitQueues. FdTable&FileDescriptor: RAII file descriptor table with geometric growth bounded byRLIMIT_NOFILE,RLIMIT_NPROCdynamic scaling, andO_CLOEXECsupport.SignalTable: per-process signal masks,SigActionhandlers, unmaskableSIGKILL/SIGSTOPinvariant enforcement, and EL0rt_sigframedelivery/unwinding (rt_sigreturn).UserStackBuilder: System V AArch64 ABI initial stack layout (argc,argv,envp,auxvincludingAT_RANDOM).
- Encapsulated
-
Linux AArch64 ABI & Syscall Layer (
kernel/uapi/,kernel/syscalls/,kernel/time/):- Dedicated C-compatible
kernel/uapi/headers verified at compile time withsizeof,offsetof,std::is_trivial_v, andstd::is_standard_layout_vstatic_asserts. Time::Durationdomain wrapper isolating internal timer/nanosecond logic fromlinux_timespec/linux_timeval.- Modular syscall handlers covering process lifecycle (
clone,execvewith#!shebangs,wait4,exit/exit_group, job control,prlimit64), memory (brk,mmap,munmap,mprotect), VFS/IO (openat,read,write,writev,pipe2,dup/dup3,fcntl,ioctl,getdents64,ppoll,pselect6,ftruncate/truncate,utimensat,fsync/fdatasync,fchmod/fchmodat,fchown/fchownat,newfstatat/fstat,faccessat/faccessat2,readlinkat,mkdirat,unlinkat,renameat/renameat2,getcwd,chdir,lseek,close), sockets (socket,socketpair,bind,listen,accept/accept4,connect,getsockname,getpeername,sendto,recvfrom,setsockopt,getsockopt,shutdown,sendmsg,recvmsg), signals (rt_sigaction,rt_sigprocmask,rt_sigreturn,kill), and time/system info (clock_gettime,nanosleep,times,getrusage,sysinfo,getrandom,uname).
- Dedicated C-compatible
-
VFS, IPC, ELF Loader & Drivers (
kernel/fs/,kernel/ipc/,kernel/loader/,kernel/drivers/):- Virtual File System with
rootfs(CPIOnewcarchive loading),tmpfs(page-backed writable filesystem),ext2(block-backed filesystem with direct, singly indirect, and doubly indirect blocks, directory entry creation/coalescing, andfsync), anddevfs(/dev/console,/dev/tty,/dev/nullwithtermios/winsizeioctls, canonical/non-canonical line discipline, and foreground PGID job control, plus/dev/fb0and/dev/input/event<N>). - Encapsulated
Kernel::IPC::Pipering buffer with blocking/non-blocking I/O,SIGPIPEgeneration, andpoll()support. - Static/PIE ELF64 binary parser and loader (
Elf64View,load_elf,load_elf_interpreter) with OOM rollback and W^X segment mapping. - VirtIO-MMIO modern transport (
VirtioMmioTransport),SplitVirtqueue,VirtioMmioBus, and drivers (virtio_blk,virtio_gpu,virtio_input,virtio_net).
- Virtual File System with
-
User-Space Payloads & Dual-Target Testing (
user/,tests/host/,kernel/shell/):- Sample user programs (
user/hello.s,user/hello_musl.c,user/hello_dyn.c,user/fb_test.c,user/evdev_smoke.c,user/unix_echo_server.c,user/unix_echo_client.c,user/unix_sock_smoke.c) and optionalmusl, BusyBox, and GNU Bash initrd images (initrds/busybox.cpio,initrds/bash.cpio). - Host-native
snitchunit tests (HOST_TEST) with ASan/UBSan andgcovrcoverage. - Interactive in-kernel shell (
milo>) with hardware diagnostics and EL0/syscall/scheduler/lazy-memory verification suites.
- Sample user programs (
.
├── arch/
│ └── aarch64-linux-gnu/ # AArch64 boot, vectors, MMU/CoW, trap handling, PL011 UART, linker script, EL0 tests
├── docs/ # Architecture, onboarding, ADRs, and full reference docs
├── kernel/
│ ├── boot/ # Flattened Device Tree (FDT) parser & memory/initrd/virtio discovery
│ ├── core/ # Freestanding type traits & logging (traits.hpp, log.hpp)
│ ├── drivers/ # In-tree hardware drivers (GICv2, PL011, fw_cfg, framebuffer/ramfb, VirtIO)
│ ├── fs/ # VFS core, cpio, PageCache, rootfs, tmpfs, devfs (TTY/FB/evdev), and ext2
│ ├── hal/ # Architecture-agnostic HAL traits & target backends (qemu_virt)
│ ├── input/ # InputEvent & InputQueue
│ ├── ipc/ # Encapsulated Pipe implementation (Pipe.hpp / Pipe.cpp)
│ ├── loader/ # ELF64 parser & executable/interpreter loader (elf64, elf_loader)
│ ├── mm/ # Page, PageFrameAllocator, KernelHeap, AddressSpace
│ ├── net/ # NetworkDevice & AF_UNIX socket implementation
│ ├── process/ # Process, FdTable, FileDescriptor, SignalTable, Scheduler, WaitQueue, StackBuilder, resource
│ ├── runtime/ # Freestanding C++ ABI support (cxx_abi.cpp)
│ ├── shell/ # Interactive kernel shell (milo>) & runtime test suite
│ ├── sync/ # RAII synchronization primitives (IrqGuard.hpp)
│ ├── syscalls/ # Modular Linux AArch64 syscall handlers & dispatcher
│ ├── time/ # Time::Duration domain wrapper
│ ├── uapi/ # Compile-time verified Linux AArch64 UAPI structs & constants
│ ├── kernel.mk # Kernel build rules
│ └── main.cpp # Kernel entry point (kmain)
├── scripts/ # Build, quality report, license check, LOC, and dump helpers
├── tests/
│ └── host/ # Host-compiled snitch unit tests, HAL mocks & .clang-tidy
├── user/ # Sample EL0 user programs
├── LICENSE # GNU General Public License v3.0
└── Makefile # Top-level build, QEMU runner, initrd packaging, host tests, and quality gates
To build, test, and run Milo locally:
- Cross Compiler:
aarch64-linux-gnu-g++,aarch64-linux-gnu-as,aarch64-linux-gnu-ld,aarch64-linux-gnu-objcopy - Host Compiler (for
HOST_TEST):g++(C++20) withsnitchandgcovr - Emulator:
qemu-system-aarch64 - Quality Tools (Optional):
clang-format,clang-tidy - Debugger (Optional):
gdb-multiarch
The aarch64-linux-gnu triplet is used to match the Linux AArch64 user-space ABI/syscall convention while compiling bare-metal freestanding code.
The .devcontainer/devcontainer.json configuration provisions the cross-toolchain, QEMU, snitch, gcovr, and lint tools automatically.
To allow namespace creation inside the container without --privileged or CAP_SYS_ADMIN, runArgs configures:
--security-opt=seccomp=unconfined— permitsclone/unsharenamespace syscalls blocked by Docker's default seccomp profile.--security-opt=apparmor=unconfined— permits mount-namespace setup blocked by Docker'sdocker-defaultAppArmor profile (and required on Ubuntu 24.04+ / Pop!_OS 24.04 hosts with AppArmor userns restrictions).
Linux host prerequisites:
- Ensure the host kernel allows unprivileged user namespaces (
sysctl user.max_user_namespaces> 0, andsysctl kernel.unprivileged_userns_clone=1on distributions that expose it). - On Ubuntu 24.04+ hosts with
kernel.apparmor_restrict_unprivileged_userns=1, keep--security-opt=apparmor=unconfinedenabled inrunArgs(and rebuild/reopen the devcontainer after changingdevcontainer.json).
make allBoots build/kernel.bin (with initrds/busybox.cpio and disk.img) on QEMU virt:
make runTo exit QEMU, press Ctrl+A then X.
make test-hostmake setup-musl
make setup-busybox
make setup-bashmake format # Format codebase with clang-format
make license-check # Verify SPDX and copyright headers
make quality # Verify formatting, license headers, clang-tidy, and host tests- Launch QEMU listening for GDB on port
1234:
make debug- Attach GDB in another terminal:
make gdbmake cleanOnce booted, the milo> shell provides built-in diagnostics and verification commands, including:
help/info/clear/halt— System info (EL, MMU/cache status, PFA frames), terminal control, and CPU halt (wfi).ls initrd/cat initrd <path>/elf initrd <path>— Inspect CPIO initrd entries, file contents, and ELF64 headers/segments.sh/bash— Launch an interactive/bin/shor/bin/bashsession from the initrd.- Subsystem & EL0 verification commands (
test cpu,test mmu,test el0,test cpp,test svc,test abort,test pfa,test ro,test nx,test sys,test cpio,test elf,test elf_interp,test dyn_exec,test vmm,test vma_mmap,test file_vma,test page_cache,test loader,test user,test user_echo,test uxn_fault,test syscall,test tty_echo,test user_mm,test proc_exit,test fork_exec,test musl,test sched,test heap,test dynamic_io,test refcount,test cow,test demand_paging,test lazy_mm,test virtio,test gpu,test fb,test input,test net,test af_unix,test unix_sock,test blk,test stack_abi). test all— Run the full integrated in-kernel verification suite.
- Decoupled Driver Development Kit (DDK): Introduce public
include/ddk/interfaces (Driver,PlatformServices, and RAIIMmioRegion/DmaBuffer/IrqHandle) and a top-leveldrivers/tree isolated from privatekernel/headers, with out-of-tree build support. - Additional Drivers & Storage: Migrate
virtio_blkto the DDK, expand persistent filesystem support (ext2), and add additional peripheral/networking drivers. - Multi-Architecture Expansion: Implement HAL backends for additional targets (e.g.,
x86_64,riscv64) underarch/.
Distributed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for details.