This article is more than 1 year old
Asahi Linux progress: Apple Silicon OS works – though it's 'rough around the edges' and has no GUI acceleration
Fascinating project but will it ever be practical?
Developer Hector Martin has reported on progress with Asahi Linux, a port for Apple Silicon Macs, and said that the OS now works but with some limitations, notably a lack of accelerated graphics.
In his August progress report, Martin talks further about the challenges of porting Linux to a platform that was created by Apple for the sole purpose of running its own operating systems.
He calls the M1, the Arm-based SoC (System on a Chip) used in the Mac Mini and iPad Pro, "a massive reverse engineering challenge." Rather than attempting to disassemble the macOS drivers, Martin created a hypervisor to sit between macOS and the M1 hardware, for the purpose of "transparently intercepting and logging hardware access."
Python code running on a separate machine can control the hypervisor.
One of the complications, Martin discovered, is that Apple added a co-processor to the display controller (DCP). He said that Apple "took half of their macOS C++ driver, moved it into the DCP, and created a remote procedure call interface so that each half can call methods on C++ objects on the other CPU! Talk about overcomplicating things."
The reverse engineering enabled Martin and his team to "implement enough of the interface to finally send display buffer swaps to the display. This allows us to implement tear-free graphics with double-buffering, hardware mouse pointer acceleration, framebuffer scaling and compositing, and more."
The DCP presents a complication since the exact interface of this firmware "changes every macOS version."
This means, Martin said, that Asahi Linux will have to support only specific firmware versions, though he is confident that "this firmware is per-OS, not per-system."
The first version of Asahi Linux is expected to support the firmware that comes with macOS 12 "Monterey", currently in preview. He added that it is not possible to replace the firmware with custom code "as it is loaded by iBoot before it hands control to the OS, and it is signed by Apple."
Applied math/s student Alyssa Rosenzweig, who describes herself as "a graphics developer passionate about software freedom," is working on a Gallium driver for the M1 GPU. A Gallium driver would enable OpenGL and OpenCL support as this is part of the Gallium framework.
- Linus Torvalds reluctantly issues one more release candidate for Linux kernel 5.12
- Asahi Linux devs merge effort to run Linux on Apple M1 silicon into kernel
- Asahi's plan for Linux on Apple's new silicon shows Cupertino has gone back to basics with iOS booting
- We turn away for a second and Corellium is already showing off Ubuntu on Apple Silicon
Another member of the team, Sven Peter, has been working on the Linux driver for the M1's IOMMU (I/O Management Unit). Peter's driver enables USB and PCIe to work "with minimal additional patches and drivers."
Martin reports that "it's already possible to use Asahi Linux as a development machine with a (non-accelerated) GUI, although things are still rough around the edges." Patches are being submitted to the Linux kernel. Martin said that the next step is to "tackle the GPU kernel driver."
Corellium, the company with which Apple recently settled a copyright lawsuit over its virtual iPhone service, also has a Linux port for M1. After a public disagreement in January, the two teams posted conciliatory tweets and now appear to be cooperating.
Last weekend, Rosenzweig submitted "a PCIe driver for the internal bus on the Apple M1" to the Linux kernel mailing list. "It's based on the work of Marc Zyngier, Mark Kettenis, and Stan Skowronek (Corellium)," she said, adding: "I've started using Linux on M1 as my workstation for Panfrost development, so this should have 40 hours of testing by this time next week," Panfrost being an open-source driver project for Arm Mali GPUs.
The work on Asahi Linux is fascinating and educational for those interested in the workings of modern hardware. It is also dependent on Apple continuing to allow booting unsigned kernels on Apple Silicon Macs, which the Asahi team take as evidence that "unlike iOS devices, Apple does not intend to lock down what OS you can use on Macs."
Combined with the dependence on Apple firmware that can change, and the general difficulty of building an OS on hardware the specification for which is reverse engineered, it is obvious that the team face considerable challenges. At the same time, in a world of app stores tightly controlled by giant corporations, the significance of open-source operating systems has never been greater. ®