How Linux was ported to the Apple Silicon M1 Mac mini
Linux now works on the Mac mini with M1 processor -- but Apple did not make it easy for the team to port the OS with its custom firmware and unique data paths. Here's how Corellium got it done.

Firefox running on Linux Ubuntu
Now that Linux is fully usable on Macs with M1 processors the team at Corellium has detailed their process for porting the OS.
In Thursday's post, Corellium says that they have been studying Apple's custom processors since the iPhone 6 released in 2014. The company used some exploits and the previous study to build a kernel port to the A10 processor in early 2020.
Apple released the Macs with M1 processor in November 2020. A follow-on OS update enabled users to install custom kernels. Following the addition of that ability, the Corellium team began working on a Linux port.
Corellium says that the M1 shares a lot of components with Apple's A-series processors. However, that only helps insomuch that Apple doesn't use the standards set forth by other ARM manufacturers.
The Corellium team broke down the exact challenges they faced when porting Linux.
Apple designed its own controller that was outside the usual ARM Generic Interrupt Controller (GIC) standards. The timer interrupts are routed to the Fast Interrupt Request (FIQ), which is not standard and reflects an older 32-bit ARM system. The team says that you have to provide a set of inter-processor interrupts (IPIs) to get multiple processors to communicate.
The Corellium team had experience dealing with FIQ support and were prepared for most of Apple's non-standard approaches. In the end, the team added a pre-loader that acts as a wrapper for Linux, which led to the OS booting on the M1 processor.
The team did not have an interface cable for the M1 Mac and had to find an alternate input route. Out of the three options -- Bluetooth, the USB Host, or the xHCI USB host on PCIe -- they chose the USB host and had to interact with a chip on I2C.
After they had a proper USB connection they could connect a keyboard, mouse, and flash drive. This opened up the possibility for running a normal desktop Linux distribution.

Firefox running on Linux Ubuntu
Now that Linux is fully usable on Macs with M1 processors the team at Corellium has detailed their process for porting the OS.
In Thursday's post, Corellium says that they have been studying Apple's custom processors since the iPhone 6 released in 2014. The company used some exploits and the previous study to build a kernel port to the A10 processor in early 2020.
Apple released the Macs with M1 processor in November 2020. A follow-on OS update enabled users to install custom kernels. Following the addition of that ability, the Corellium team began working on a Linux port.
Corellium says that the M1 shares a lot of components with Apple's A-series processors. However, that only helps insomuch that Apple doesn't use the standards set forth by other ARM manufacturers.
The Corellium team broke down the exact challenges they faced when porting Linux.
The technical details
The Corellium team says Apple doesn't boot its CPUs using traditional means. First, the bootloader runs an executable called Mach object file format (Mach-O) wrapped in a signed wrapper format called IMG4. It gets even more complicated as more CPU cores are brought up, as they start at an address specified by a Memory-mapped I/O (MMIO) register then begin running the kernel.Apple designed its own controller that was outside the usual ARM Generic Interrupt Controller (GIC) standards. The timer interrupts are routed to the Fast Interrupt Request (FIQ), which is not standard and reflects an older 32-bit ARM system. The team says that you have to provide a set of inter-processor interrupts (IPIs) to get multiple processors to communicate.
The Corellium team had experience dealing with FIQ support and were prepared for most of Apple's non-standard approaches. In the end, the team added a pre-loader that acts as a wrapper for Linux, which led to the OS booting on the M1 processor.
The team did not have an interface cable for the M1 Mac and had to find an alternate input route. Out of the three options -- Bluetooth, the USB Host, or the xHCI USB host on PCIe -- they chose the USB host and had to interact with a chip on I2C.
After they had a proper USB connection they could connect a keyboard, mouse, and flash drive. This opened up the possibility for running a normal desktop Linux distribution.

Comments
Apple should just document their hardware properly, after all, they sell hardware, not software. If people want to run Linux or some other OS on their hardware shouldn’t bother them, it’s not like documenting some instruction sets and boot sequence details allows anyone to clone their chip designs or something like that; and security should never rely on obscurity, but on well documented processes.
So it sounds like they can show a static image on the screen, but there's still work to be done to get a full blown desktop environment (or even a terminal for that matter). That said, if they know how to use the framebuffer, it shouldn't take too long to get CPU-based graphics up and running. Which will be good enough for the Linux server market.
I'm sure they have everything documented internally for their engineers. However, publishing takes time and resources. Which Apple certainly has, but the question is where those resources are best spent. Especially since everything shared with the Linux community will eventually make its way into Android, and thus into competing products. I really wish I could be as idealistic about Linux as I was 20 years ago since it's a great platform for budding engineers. But I just can't stomach seeing what's happened to it in the hands of opportunistic people who have no ethics.
So the real question is: Does getting Linux running on the M1 move us any closer to getting Windows running on M1? The answer to that question is the only thing that really matters to me. The follow up question of course is if we get Windows running on M1, what does that mean for the x86 Windows apps that I need to run on it? If the answer to my second question is “none of your x86 apps will be supported” then I’m going to step out of the queue and buy a Windows PC that’s good enough to run the few x86 Windows apps I need to run. That’s not a huge burden.
The only real sticking point I now have with the fallback of buying a “good enough” PC to handle my legacy needs, which include 4K @ 60 Hz support, is that I’m staring at the new M1 Mac Mini and realizing what a high quality beast it represents for the money. I know I can go the Intel NUC route, but I’ve worked with NUCs and they just aren’t as refined or as stable as a Mac. With M1, the performance of the lowest cost Mini rivals the higher end, fan crazy, sketchy driver, integrated graphics NUCs. Yeah, I can snatch an Intel Mini before they disappear, but the price-performance ratio (bang for the buck) pales against the M1 Mini. The M1 changed the dynamic and forever skewed my expectations. Perhaps a compromise solution is to be had from one of the newer AMD Ryzen small form factor units like the ASUS PC PN50. Who knows? But these M1 Macs, even this first round lower end offerings , have raised the bar and diminished the perceived value of a lot of competitors in the same market segment. The next round of second generation and “Pro” Apple Silicon Macs will undoubtedly do the same thing to their market segment.
The vast majority of domain specific (vertical) applications that I have encountered in (non tactical) military/aerospace, retail automation, manufacturing, industrial automation, and industrial networking over the past 30 years are Windows based. It had nothing to do with finding the lowest bidder. It had everything to do with the availability of development resources (programmers, platforms, languages, development and deployment tools, etc.) and the availability of commodity computers to run them on, including hardened/industrialized versions of WinTel computers configured as clients, servers, desktops, and embedded. I have never seen a Mac/Apple computer used in a vertical application but I'm sure they do exist. Linux and Unix, yes, but Macs? Nope. I've used Macs for high level design and business productivity, office apps, but never deployed in a vertical application.
Outside of platform-specific, or in the case of Apple, brand specific enthusiast groups like AppleInsider a lot of folks see computers as simply being appliances and tools to help them do a job or perform a certain set of tasks. The tools they need to use determines their choice of computer, not the other way around. I happen to need a Windows PC to run some of the tools I need to run. I can either stand up a Windows box, physical or virtual, to meet my need, develop the tool I need from scratch, or go without. There's nothing archaic about having to make choices.