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

PowerPC74

macrumors member
Original poster
Dec 15, 2024
71
23
I hope you folks are not anti-emulator, the future of running the Mac OS on PowerPC is emulation. Our Quad Core G5's are never going to get any faster. Emulation of PPC in Qemu is pretty good, and a lot faster than most people would think on an M2 host.

Emulation will continue to get faster as CPUs get faster, our G5s never will. This thread is about working being done to make SMP and TCG Multithreading work with Qemu so the guest( Mac OS ) can take advantage of more the one host CPU core to emulate more that one Guest CPU.

Just like having a Dual G4, or a Quad G5.

Work is progressing and I have Mac OS X up and running, but the second CPU is stuck in a loop and Mac OS X can't use it at all. The System Profiler reports 2 CPUs, and both CPUs are there, but only one works.

The issue right now is that stuck CPU, it was not bought out of reset correctly and I'm having trouble understanding exactly how the GPIO works, and how it should work to get that second CPU to come out of reset so we can use it.

I am willing to share my patches for people willing to help.

Right now what needs to be done is install Linux in qemu ppc with my patches and use gpio-untils to poke at the GPIO until we figure out the correct bits to poke to get that second CPU out of rest and up and running.

So any takers?

The Linux documentation from the kernel source should be all we really need to get this working.

linux/arch/powerpc/include/asm/keylargo.h

linux/arch/powerpc/platforms/powermac/feature.c:

These are simple GPIOs, they are complex in their bit fields for GPIOs, but it's not that hard folks.
qemu.jpg
SMP.jpg
 
Mac OS graphics performance is usually dog slow in a unaccelerated VM, how would you go about getting any decent GPU performance while emulating a PPC mac?
 
Mac OS graphics performance is usually dog slow in a unaccelerated VM, how would you go about getting any decent GPU performance while emulating a PPC mac?
PCI passthrough, I've done this before with the lowly Rage 128 PCI card, but there is no reason it can't be done with the Radeon 1950 XT I have.

Sadly for great graphics performance on OS 9 there really isn't a good option as all the good cards were AGP.

There are versions of the Radeon 9000 that are PCI, and we should be able to get them to work, but you'll likely be limited to 66MHz PCI at best.

The Raspberry Pi 5 has a PCI-E connector and they have cards they call Hats that can provide full PCI-E slots. Or you can use a fast x86 system with either PCI-E or thunderbolt.

If Apple was not lagging behind we could do PCI passthrough on macOS hosts, but right now hosts are limited to Linux OS, and there are no Thunderbolt ports woking on Apple SoC for that.

There is no shortage of AGP Radeon 9000's, but no one is currently selling a AGP to PCI adapter, tho they do exist. Going from AGP to PCI then PCI to PCI-E can be done. The PCI adapter would need 66Mhz signaling for full 266MB/s performance. That's really the best that maybe done for OS 9, and really it should play any OS 9 game at an executable performance level.

OS X has no such limits, at least Tiger and Leopard have full PCI-E support.
 
Last edited:
PCI passthrough, I've done this before with the lowly Rage 128 PCI card, but there is no reason it can't be done with the Radeon 1950 XT I have.

Sadly for great graphics performance on OS 9 there really isn't a good option as all the good cards were AGP.

There are versions of the Radeon 9000 that are PCI, and we should be able to get them to work, but you'll likely be limited to 66MHz PCI at best.

The Raspberry Pi 5 has a PCI-E connector and they have cards they call Hats that can provide full PCI-E slots. Or you can use a fast x86 system with either PCI-E or thunderbolt.

If Apple was not lagging behind we could do PCI passthrough on macOS hosts, but right now hosts are limited to Linux OS, and there are no Thunderbolt ports woking on Apple SoC for that.

There is no shortage of AGP Radeon 9000's, but no one is currently selling a AGP to PCI adapter, tho they do exist. Going from AGP to PCI then PCI to PCI-E can be done. The PCI adapter would need 66Mhz signaling for full 266MB/s performance. That's really the best that maybe done for OS 9, and really it should play any OS 9 game at an executable performance level.

OS X has no such limits, at least Tiger and Leopard have full PCI-E support.
Ohh wow, I didnt know that I could passthrough my old x1900xt thats pretty cool
 
Ohh wow, I didnt know that I could passthrough my old x1900xt thats pretty cool
Like I said, I passed through the Rage 128 PCI to OS X Tiger, played a few games, JK2, Q3. Just to test it out.

This was 5 or 6 years ago, but Openbios doesn't run the FCode ROMs when it probes PCI and lack some of the words needed to do it manually. We added the needed words to a patched Openbios, and got the Rage working.

The x1900 may need new words added, but that's not too hard.

I intend to buy a Pi 5 and hat to test the x1950 I have that works in a Quad, but I'm woking on the SMP stuff first.

Balaton got the second CPU to start, but it shoots itself to the dark side of the moon in the MMU code somewhere, so we have to debug that.

With any luck the Pi 5 doesn't have any other devices in the IOMMU group with the PCI-E card or that is going to be an issue, I've worked around that before on x86 systems but really a device needs its own IOMMU group or you need to passthrough all the devices in the group, and that's an issue for the Pi's builtin devices because the host likely needs them.

I only found one person who tried PCI-Passthrough on the Pi and they failed, but it was unclear why and they did. not check the IOMMU groups.

I'll let you know how it goes with the Pi and the x1950, with any luck it will be a little Doom 3 action on more than 1 CPU.
 
Is this gonna work without Linux being involved?
Qemu runs on all platforms and architectures, so you don't need Linux unless you want to do PCI Passthrough. I use a macOS host on an M2 MacBook Pro.

As far as guest OS's....

We haven't got Linux to work with it yet, but Mac OS 9 and Mac OS X work. A few quick and dirty benchmarks, Geekbench 2.2.0 went from 743 Single CPU to 1033 Multi( 2 ) CPUs. Mac OS X Tiger.

Encoding a short DV clip to MPEG2 with QuickTime under Mac OS 9.2.2 57 sec. single CPU to 31 sec. Multi(2) CPUs.
 
  • Like
Reactions: barracuda156
but Mac OS 9 and Mac OS X work. A few quick and dirty benchmarks, Geekbench 2.2.0 went from 743 Single CPU to 1033 Multi( 2 ) CPUs. Mac OS X Tiger.

Thank you. Not fast, but perhaps not bad either. Wonder how it compares to running it on POWER (and also to Rosetta on a fast x86 machine).
 
Thank you. Not fast, but perhaps not bad either. Wonder how it compares to running it on POWER (and also to Rosetta on a fast x86 machine).
Given that Rosetta died with 10.6.8, people running modern Macs have little choice for running PPC Mac OS.

There is DigusPPC, but it's in its early stages and can't do everything Qemu can do, yet, but it does run the full Mac ROM and Open Firmware is fully available. If it had PCI Passthrough it could very quickly become the best Mac OS emulator for PPC.

What we have learned about the GPIO and SMP in Qemu should port nicely to DingusPPC.
 
Thank you. Not fast,
It does better than one of the fastest G4 single core Macs ever made, so not fast is relative.


The thing to remember is as host CPUs get faster, so does Qemu, even without optimizations.
 
  • Like
Reactions: barracuda156
Nice work, this is so cool!

A few quick and dirty benchmarks, Geekbench 2.2.0 went from 743 Single CPU to 1033 Multi( 2 ) CPUs. Mac OS X Tiger.

I just ran Geekbench on my Dual 1 GHz MDD with 2 GB of RAM and an SSD and it got 858, so I'd say the VM's performance is quite nice.

On a side note, what happens if the VM is set with 3 or more CPUs? Considering we have the G5 Quad, at least 4 should work, right?
 
Nice work, this is so cool!



I just ran Geekbench on my Dual 1 GHz MDD with 2 GB of RAM and an SSD and it got 858, so I'd say the VM's performance is quite nice.

On a side note, what happens if the VM is set with 3 or more CPUs? Considering we have the G5 Quad, at least 4 should work, right?
We have not yet ported it to more than 2 CPUs, Openbios will enumerate them in the device-tree, but it's really the OS that starts the additional CPUs.

The " state" property on a real Mac in Open Firmware for additional CPUs is " stopped". They don't start until the OS pokes at the GPIO for a soft-reset. Figuring out the GPIO bits is what is key.

I'm not sure the GPIO emulation in Qemu will support 4 CPUs, maybe. G5 emulation is Qemu is not complete, it won't boot OS X, but it will boot Linux. 4 G4s would be cool!
 
We have not yet ported it to more than 2 CPUs, Openbios will enumerate them in the device-tree, but it's really the OS that starts the additional CPUs.

The " state" property on a real Mac in Open Firmware for additional CPUs is " stopped". They don't start until the OS pokes at the GPIO for a soft-reset. Figuring out the GPIO bits is what is key.

I'm not sure the GPIO emulation in Qemu will support 4 CPUs, maybe. G5 emulation is Qemu is not complete, it won't boot OS X, but it will boot Linux. 4 G4s would be cool!

Do you know btw why it cannot emulate G5?
 
We have not yet ported it to more than 2 CPUs, Openbios will enumerate them in the device-tree, but it's really the OS that starts the additional CPUs.

The " state" property on a real Mac in Open Firmware for additional CPUs is " stopped". They don't start until the OS pokes at the GPIO for a soft-reset. Figuring out the GPIO bits is what is key.

I'm not sure the GPIO emulation in Qemu will support 4 CPUs, maybe. G5 emulation is Qemu is not complete, it won't boot OS X, but it will boot Linux. 4 G4s would be cool!

I see. Awesome project!
 
Subscribing to progress on this.

Would love to see Linux guest support happen. I've been meaning to roll a Gentoo local compile and binary server but ppc crossdev fails to actually compile anything useable.
 
Subscribing to progress on this.

Would love to see Linux guest support happen. I've been meaning to roll a Gentoo local compile and binary server but ppc crossdev fails to actually compile anything useable.
We managed to get the 2nd CPU to start in Linux, but only by using gdb and setting a break point, then stepping through the code. If we don't set the break point and step, CPU1 remains stuck.

It's tough to debug, but we'll figure it out at some point, the two best guys are on it, they care more about running Linux in a Mac Emulator than I do.

If you want to run PPC linux in Qemu, there are other PPC machine types like the 'pseries' you can throw cores at all day.
 
  • Like
Reactions: barracuda156
We managed to get the 2nd CPU to start in Linux, but only by using gdb and setting a break point, then stepping through the code. If we don't set the break point and step, CPU1 remains stuck.

It's tough to debug, but we'll figure it out at some point, the two best guys are on it, they care more about running Linux in a Mac Emulator than I do.

If you want to run PPC linux in Qemu, there are other PPC machine types like the 'pseries' you can throw cores at all day.

BTW, support for Darwin ppc host is still broken as it was?
 
Just in case I attach files here, balaton1 and balaton2 should arrive at some time in main qemu tree, qemu-mac99-cpus-v2.patch should be applied with git apply (at least in my case). qemu tree is commit b69801dd6b1eb4d107f7c2f643adf0a4e3ec9124 and openbios tree from https://github.com/mcayland/openbios.

Note that you need -M mac99,via=pmu or may be via=adb-pmu otherwise patch will segfault with -smp 2.

Code:
./qemu-system-ppc -M  mac99,via=pmu -cpu g4 -smp 1 -m 256 -hda ~/QEMU/Mac-netbsd-2gb.qcow2  -bios  ~/K38_sdcard1/Documents/openbios-qemu-smp.elf -accel tcg,thread=multi

a bit like this, I guess (NetBSD sadly regressed recently on qemu-system-ppc, so i can't log in into my macppc VM :) )


You might want qemu-system-ppc64, but for gdb debugging I needed 32-bit qemu, it seems.


I used tips from that page, just running gdb in Debian ppc32 running in another qemu instance with networking (so target IP was 10.0.2.2 ) :) For Linux you can add cmd arg "-nosmp" via -append "args" qemu switch.

Code:
./qemu-system-ppc64 -M  mac99,via=pmu -cpu 7450 -smp 2 -m 512 -kernel
~/boot/vmlinux -nographic  -bios  ~/K38_sdcard1/Documents/openbios-qemu-smp.elf
-accel tcg,thread=multi -boot d -append "console=ttyPZ0"

I tried cpu g4 and cpu 7450 without any difference.

Kernel deb at

MTCCG info at
 

Attachments

  • mac99-smp-balaton.zip
    9.1 KB · Views: 24
Here is the binary Openbios.elf for SMP.
 

Attachments

  • openbios-qemu-smp.elf.zip
    146.4 KB · Views: 30
Ya, while *I think* this binary might break G3 processors/machine in qemu? At least it does for me ...

I also found this pdf, about 970MP (currently not in openbios, unlike 970FX)


and there was my earlier find about CPC945 (northbridge), not sure how closely Apple followed this spec
there is document at

http://datasheet.datasheetarchive.com/originals/library/Datasheets-SW3/DSASW0048084.pdf

CPC945 Bridge and Memory Controller User Manual

I am afraid making shiny new qemu board (for 4x970MP) much beyond me, but there was sort of intro based on qemu 4.2.0 ?

 
Here is the binary Openbios.elf for SMP.

I think this one a bit better because it works again with G3/970FX cpu types. Patches included in zip and send to openbios mailing list.
 

Attachments

  • openbios-smp-new.zip
    141 KB · Views: 25
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.