xnulinux
xnulinux builds Apple's open-source XNU kernel and runs it as a loadable module inside an unmodified arm64 Linux kernel, letting macOS userspace run alongside Linux processes without a hypervisor.
Visit AFK-surf/xnulinuxOverview
xnulinux builds XNU, the open-source kernel of macOS, from Apple's published sources and runs it as xnu.ko inside an unmodified arm64 Linux kernel. A companion fki.ko module provides CPUs, memory, timers, files, network, and GPU access. With a stock Ubuntu kernel, insmod xnu.ko boots a macOS 27 system disk made by Apple's installer to the desktop, with macOS processes running natively alongside Linux processes on the same CPUs.
Key Features
- XNU runs as xnu.ko inside an unmodified arm64 Linux kernel, with no hypervisor between hosted macOS and Linux.
- fki.ko supplies the foreign kernel interface for CPUs, memory, faults, IPIs, files, network, and host calls.
- macOS processes and Linux processes run natively on the same CPUs; each hosted CPU is a Linux kernel thread pinned to a Linux CPU.
- Devices are provided through kexts for disk, display, keyboard and pointer, Ethernet, keystore, and a GPU bridge.
- Metal support can use gpu/xnu-cpu-metal over Vulkan and a DRM bridge, with CPU rendering as fallback when no supported DRM backend is present.
- Runs on stock distro kernels, demonstrated with Ubuntu and on an NVIDIA DGX Spark.
Use Cases
- Running a macOS 27 desktop and macOS applications on an arm64 Linux host without a hypervisor.
- Studying or experimenting with two kernels sharing CPUs, memory, faults, and devices through a foreign kernel interface.
- Exploring kernel internals, MMU behavior, and device handoff between XNU and Linux.
- Using a hosted macOS system alongside Linux processes, such as an SSH session from hosted macOS into the underlying Linux.
Getting Started
- On the arm64 Linux host, run scripts/vm-xnu-build.sh once to set up the toolchain and build XNU xnu-12377.121.6 natively.
- Run scripts/vm-xnu-rebuild.sh to apply xnu-patches, build the kernel and kexts, and link the kernel collection with Apple's kexts from your macOS installation.
- On the Mac, run scripts/mk-macvm-disk.sh to turn a macOS VM disk made by Apple's installer into the hosted system disk and copy it into the Linux VM.
- On the arm64 Linux host, run scripts/xnulinux-boot.sh to build fki.ko and xnu.ko against the running kernel, bring up networking and the optional GPU bridge, and boot the hosted system.
- Optionally run scripts/install-service.sh to run it as xnulinux.service configured in /etc/xnulinux.conf; on the Mac, scripts/install-krun-agent.sh keeps the VM running.
Deployment & Requirements
- An arm64 Linux host with PAC (FEAT_PAuth), 4K pages, and at least 16 GB of RAM, with 8 GB reserved for the hosted kernel.
- A Mac with Xcode to make the system disk and build the GPU parts.
- A macOS 27 installation from an Apple Virtualization VM disk of your own; no Apple binaries are included or distributed by the repository.
- Tested on NVIDIA DGX Spark bare-metal Ubuntu 24.04.5 LTS aarch64 with Linux 7.0.0-1025-nvidia, and on an Apple Silicon Mac M1 or later running an arm64 Linux VM via krunkit or tart.
- For bare-metal hosts, set the carve-out (mem=, carve_base=, carve_mb=) and set GPU=off because xnudrmd supports only virtio-gpu for now.
Before You Adopt
- License: Other. Review its terms before using, modifying, or distributing the project.
- The project is explicitly experimental and systems-level.
- The working configurations are described as narrow, with two arm64 Linux setups demonstrated.
- The Apple kexts, macOS system disk, and trust cache must come from the user's own installation.
- The module is reported as non-GPL, which taints the Linux kernel as ZFS does.