Heyang Zhou, one of the creators of the Deno Deploy platform, has published the XNU Linux project, which allows you to build and load the XNU kernel as a Linux kernel module and use it to run a macOS user environment on Linux. XNU is used in macOS, is part of the open-source Darwin project, and represents a hybrid kernel combining the Mach microkernel, FreeBSD kernel subsystems, and the C++ IOKit API for writing drivers. By loading XNU as a kernel module, you can run the standard macOS graphical environment within Linux, where macOS applications, including the Safari browser, will be executed.
The XNU kernel is built from the source code provided by Apple and runs in Linux in the form of the xnu.ko kernel module, which directly interacts with the CPU and the memory management unit (MMU), allowing processes of Linux and macOS to run side by side on the same 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, a foreign kernel interface module, fki.ko, has been created.
The module with the XNU kernel operates in its own address space — the XNU kernel receives a contiguous block of physical memory from Linux and manages it through its pmap, while part of the address space for user processes is used jointly in Linux and XNU. Each virtual CPU for macOS is designed as a Linux kernel thread, bound to a physical CPU core. Drivers are provided for accessing the disk image from macOS, as well as for display, keyboard, mouse, Ethernet, and GPU. The Metal graphics API is implemented on top of Vulkan through the metal2vulkan layer.
The linking module for the kernel and accompanying utilities developed by the project is distributed under the GPLv2 license, while the components of the XNU kernel module are provided under the APSL-2.0 license. Drivers XnuDisplay, XnuEthernet, and XnuInput, borrowed from the macOS-DroidVM project, are available under the BSD license. XNU Linux also utilizes developments from the UniXNU project, which allows running macOS and iOS on ARM64 systems not from Apple. The development of XNU Linux is carried out using the AI assistant Claude. As an example, a boot from an Apple installer-created system disk with macOS was demonstrated in Ubuntu Linux. Currently, only booting on Apple ARM computers with M1 chips and newer is supported.



Izvor: opennet.ru
