deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

XNU as a Linux kernel module: macOS 27 desktop boots on stock arm64 Linux

xnulinux loads a source-built XNU kernel into a stock arm64 Linux kernel as a module, booting macOS 27.2.1 to a full desktop with Safari, Finder and a Vulkan-based GPU bridge — no hypervisor required.

XNU as a Linux kernel module: macOS 27 desktop boots on stock arm64 Linux

The xnulinux project has run Apple's XNU kernel as a loadable module inside an unmodified arm64 Linux kernel, booting a full macOS 27 desktop — loginwindow, WindowServer, Dock, Finder, Safari and Chrome — with no hypervisor in between. The repository, published on GitHub under the account AFK-surf and copyrighted by Heyang Zhou and contributors, reached Hacker News's front page on 23 November.

According to the project's documentation, the code builds XNU from Apple's published sources (xnu-12377.121.6) and packages it as xnu.ko. On a stock Ubuntu kernel, loading that module boots a macOS system disk created by Apple's own installer all the way to the desktop. The hosted XNU drives the CPU and MMU directly, so macOS processes execute natively on the same processors as Linux processes, and Linux supplies memory, timers, files, network and GPU access through a small companion module.

How it works

The design splits along a narrow interface. On one side, xnu.ko loads and runs the XNU kernel collection under the APSL-2.0 license, modified by a patch set that adds a "LINUX64" machine layer. On the other side, fki.ko — a GPL-licensed module the project calls the foreign kernel interface — exposes Linux CPUs, memory, page faults, inter-processor interrupts, files and networking. The XNU side is permitted to touch Linux only through fki_* calls.

Each hosted CPU is a Linux kernel thread pinned to a Linux CPU; XNU runs on it until it needs the host for idle, I/O or a timer, and fki.ko forwards faults and user exceptions from XNU code back to XNU's own handlers. Memory comes from one physically contiguous block allocated through Linux's CMA, which XNU then manages with its own pmap; the two kernels share the user half of the address space layout on 4K pages. Kexts supply virtual hardware: a disk backed by a Linux file, a framebuffer display, keyboard and pointer input, Ethernet, a keystore and a GPU bridge.

Graphics is handled by translating Metal calls to Vulkan via metal2vulkan, then routing Vulkan through a DRM bridge to the host's render node using Mesa's Venus driver; when no GPU is available, rendering falls back to Mesa's lavapipe on the CPU.

What works today

Testing so far was done on an Apple Silicon Mac running an arm64 Linux virtual machine (via krunkit) with one to six hosted CPUs. The project reports that macOS 27.2.1 boots to an auto-login desktop in 31–48 seconds, versus 49 seconds for an Apple Virtualization macOS VM on the same machine. Applications open and quit, Spotlight and the filesystem work, and a 30-minute stress run of 40 rounds across Safari, Notes, Calculator, TextEdit, System Settings, Spotlight and a disk walk completed with no kernel panic or crash report. The hosted system can run as a systemd service that starts at boot, stops cleanly with the VM and restarts after a hosted-kernel panic.

The project's own production notes list the gaps: the OS cryptex is merged into the system volume, AMFI is patched and SIP is relaxed, and memory access is slower than in a native VM because of 4K pages instead of macOS's usual 16K.

Requirements and licensing

Running it requires an arm64 Linux host with pointer authentication support — Apple Silicon M1 or later inside a VM, using krunkit for GPU access or tart — plus 4K pages and roughly 24 GB of RAM, 8 GB of it reserved for the hosted kernel. A Mac with Xcode is needed to prepare the system disk and build the GPU components, and users must supply their own macOS 27 installation; the repository distributes no Apple binaries, and the kexts, system disk and trust cache all come from the user's own install.

The license split is deliberate: the Linux side is GPL-2.0-only and the XNU side APSL-2.0, meeting only at the FKI boundary. xnu.ko declares itself a non-GPL module and taints the kernel the same way ZFS modules do, and the project forbids it from including Linux headers beyond the module ABI or calling anything other than fki_* functions. The README credits macOS-DroidVM and UniXNU for the 4K-page XNU base, the Linux-hosted toolchain and several kexts, and notes the project is not affiliated with Apple.

Why it matters

This inverts the usual ways of running macOS somewhere else. Virtualization inserts a hypervisor between guest and hardware; compatibility layers reimplement APIs on top of a host kernel. xnulinux instead treats Linux as a host that lends hardware services to a second, fully sovereign kernel, with the guest's processes scheduled as ordinary work alongside Linux's own. The result is closer to a kernel-level personality — one machine, two complete userspaces, each with its own window server and native applications — than to a VM, and the reported boot times already rival Apple's own virtualization stack. It also underlines that XNU, like Linux, is genuinely buildable open source: Apple's published sources plus a new machine layer were enough to retarget it. Daily use remains distant given the relaxed security settings, the Apple-hardware requirement and the large memory footprint, but as a systems hack — XNU loaded with insmod — it is a remarkable piece of engineering.

  • #macos
  • #linux-kernel
  • #xnu
  • #arm64
  • #open-source

Related posts