Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

README: M2c, M2e status

Heyang Zhou7288c0381018
diff --git a/README.md b/README.md
index ccde0d4..42d414a 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,10 @@ The two sides are kept apart by license and only meet at the FKI (foreign kernel
- **M1 (done, 2026-11-20).** A source-built XNU (`xnu-12377.121.6` plus the macOS-DroidVM patch series, arm64e) is loaded by `xnu.ko` into a stock Ubuntu 24.04 kernel (`7.0.0-43-generic`, 4K pages, PAC). It is slid and PAC-signed with XNU's own kernel keys, and XNU code runs inside Linux. XNU's `strlen` and `crc32` results match a reference computation.
- **M2a (done, 2026-11-20).** `arm_init` runs inside the module from `xnu.ko`'s boot args and ADT up to `arm_vm_init` (stage 199), with XNU's `kprintf` in dmesg. Next is M2b: a LINUX64 `arm_vm_init` and pmap on FKI.
- **M2b (done, 2026-11-20).** XNU runs at its own link address on physically contiguous memory with real PAs. `arm_vm_init` builds its kernel page tables, `xnu.ko` installs XNU's 48 kernel L1 entries into Linux's top-level L1 (the free `L1[384..495]` of `L0[511]`), and the hardware walks XNU's own tables. `pmap_bootstrap` runs, and XNU prints `kprintf initialized` to dmesg. Then (M2c, 2026-11-20) `machine_startup` → `kernel_bootstrap` runs to the end: zalloc/kalloc, scheduler, Mach IPC, tasks and threads; `load_context` switches to `kernel_bootstrap_thread`, which creates the idle thread, starts the scheduler, thread calls, clock service, kdp and sysctl, and reaches `PE_init_iokit`. Next: IOKit (`PE_init_iokit`), then timers/IPIs on FKI and real kthreads.
+- **M2c (done, 2026-11-20).** The bare kernel runs `kernel_bootstrap_thread` through IOKit to `bsd_init` (VFS, mbufs, MAC, audit, aio), with a cooperative timer (XNU idles into the host, which delivers its timer), a virtual interrupt flag (hardware IRQs stay masked on XNU stacks), host-reported `assert`s and panics, and stand-ins for what the kexts would register.
+- **M2e (in progress, 2026-11-20).** `xnu.ko` loads a fileset kernel collection: our kernel plus 53 of Apple's macOS 27.2 kexts (vma2 kernelcache, linked with macOS-DroidVM's `kc-build27.py`; Apple's binaries stay local). XNU applies the collection's chained fixups and signs it itself. Kernel page faults on XNU addresses are forwarded by FKI (`fki_fault_register`) to XNU's `vm_fault`; a fault nothing resolves ends the run cleanly instead of taking the host down. Apple's corecrypto (FIPS POST passes), AppleImage4, AMFI and Sandbox initialize; the ADT carries the `/chosen` a bootloader would pass (boot manifest hash, AP identity, NVRAM, SIP) and `/options`. `bsd_init` runs through networking and Skywalk to `IOFindBSDRoot`, waiting for a root device. Next: a root device (an FKI block endpoint or a RAM disk), NativeAES and AKS for AppleImage4 and AMFI, then `launchd` (M3).
+
+Debugging: the VM console is captured on the host (`scripts/serial-pty.py`), a monitor thread on another CPU prints XNU's counters every 2 s, and XNU dumps its threads with their saved frames after 20000 idle rounds.
## Running M1