Don’t be like me, be better
I will admit to not properly researching what GPU I needed to properly run macOS with Qemu. Combine that with me wanting go buy the cheapest yet still available AMD GPU and you get the Sapphire AMD RX550 OC(2GB).
What I did not know is that this card has at least 2 variants: one based on the Lexa Pro chip and one based on the Baffin chip. The Lexa Pro one is specifically NOT supported by macOS drivers, this version has a PCI ID of 1002:699f while the supported one has a PCI ID of 1002:67ff. Guess which one I got… the unsupported one, of course.
Still, with a devil-may-care attitude I started hacking away because nothing is impossible(it’s usually possible but with caveats).
Entrypoint: macOS VM
This setup is based on the amazing work by foxlet:
It documents pretty nicely how to passthrough your GPU and install everything, so start there.
You will also need to learn about VFIO and IOMMU.
This excellent Arch Linux wiki article explains a lot:
This is a pretty big topic and depending on what Linux you are using and with what hardware, things might be easier or harder.
Initially I ran on a Linux Mint then switched to Manjaro. I was able to enable IOMMU and vfio on both.
My CPU is Core i9-9700k which is supported by IOMMU and my motherboard is a Gigabyte Aorus Z390 Pro.
If you, like me, want to mess around with this stuff(hackintoshes in general) be warned that is implies using hardware in ways it was never meant to be used. Now, I’ve been hackintoshing since OS X Tiger was a thing and never broke any hardware(I think!) but you never know. You are warned!
Attaching the GPU to the VM
If you read the article on the Arch wiki you know that the GPU must reside on a separate IOMMU group or you must use the ACS patch. I had to put my RX550 in the lowest PCIe slot, the x4 one(oh well, some bandwidth loss) to have this working properly; I could have also used the ACS patch but I prefer to avoid Linux kernel patches.
This is the sequence of qemu params that attaches the GPU to the VM:
-vga none \ -device pcie-root-port,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 \ -device vfio-pci,host=03:00.0,bus=port.1,multifunction=on \ -device vfio-pci,host=03:00.1,bus=port.1 \
You can also experiment with -vga qxl to have 2 GPUs attached to the VM until you can get the real one working.
Oh, also important: I had to add this param to my kernel command line: pcie_aspm=off (seems there is a bug in how the RX550 handles power states, I did not dig too deep but without that param you can only boot the VM once after which the card gets stuck in power state D3).
You can always check your currently booted kernel command line as such:
cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-5.7-x86_64 root=UUID=f3d1e846-3860-4971-980b-50951c8eeb38 rw intel_iommu=on iommu=pt pcie_aspm=off quiet apparmor=1 security=apparmor resume=UUID=e18580d7-c30e-4bd9-abdf-ecfaa503a7ad udev.log_priority=3
The important bits are intel_iommu=on iommu=pt pcie_aspm=off.
Realizing that the GPU is not supported
OK, so the VM booted, things but it cannot load a driver for the GPU….
Still, my searches lead me to this post:
Someone here claims that it can run this GPU(similar, 4GB RAM version, same PCI ID) by patching the DSDT.
Now, I never needed to patch my DSDT, I always used bootloader and/or kext hacks but hey, I’ll learn this too if I have to.
Now, the DSDT seems to be somehow similar to the DTB on embedded Linux but I can’t tell you how it works exactly but it is linked to the ACPI interface.
To patch your DSDT the best tool I found is MaciASL by RehabMan:
This both extracts the current systems DSDT and it allows for editing, compiling and exporting.
You need to combine this with a tool like Clover Configurator to be able to mount your EFI and add the patched DSDT in /EFI/ACPI/patched
The above worked on Mojave. Catalina was another story. I dropped the DSDT patch in favor of Clover patches. I did not use Lilu/WhateverGreen.
One issue I think I had was the VBIOS being not properly read by the VM, sometimes I had to shut it down, wait a minute and then start again. And definitely not pass a rom via romfile= in the command line to qemu.
In the end these are the patches I did in Clover Configurator:
Graphics: LoadVbios, InjectATI,RadeonDeInit and FakeID ATI 0x67FF1002
Seems FixDisplay was vital to add GFX0 in the DSDT. The rest might be optional, except for the Fake ID.