10 ms·
How We Ported Linux to the M1
- Pasorrijer 6y agoI love this for a few reasons. First off, we get to see a deeper look into what Apple did, and I'm enjoying how they went outside the established norms... Sometimes the Apple cart (pun not intended) needs overturning. Secondly, the fact that they are able to dig into this much depth bodes well for competitors to reverse engineer similar performance into other platforms
- jbob2000 6y agoComputers used to be a "commodity of commodities". The motherboard was made by one manufacturer, the memory was made by another one, the CPU by a different one, etc. etc. Unless a competitor controls and owns their supply chain like Apple does, I don't see how they can compete; they need those "established norms" otherwise they won't be able to find commodities that work with their final product.
- spijdar 6y agoComputers being "commodities of commodities" is kind of a recent phenomenon. For a while, the norm was to do exactly what Apple is doing. It was much more common to design and market your own custom processor or, at the least, custom chipsets coupled with your own firmware/OS, like most unix workstations, non-IBM-PCs like the Amiga, Atari, Macs... It'll be interesting to see if any other players try to move back to this style in the desktop/laptop PC space.
- AnIdiotOnTheNet 6y agoPersonally I think that could be a good thing if it allows us to once again become experimental with personal computing operating systems, an are that has stagnated significantly in the past 2 decades due in part to the fact that any new contender has to support a ludicrous amount of hardware to be usable on a wide variety of PCs. Then again it could all go horribly wrong and leave us with nothing but highly locked-down terminals suitable only for connection to our glorious cloud masters.
- spideymans 6y agoAlso innovation in the PC space has pretty much been limited by whatever Intel is willing to accommodate. I'm happy we're beginning to move away from this.
- ryukafalz 6y agoThe flip side to that is that OSes that are built for specific hardware are only useful so long as that hardware continues to be produced. I don't think we'd have Linux as a useful contender today if it had been locked to a specific company's hardware; there's a reason we're not still using BeOS today for example (Haiku aside). I'm more excited about things like rump kernels for hardware support across disparate OSes: https://en.m.wikipedia.org/wiki/Rump_kernel https://en.m.wikipedia.org/wiki/Rump_kernel
- spijdar 6y ago> there's a reason we're not still using BeOS today for example (Haiku aside). You're blaming BeOS's failure on the BeBox? Every release of BeOS that was marked as a "full release" (as opposed to a developer preview or a "preview release") could run on Intel hardware, and the BeBox itself was discontinued long before then. This is a tangent, but I don't understand people who think BeOS was the heir-apparent to consumer/home/personal OSes. It had super half baked networking support and absolutely no concept of multi-user or privilege separation. Similar home OSes didn't enforce privilege separation or multiple users, but at least had the framework -- BeOS essentially just runs everything as root. It had some neat tricks, but was a pretty underdeveloped OS in some key areas. The fact it never took off isn't that surprising to me, and it's not just because Be was a small company or that it's hard for an underdog to get market share in a crowded space (both of which are also true). It just wasn't really well suited for "general purpose computing" in the same way that e.g. Linux, WinNT, or Darwin are.
- AnIdiotOnTheNet 6y ago> This is a tangent, but I don't understand people who think BeOS was the heir-apparent to consumer/home/personal OSes. It had super half baked networking support and absolutely no concept of multi-user or privilege separation. What need does a personal computer OS have for multi-user support? The median number of users on a personal computer at any given time is 1. Even in the rare case that two or more people want to use the same computer at separate times and desire to protect eachother's files from eachother, they can use encryption rather than fake OS enforced security. Privilege separation, in order to keep malicious applications from compromising the user's files, has become significantly more important but it wasn't that important back then.
- spideymans 6y ago>It'll be interesting to see if any other players try to move back to this style in the desktop/laptop PC space. It's possible. I wouldn't necessarily bet on it, but it's possible. Qualcomm is just licensing ARM's standard core designs. If I were a PC OEM, designing your own custom silicon around the ARM core might be tempting, if it allows you to better differentiate your product.
- kelnos 6y ago> If I were a PC OEM, designing your own custom silicon around the ARM core might be tempting, if it allows you to better differentiate your product. There's a problem there, though (that Apple doesn't have): a random PC OEM doesn't control the OS. So that means they have to beg Microsoft to add support for their custom architecture, which MS may not want to do, and instead say "we're standardizing on what Qualcomm does, so do that or get bent".
- Blikkentrekker 6y agoIs that not still the case? My machines aren't that old, and I'm fairly certain that is the case in both of them. In fact, I'm thinking about upgrading my working memory on one of them looking at the 50% indicator at my screen right now for what is only having 12 tabs open in a web browser and not doing much other heavy lifting.
- mhh__ 6y agoWhat norms are there that actually make any difference? The cool stuff in M1 is the design work into the processing hardware, aren't the peripherals a bit of a hodge-podge of old this and non-standard that?
- 95014_refugee 6y ago> aren't the peripherals a bit of a hodge-podge of old this and non-standard that? There are certainly "old" peripherals in the SoC (the UART comes to mind). There's probably not a lot of norm-busting in this, There are certainly "non-standard" peripherals in the SoC (if by "non-standard" you mean "nobody else has them"). As the article notes, many if not most other folks "just" check off a couple dozen boxes on the ARM PrimeCell Shopping List (plus a few 3p vendors) and stack the resulting blobs together. Going your own way and building major components yourself (and all of the major components, including the fabric / interconnects) is very definitely not the "norm".
- ValentineC 6y agoPrevious discussion: https://news.ycombinator.com/item?id=25845201 https://news.ycombinator.com/item?id=25845201
- jeromenerf 6y agoThe original title is "How we ported ...", less of an announcement, more of a story.
- easton 6y agoThe title fixer messed it up, I’ve fixed it.
- CyberRabbi 6y agoWhat are they doing for video?
- stefan_ 6y agoIt's just a static framebuffer that on the real MacOS is likely used for nothing more than a boot logo. All the graphics are software rendering.
- tedd4u 6y agoThis person (Panfrost driver developer) is working on reversing M1 GPU https://rosenzweig.io/blog/asahi-gpu-part-1.html https://rosenzweig.io/blog/asahi-gpu-part-1.html
- liquidify 6y agoGood job guys. Awesome read. Pretty recently read that Linus was wanting to run Linux on new Macbook Air with M1, but he though it would be too much of a pain in the ass. I imagine we will see it soon.
- benkoller 6y agoI'd be thrilled to hear how the energy consumption under Linux would compare to native Big Sur - obviously with the M1 Macbook Pros in mind.
- kelnos 6y agoMuch worse, I'd expect. I doubt their porting work does all that much with power management. And there's no GPU driver, so whatever power state it starts up in is what you're going to get. Also they seem to be booting Ubuntu off of a USB stick, so it's possible that they haven't figured out how to support the internal storage yet, let alone things like audio, suspend/resume, ethernet/WiFi, keyboard/trackpad (for the laptops), etc. So those things would either come up completely shut down (and give you better power stats than you'd expect under normal usage), or come up active, and possibly not have power management enabled at all, killing your battery. Edit: looks like in the last half-day they've just figured out PCIe, the USB-A port, and ethernet: https://twitter.com/cmwdotme/status/1352361874076164098?s=21 https://twitter.com/cmwdotme/status/1352361874076164098?s=21
- mbreese 6y agoHere is how they actually set the kernel for booting. It's hidden behind a `curl <url> | sh` in their post: #!/bin/sh bputil -d | grep "CustomerKC" | grep -v "absent" KC=$? if [ $KC -eq 1 ] then bputil -n -k -c -a -s csrutil disable csrutil authenticated-root disable fi cd /Volumes/Preboot curl https://$LONGURL/linux.macho > linux.macho kmutil configure-boot -c linux.macho -v /Volumes/Macintosh\ HD/ echo "Kernel installed. Please reboot"; So, it looks like they download their pre-compiled kernel onto a Preboot volume. This is then set as the booting kernel? How long until there is a grub-like option? I should add -- I don't know what most of these commands are. It would probably be helpful if they had spelled these out more, but this is all a great place to start. bputil - Utility to precisely modify the security settings on Apple Silicon Macs. csrutil - Configure System Integrity Protection (SIP) kmutil - replaces kextload, kextunload, and other earlier tools for loading and managing kexts
- azinman2 6y agoAnd in doing so it turns of SIP. Probably necessary to boot a non-Apple kernel, but it means if you do want to switch back to the Mac side you’ve got one of the main security mechanisms turned off.
- easton 6y agoThe plan, IIUC, is to use PongoOS[0] as a bootloader which will then be able to load XNU/macOS or Linux. PongoOS already works on M1, so once the Linux support is done there will be a GRUB substitute. 0: https://github.com/checkra1n/pongoOS https://github.com/checkra1n/pongoOS
- ogre_codes 6y agoFrom the sounds of it, the corellium guys and Marcan are being a bit more cooperative now. Also, it sounds like much of the Corellium code is going to be pushed up to the main line so there won't be 2 Linux M1 branches for long. This hopefully means more of the efforts going into Marcan's projects can be spent on higher lever things like getting the GPU, Power management and other important bits working well.
- solarkraft 6y ago> You should also consider supporting the work being done by the folks over at Asahi Linux. This seems like quite a nice gesture after the bit of drama that apparently happened (and made corellium look bad, imo). I hope that eventually they're not going to duplicates effort as much as they likely are now, but then again it seems like Marcan thinks that their approach (with "insider knowledge") is an inherent risk to the project's legality. With or without Corellium Asahi will eventually get there, though, and they're pretty certainly the ones who will make the GPU work (thanks to the amazing Alyssa Rosenzweig of Panfrost fame).
- ballenf 6y agoI think the risk is more reputational for orgs wanting to use the Asahi project while not souring relations with Apple.
- starkruzr 6y agois there any actual hope for the GPU? is it based on any architecture for which there already exist Linux drivers?
- ogre_codes 6y agoThey managed it with Nvidia, granted it took years and it's still not as good as the proprietary drivers, but it's passable for dev work.
- Teknoman117 6y ago
- tyingq 6y agoIt would be interesting if this project and the Asahi one would post a "wish list" of actions, documentation, and so forth that they wished they had from Apple. Even if Apple never responded, it would help clarify what the challenges are, and what issues might pop up for future variations of Apple silicon. Or maybe some Apple devs would offer up some helpful pointers outside of official sanction.
- codys 6y agoI feel like we're missing some of the details/steps here, perhaps because the folks at corellium have a bunch of existing experience with apple SoCs and as a result had non-public knowledge about the platform. For example: determining that interrupts were being routed to FIQ. It's unclear how one would have figured that was occurring. Or that there was an special AIC (apple interrupt controller) that needed talking to, and how to talk to it. It feels like there's a lot of "reverse engineer some Apple kernel bits" that's potentially being elided over. Edit: or alternately, some debug interface that isn't being mentioned (swd/jtag/itm).
- azinman2 6y agoI had the same thought. How does one even know where to start when reverse engineering?
- aeyes 6y agoYou start with a problem, then you think what system might be interacting with that particular subsystem. Then you start to poke around in there trying to intercept, dump code, add debugging and so on.
- azinman2 6y agoBut are you poking around macOS? If it’s totally unique hardware unlike anything else, what would you even poke around?
- webgoat 6y agoSide channels like timing during different tests is one possibility. You can also reverse the operating system to understand more about how it may be handling interrupts or unique hardware. Then there's also dumping any onboard firmware memory to learn about the boot process. With some creativity, there's loads of ways to infer functionality of the processor/system enough to develop over it.
- johnmaguire2013 6y ago
- marmaduke 6y ago> we've been tracking the Apple mobile ecosystem since iPhone 6, released in 2014 with two 64-bit cores It sounds like they were well prepared. More and more I see preparation as make or break for engineering success, not budget or talent or tech, but silent persistence.
- ndesaulniers 6y agoCool, looks like they've been posted upstream for review. https://lwn.net/Articles/843221/ https://lwn.net/Articles/843221/
- gigatexal 6y agoIs there a what’s working and what’s not working list?
- notaplumber 6y agoVery few drivers have been written, beyond handling low-level SoC stuff. The ones that have been are explicitly mentioned in the linked article, stuff like USB which leverages existing Linux code. No keyboard, no trackpad, no GPU drivers (besides an unaccelerated framebuffer, setup and left by iBoot). There's some indication of Wi-Fi support, as it's a Broadcom FullMAC device (brcmfmac on Linux). But yeah, I'd say unusable without a USB hub and a myriad of external devices. Again, said as much in the article.
- jamesfmilne 6y agoLooks like PCIe and networking working now too. https://twitter.com/cmwdotme/status/1352361874076164098?s=21 https://twitter.com/cmwdotme/status/1352361874076164098?s=21
- notaplumber 6y agoVery recently as well. It's nice to see some rapid progress, certainly coming together. Good to hear the Ethernet is working on the M1 Mac Mini. Do you happen to know what device it is?
- pabs3 6y agohttps://rosenzweig.io/blog/asahi-gpu-part-1.html https://rosenzweig.io/blog/asahi-gpu-part-1.html
- chaorace 6y agoWhat's working: * A single USB type-C port * Software video framebuffer That's about it lol. You can't even use the internal disk at present moment.
- uHuge 6y ago"One you see it print" typo.
- SeanLuke 6y agoA nice article, but one nitpick. The authors repeatedly describe Apple's approach as "non-standard" when what they mean is "not what Linux does". That's pretty grating. It's also worth mentioning that in several cases (such as Mach-O), Apple's approach predates the very existence of Linux.
- kelnos 6y agoI don't think that's entirely accurate. Yes, the bit about flat image vs. PE vs. Mach-O is guilty of that. But things like their SMP bringup process, the AIC, using FIQs to deliver interrupts, etc. are things that Apple is doing that's not what most ARM SoC vendors do.
- person_of_color 6y agoWhat was the controversy between Asahi and Corellium?