Heyang Zhou, one of the creators of the Deno Deploy platform, published the XNU Linux project, which allows for the compilation and loading of the XNU kernel as a kernel module in Linux, enabling the execution of a macOS user environment within Linux. XNU is used in macOS, is part of the open-source Darwin project, and represents a hybrid kernel that combines the Mach microkernel, FreeBSD kernel subsystems, and the C++ IOKit API for writing drivers. By loading XNU as a kernel module, it is possible to run the native macOS graphical environment within Linux, where macOS applications, including the Safari browser, can operate.
The XNU kernel is built from the source code provided by Apple and runs in Linux as the kernel module xnu.ko, which interacts directly with the CPU and memory management unit (MMU), allowing both Linux and macOS processes to run side by side on a single CPU without the need for a hypervisor. To allow the XNU kernel access to memory, files, timers, exception handling, networking, and GPU through the Linux kernel, the fki.ko (Foreign Kernel Interface) module has been created as a bridging layer.
The module with the XNU kernel operates in its own address space—the XNU kernel receives a continuous block of physical memory from Linux and manages it through its pmap, while part of the address space for user processes is shared between Linux and XNU. Each virtual CPU for macOS is represented as a Linux kernel thread pinned to a physical CPU core. To access the disk image of macOS, display, keyboard, mouse, Ethernet, and GPU, bridging drivers are provided. The Metal graphics API is implemented on top of Vulkan through the metal2vulkan layer.
The bridging kernel module and accompanying utilities are distributed under the GPLv2 license, while components of the XNU kernel module are provided under the APSL-2.0 license. The drivers XnuDisplay, XnuEthernet, and XnuInput, borrowed from the macOS-DroidVM project, are available under the BSD license. The XNU Linux project also leverages work from the UniXNU project, which allows macOS and iOS to run on ARM64 systems not made by Apple. Development of XNU Linux is being conducted using the AI assistant Claude. As an example, the booting of a macOS system disk in Ubuntu Linux, created by Apple's installer, has been demonstrated. Currently, only booting on ARM computers by Apple with M1 chips and newer is supported.



Kilde: opennet.ru
