xnulinux: Apple’s XNU Kernel Running as a Linux Kernel Module

Conceptual AI-generated banner reading xnulinux, with a glowing terminal window

What is xnulinux?

xnulinux is an open-source project by Heyang Zhou and contributors. It builds XNU, the macOS kernel, from Apple’s published sources and loads it as a module (xnu.ko) inside an unmodified arm64 Linux kernel. The reported result is a full macOS desktop on top of a stock Ubuntu kernel, with no hypervisor in between.

How it works

  • Two modules: xnu.ko runs the XNU kernel under the APSL-2.0 licence, with a patch set adding a “LINUX64” machine layer. fki.ko, a GPL-licensed foreign kernel interface, lends Linux services to it: CPUs, memory, page faults, files and networking.
  • CPUs and memory: each hosted CPU is a Linux kernel thread pinned to a Linux CPU. Memory comes from one physically contiguous block allocated through Linux’s CMA, which XNU manages itself.
  • Virtual hardware: kexts supply a file-backed disk, framebuffer display, keyboard and pointer input, Ethernet and a GPU bridge.
  • Graphics: Metal calls are translated to Vulkan and sent to the host GPU through Mesa’s Venus driver. Without a GPU, rendering falls back to Mesa’s lavapipe on the CPU.

What works today (as reported)

  • It boots macOS 27.2.1 to an auto-login desktop in 31–48 seconds, against 49 seconds for an Apple Virtualization macOS VM on the same machine.
  • Finder, Safari, Spotlight, Notes and other apps open and quit.
  • A 30-minute stress run of 40 rounds finished with no kernel panic or crash report.
  • It can run as a systemd service.
  • The README also reports it booting to the desktop on a bare-metal NVIDIA DGX Spark, with CPU rendering for now.

Limits and requirements

  • Hardware: an arm64 Linux host with pointer authentication (FEAT_PAuth) and 4K pages, and at least 16 GB of RAM, 8 GB of it reserved for the hosted kernel (per the project README). Tested on Apple Silicon M1 or later inside a Linux VM, and on a DGX Spark.
  • Your own macOS: you supply your own macOS 27 install, and a Mac with Xcode is needed to prepare the disk. The repository ships no Apple binaries.
  • Security trade-offs: AMFI is patched and SIP is relaxed. Memory access is slower than in a native VM because of 4K pages instead of macOS’s usual 16K.
  • Licences: the Linux side is GPL-2.0-only and the XNU side is APSL-2.0. xnu.ko taints the kernel. The project is not affiliated with Apple.

Why it matters

Virtualization puts a hypervisor between guest and hardware, and compatibility layers reimplement APIs on a host kernel. xnulinux instead treats Linux as a host that lends hardware services to a second, complete kernel, so macOS processes run beside Linux ones on the same CPUs. Daily use is a long way off, given the relaxed security, Apple-hardware requirement and memory footprint, but as a systems hack it is a striking piece of engineering.

FAQ

Is this a virtual machine?

Not in the usual sense. The project says no hypervisor sits between macOS and the hardware, though the main tests ran inside a Linux VM on a Mac.

Can I run it on any PC?

No. It needs an arm64 host with the features above.

Is it legal to use?

It uses Apple’s published XNU sources and your own macOS install. Check Apple’s licence terms for your case; this is not legal advice.

Note: these details come from the project README and a secondary write-up, and have not been tested firsthand.

Sources: xnulinux on GitHub, @sysxplore on X, Deniz Genc’s write-up


Discover more from Juzhax Technology

Subscribe to get the latest posts sent to your email.

Leave a Reply