Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,745
2,087
I was asked on Github if I could compile my Chromium Legacy Updater PrefPane with 32bit support. This surprised me, because Chromium Legacy itself is 64 bit.

I was told:
That MacBook has a 64bit CPU so even though Lion itself runs in 32bit mode because the chipset it 32bit and can only address 3GB of RAM, 64bit apps run just fine. I upgraded it with a super-fast SSD and I'm very happy with it as a 2ndary MacBook with a still quite accentuated 17" matte screen & working sound, all for $40 :)

I added a 32bit version to the binary, and apparently that worked for this user. But, now I'm super curious, does anyone know what the heck is going on here? A 32bit OS that can still run 64bit binaries? Unless they're Preference Panes, apparently? What wizardry did Apple pull with their early Intel Macbooks?
 
  • Like
Reactions: RogerWilco6502

Amethyst1

macrumors G3
Oct 28, 2015
9,786
12,186
As far as I understand it, Lion will run on machines with a 32-bit EFI but that's it - officially. Crucial components such as Finder require a 64-bit CPU, which is why you need to replace them with versions from a DP if you want to run Lion on e.g. a Core Duo.

I don't know what "32-bit mode" is supposed to mean.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,745
2,087
Lion will run on machines with a 32-bit EFI but that's it - officially.
And I assume such machines don't do something bizarre like always start System Preferences in 32 bit mode, right?

(I realize I could ask the guy, but I don't want to clutter up the Github issue with off topic chatter any more than I already have.)
 

wicknix

macrumors 68030
Jun 4, 2017
2,621
5,306
Wisconsin, USA
I ran your original updater on my Lion install without issue, fwiw.

If osx is like linux, all you need is a 64bit kernel on 64bit hardware. Its then capable of running 32bit software. Like Ubuntu on G5's. 64bit kernel and 32bit rootfs and software. As far as i know macos didn't drop 32bit support until 10.15 or big sur.

Cheers
 

joevt

macrumors 604
Jun 21, 2012
6,938
4,240
Leopard (10.5.8) is 32-bit kernel only.
Snow Leopard (10.6.8) is 32-bit kernel default, but you can set 64-bit kernel using arch=x86_64 in boot-args.
Lion (10.7.5) is 64-bit kernel default, but you can set 32-bit kernel using arch=i386 in boot-args (I haven't tried that).
Mountain Lion (10.8.5) is 64-bit kernel only.

They all run 32-bit and 64-bit apps (Catalina 10.15.7 only runs 64-bit apps).


System Preferences.app runs as 32-bit or 64-bit app. The preferences panels run in the same environment as System Preferences.app, and therefore must support the same architecture that System Preferences.app is currently using, otherwise it will tell you that it needs to restart System Preferences using the architecture of the selected preferences panel. To eliminate this problem, your preferences panel should contain code for both architectures (using a fat binary).

Use Activity Monitor.app to see what architecture the kernel and System Preferences and other apps are using.
 

Project Alice

macrumors 68020
Jul 13, 2008
2,078
2,159
Post Falls, ID
It has always been possible to run 64bit software, on 32bit OS's (kinda) as long as the hardware is 64bit; depending on how the OS is built.
For example, you can run a virtualized 64bit OS on a 32bit OS. VirtualBox officially supports this.
Mac OS X was designed with this in mind. I'm pretty sure Tiger on 64bit machines is capable of running 64bit apps even though it is 32bit in nature itself. Obviously Leopard and higher are able to.

Someone who understands this better than I do can probably provide a better explanation though.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,745
2,087
For example, you can run a virtualized 64bit OS on a 32bit OS. VirtualBox officially supports this.
Mac OS X was designed with this in mind. I'm pretty sure Tiger on 64bit machines is capable of running 64bit apps even though it is 32bit in nature itself.
Well that's cool! I would have thought it was impossible, but your Virtualbox example makes sense, even if in that scenario you're running a separate OS. I wonder what wizardry Apple did to make that all work seamlessly...
 

f54da

macrumors 6502a
Dec 22, 2021
503
185
Was mulling over this when I was trying to find resources on how osx page tables are set up. It's well known that linux 32-bit uses a 3/1. And 64-bit linux uses a half-half split. It was a little harder to find out how osx splits it, but some digging revealed that 32-bit xnu does not use a shared cr3 between userspace/kernelspace, it essentially does a 4/4 virtual address split. (I guess this means that to transfer memory from userspace to kernelspace it would need to do its own page table walk, and it probably identity maps physical memory, or creates the page table entry on demand? I need to double check the osx internals book...). Also interestingly this means that 32-bit xnu is not vulnerable to meltdown....

On 64-bit xnu they do the sensible thing by having a shared cr3 and thus address space (interestingly you can apparently disable this via setting no-shared-cr3 boot flag), so apparently they still bothered to include the machinery to swap out the address space entirely. Btw this is how you can do 32-bit kernel running 64-bit app, it just uses this feature of swapping out the mappings entirely, in kernelmode only 4GB needs to be mapped at once (I guess higher mem can be mapped on demand if needed from kernelspace). And that also raises the question of how XNU handled Meltdown, since now with a shared mapping between userspace/kernelspace, 64-bit xnu is vulnerable to it. Apparently done via something called "double map" https://blog.ret2.io/2022/08/17/macos-dblmap-kernel-exploitation/ very similar to KPTI on linux.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.