|
| 1 | ++++ |
| 2 | +date = "2026-06-30T20:30:00+10:00" |
| 3 | +draft = false |
| 4 | +title = "Progress Report: Linux 7.1" |
| 5 | +slug = "progress-report-7-1" |
| 6 | +author = "James Calligeros" |
| 7 | ++++ |
| 8 | + |
| 9 | +Linux 7.1 is now here, and of course with it comes another progress report. We've got M3 |
| 10 | +progress, Apple bugs, and more! |
| 11 | + |
| 12 | +## Welcome back Master Boot Record |
| 13 | +When you long-press the power button on your Mac to bring up the boot picker (or use the |
| 14 | +Startup Disk application), what you see listed as Asahi is not actually the partition |
| 15 | +with the operating system on it. Apple's boot tooling will only work with what it considers |
| 16 | +to be a "valid" macOS installation inside an APFS container. So that we can use Apple's |
| 17 | +bootloader and avoid needing users to run commands from Recovery every time they want to |
| 18 | +use Asahi, the Asahi Installer creates a small APFS container (2.5 GB) with just enough |
| 19 | +of macOS on it to convince Apple's tools that it is a bootable installation of macOS with |
| 20 | +m1n1 as its kernel. This arrangement worked completely unchanged from macOS 12 to macOS 26, |
| 21 | +and Apple even fixed a couple of bugs in their tools that are only encountered when attempting |
| 22 | +to boot raw binaries that are not a real XNU kernel. |
| 23 | + |
| 24 | +Shortly after the release of the macOS 27 Golden Gate developer beta however, we began |
| 25 | +receiving reports that people were no longer able to boot into Linux on their |
| 26 | +machines --- the option had simply disappeared from both Startup Disk and the boot picker! |
| 27 | +Obviously this is quite concerning, and so we made investigating this a priority. |
| 28 | + |
| 29 | +Inspecting the disk using diskutil revealed that all Asahi-related partitions were still |
| 30 | +present on the disk after upgrading to macOS 27. No data loss was occurring, which is a |
| 31 | +positive sign. Additionally, Asahi was still bootable on the same machine when using the |
| 32 | +boot tooling from a second install of macOS 26. |
| 33 | + |
| 34 | +chaos_princess began inspecting Apple's own macOS Installer and old streams from way back |
| 35 | +when we were first poking at Apple's boot tools. The macOS Installer sets some APFS |
| 36 | +metadata before rebooting the machine, which further investigation revealed to be a flag |
| 37 | +that marks the volume as bootable. Until macOS 27, the boot tooling simply ignored this |
| 38 | +flag entirely. After setting the flag manually on an Asahi APFS container, it becomes |
| 39 | +available in the macOS 27 boot picker with no further changes. |
| 40 | + |
| 41 | +Going forward, all new Asahi installs will have this flag set automatically by the |
| 42 | +Asahi Installer. We've also added an installer mode that will fix existing installations. |
| 43 | +If you've installed the macOS 27 developer beta and cannot access your Asahi install, please |
| 44 | +run the installer again and use the "Fix macOS 27 boot picker compatibility" option. |
| 45 | + |
| 46 | +chaos_princess has also developed a program that can be run from Linux to fix the issue. |
| 47 | +While we would eventually like to deploy this fix automatically, we need more testing |
| 48 | +data to confirm that it is reliable and will not destroy anyones' filesystems. That's where |
| 49 | +you come in. If you are willing to help us test this, clone [this repo](https://github.com/AsahiLinux/asahi-fix27), |
| 50 | +then build and run it from Linux _before_ upgrading to macOS 27. If your Asahi volume |
| 51 | +is still selectable as a boot target from macOS, it has worked. Do be sure to let us |
| 52 | +know how it went by popping in to one of our [channels](https://asahilinux.org/community) |
| 53 | +on OFTC or Matrix, especially if you run in to any issues. |
| 54 | + |
| 55 | +## Three bytes forcing shutdowns |
| 56 | +macOS 27 also brings firmware updates for all peripherals with global firmware, including |
| 57 | +the SMC. One of the SMC's myriad functions is battery management. Our Linux power supply |
| 58 | +driver talks to the SMC to get information such as charge state, voltage, time until empty and |
| 59 | +battery health. The driver also uses the SMC's firmware interface to configure charge |
| 60 | +start and stop thresholds to prolong the life of the battery. macOS 27's SMC firmware |
| 61 | +changed one of the battery management interfaces from returning a 32-bit integer to |
| 62 | +returning a single byte. This change confuses our driver, which under certain conditions |
| 63 | +considers the battery as having failed and initiates an emergency shutdown to protect |
| 64 | +the system. We have already patched this in the downstream kernel; starting with version |
| 65 | +7.0.12, the power supply driver can deal with both firmware ABIs. |
| 66 | + |
| 67 | +## On installing betas |
| 68 | +Bugs like these are an important reminder that developer betas are just that, developer |
| 69 | +betas. It is ill-advised to install them on production machines. The two issues we |
| 70 | +have had so far have luckily minor, but that doesn't mean that all future issues will |
| 71 | +be too. Global firmware updates are effectively permanent too, and can only be rolled |
| 72 | +back with a DFU restore of the machine. Please refrain from installing developer betas |
| 73 | +going forward. We have sacrificial machines we use to test these things on your behalf, |
| 74 | +there is no need to risk your own expensive hardware and important data. |
| 75 | + |
| 76 | +## The more things change... |
| 77 | +Designing and validating computer platforms and the ICs that go into them is extremely |
| 78 | +expensive and time consuming, so it makes very little sense to make changes to existing |
| 79 | +designs when they are not necessary. Early on in the project, we made a bet that Apple |
| 80 | +would agree and refrain from making constant breaking changes to either. Discounting a |
| 81 | +few of the larger SoC blocks like the GPU that are almost required to change every |
| 82 | +generation, this bet has largely paid off. |
| 83 | + |
| 84 | +Audio on an Apple Silicon laptop involves a few different ICs and SoC blocks. The |
| 85 | +defacto industry standard for audio ICs is I<sup>2</sup>S, an I<sup>2</sup>C-based bus |
| 86 | +optimised for audio data. Apple's I<sup>2</sup>S controller has remained unchanged |
| 87 | +since M1. All of these audio ICs also need a stable clock source, which must be |
| 88 | +configurable to accommodate the wide variety of audio data rates. Apple's Numerically |
| 89 | +Controlled Oscillator (NCO) has also remained unchanged since M1. Apple have also used |
| 90 | +the exact same speaker and headset amplifier chips in almost all Apple Silicon machines. |
| 91 | +So, when chaos_princess started adding speaker and headphone jack support to M3 machines, |
| 92 | +little more was required than some trivial Devicetree additions and config files for |
| 93 | +asahi-audio and speakersafetyd. As such, M3 machines now sport high-quality audio output |
| 94 | +on Asahi Linux! |
| 95 | + |
| 96 | +M3 machines have also grown support for both CPU frequency switching and proper big.LITTLE |
| 97 | +task scheduling. Apple have not changed how CPU frequency switching works since the base |
| 98 | +M2, meaning that all M3 and M3 Pro/Max/Ultra SoCs required nothing more than Devicetree |
| 99 | +changes to work with our existing cpufreq driver. Tasks should now be more intelligently |
| 100 | +placed on either efficiency or performance cores according to their requirements, and the |
| 101 | +CPU cores themselves should clock up and down based on load. This will both save energy |
| 102 | +_and_ improve performance! |
| 103 | + |
| 104 | +Adding support for the SMC's hardware sensors was similarly trivial; the SMC's firmware is |
| 105 | +not materially different across machines, so once again nothing more than a few Devicetree |
| 106 | +changes was required here. |
| 107 | + |
| 108 | +On top of the above, we also have PCIe, WiFi, Bluetooth, NVMe, keyboard, trackpad, and |
| 109 | +other core SoC block drivers working in Linux for M3 series machines. Most of this work |
| 110 | +has come by way of [Yureka](https://fedi.yuka.dev/yuka), who has been very busy hacking |
| 111 | +on both m1n1 and Linux with her M3 series machines for a while now. We still have a ways |
| 112 | +to go before we can start enabling Asahi Installer support for these machines, but progress |
| 113 | +is rapid so watch this space! |
| 114 | + |
| 115 | +## We're writing firmware now? |
| 116 | +Most of the complicated hardware on this platform uses complicated firmware blobs. Most |
| 117 | +of this is based on RTKit, an RTOS-like firmware framework used by Apple to present a mostly |
| 118 | +standardised interface for the kernel to talk to the various bits of hardware. There are |
| 119 | +exceptions to this, however. Some blocks, like DCP and AOP, use RTKit as the basis for their |
| 120 | +firmware, but layer yet another set of abstractions called EPIC on top of it. Others still, |
| 121 | +like the Broadcom WiFi/Bluetooth chipset, use third-party firmware that Apple has no direct |
| 122 | +control over. Then, there's the Apple Video Decoder (AVD). |
| 123 | + |
| 124 | +AVD is special. Its firmware is neither RTKit nor EPIC, it's a secret third thing. The |
| 125 | +hardware itself is essentially an ARM Cortex-M3 controlling a series of fixed-function hardware |
| 126 | +units for decoding video frames encoded in AVC (H.264), HEVC (H.265), VP9, and AV1 on more recent |
| 127 | +SoCs. The CM3 runs a blob of firmware that exposes an interface for XNU to point it to video |
| 128 | +data, and then programs the actual decoder hardware itself. This would normally be fine, however |
| 129 | +Apple made the interesting choice of bundling both the AVD's firmware and a pile of configuration |
| 130 | +data _inside_ the AVD kext. Making matters worse, each SoC has a slightly different AVD variant. |
| 131 | +This is logistically challenging, as the Asahi Installer would have to constantly be updated |
| 132 | +with (and keep track of) Apple's changes to the offsets of the firmware data in the kext. |
| 133 | +We _could_ do this, but what if there's a better way? |
| 134 | + |
| 135 | +The firmware loaded by XNU is not verified by the CM3. It will begin executing from |
| 136 | +its reset vector when signalled, no matter what is actually there. What if we |
| 137 | +just... used our own firmware? |
| 138 | + |
| 139 | +Since the firmware is effectively just there to abstract away the underlying video |
| 140 | +decoder hardware, it doesn't actually matter what it does, so long as it installs |
| 141 | +interrupt handlers for the various hardware blocks. If we understand what the underlying |
| 142 | +hardware expects, we can just program it all from a Linux driver. To do this, we need |
| 143 | +to understand how the firmware drives each decoder. |
| 144 | + |
| 145 | +Being standard Cortex-M3 code, it is possible to run the AVD firmware in an emulator. |
| 146 | +A number of solutions exist to do this, including QEMU, which allows you to single-step |
| 147 | +your program and inspect bus and register operations. The groundwork for this was laid |
| 148 | +many years ago by Jamie, R and Eileen, who through a combined effort managed to reverse |
| 149 | +engineer the instructions and data formats required by the AVC and VP9 decoders. |
| 150 | + |
| 151 | +The XNU kext also applies a unique set of tunables to each AVD revision. We are not |
| 152 | +entirely certain what these do, so applying these essentially needs to be a replay of |
| 153 | +MMIO writes made by XNU. We need to keep track of each AVD revision, each set of tunables, |
| 154 | +and which revision they need to be applied to. This would be impossible to maintain |
| 155 | +satisfactorily in an upstream Linux kernel driver, so this should also probably live |
| 156 | +in firmware. |
| 157 | + |
| 158 | +While not much work happened on this front for a long time, new contributor [sofus](https://github.com/sofus13) |
| 159 | +recently stepped up to fill the gap. With a blob of custom AVD firmware that simply |
| 160 | +installs interrupt handlers and applies each variant's set of tunables, he was able to |
| 161 | +write a working V4L2 driver for the AVC hardware! The hardware can decode 10-bit AVC-encoded |
| 162 | +video up to 4K, and works well with software that implements the V4L2 Request API. |
| 163 | +Keeping the firmware basic and stateless, with userspace and the kernel being responsible |
| 164 | +for parsing all video data and programming the decoders themselves, also enables us to |
| 165 | +more easily support other video acceleration APIs like VA-API and Vulkan Video at some |
| 166 | +point in the future. |
| 167 | + |
| 168 | +There's still some work to do before we can ship AVD support to users. AVD supports VP9, |
| 169 | +HEVC and even AV1 on some SoCs, but we have not implemented support for any of these yet. |
| 170 | +Some devices also have quirks that must be tested and accounted for in the driver. We |
| 171 | +hope to have something shippable for you all in the not too distant future! |
| 172 | + |
| 173 | +## A large m1n1 release |
| 174 | +We have also recently tagged version 1.6.0 of m1n1. This is a consequential |
| 175 | +release for distros, as it is the first version that requires Rust for stage 2 |
| 176 | +builds. Previously, m1n1 only made use of Rust when built with chainloading |
| 177 | +support. Stage 1 m1n1 replaces the XNU kernel in Apple's boot tooling, and is used |
| 178 | +only to mount the EFI System Partition and chainload Stage 2 m1n1 from there. A |
| 179 | +little while ago however, we made the decision to move GPU initialisation into |
| 180 | +m1n1. This removed the need for the kernel driver to deal with the floating point |
| 181 | +numbers found in Apple's hardware initialisation data, and also greatly simplified |
| 182 | +the Devicetree bindings. The version of the GPU driver we eventually submit to |
| 183 | +the Linux Kernel Mailing List will therefore rely on m1n1 to do this initialisation |
| 184 | +for it. We also ported the Apple Device Tree parsing code to Rust, which is |
| 185 | +consumed by just about every other part of m1n1. |
| 186 | + |
| 187 | +Given that m1n1 is effectively firmware, it uses `no_std` Rust and targets `aarch64-none-softfloat`. |
| 188 | +To avoid pulling in superfluous dependencies, you can pass `BUILDSTD=1` to `make` to build `core` |
| 189 | +and `alloc` without requiring a full `softfloat` toolchain to be installed. |
| 190 | + |
| 191 | +Version 1.6.0 also brings a whole host of improvements to M3 series support, including |
| 192 | +support for the SPMI controller and PCIe initialisation. We also now support tunnelling |
| 193 | +the SoC's hardware UART directly over DebugUSB with [kisd](https://github.com/AsahiLinux/kisd), |
| 194 | +which can be used to achieve much the same functionality as the Central Scrutiniser. |
| 195 | +Much of this work is also courtesy of Yureka. |
| 196 | + |
| 197 | +We are also laying the groundwork for M4 and A18 Pro (MacBook Neo) support, with better |
| 198 | +handling of Apple's non-macOS boot mode and support for new power domain metadata found |
| 199 | +in the Apple Device Tree. |
| 200 | + |
| 201 | +## Thanks again! |
| 202 | +As always, we would like to thank our generous supporters on [GitHub Sponsors](https://github.com/sponsor/AsahiLinux) |
| 203 | +and [Open Collective](https://opencollective.com/asahilinux), without whom we would not be |
| 204 | +able to continue working on unfinished M1 and M2 features or work on M3, M4 and A18 Pro |
| 205 | +support while supporting our enthusiastic new contributors! |
0 commit comments