The forgetful CPU (Linux on M4)
This blog post delves into the author's experience of booting Linux on their M4 Mac mini. They express gratitude to the Asahi Linux team for their contributions and encourage donations to support further development on Apple Silicon. In November 2024, the author purchased an M4 Mac mini, expecting it to be similar to previous Apple Silicon machines and easily supported in Asahi Linux.
However, they soon discovered that the M4 machines were the first generation to mandate SPTM (Secure Page Table Monitor), a feature that provides hardening against vulnerabilities in the XNU kernel of macOS.
The author initially attempted to boot Linux using m1n1 hypervisor-based techniques, which relied on MMIO traces from previous generations. With SPTM enabled, this approach became more challenging, necessitating significant modifications to the hypervisor. Despite these obstacles, the author persevered in their efforts to boot Linux on the M4.
Throughout the process, the author faced numerous hurdles, such as disabling strict boot security, obtaining a serial console, and modifying the Linux kernel to bypass MMU-related issues. Eventually, they managed to get the kernel to boot to a shell, allowing them to further investigate the problem.
As they delved deeper into the issue, the author discovered that the missing stdout-path = serial0 in the device tree was causing the lack of printk output on the serial console. Once they added this parameter, they were able to obtain register dumps and stack traces, revealing valuable information about the boot process.
Despite the progress made, the author encountered another mysterious crash during the boot process. They attributed this issue to the WFI (Wait For Interrupt) instruction, a behavior specific to previous Apple Silicon CPU generations. After investigating the XNU OSS code, the author found a solution by modifying the Linux kernel to handle the WFI instruction correctly.
In summary, this blog post provides a detailed account of the author's journey to boot Linux on an M4 Mac mini, highlighting the challenges they faced due to the unique features of the M4 SoC, such as SPTM and the WFI instruction. Through persistence and meticulous debugging, the author successfully booted Linux on their M4 Mac mini, showcasing the potential of Asahi Linux for Apple Silicon devices.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.