Enable the AMDGPU driver to work for a Ryzen APU (E.g. 5700G) passed through to a Linux (or Windows) VM
Describe the problem
To be able to use the APU on a Ryzen APU (e.g 5700G) in a virtual machine guest (either Linux or Windows), hosted on a Linux hypervisor (E.g. KVM).
Describe the new feature behavior
At the moment, discrete GPUs (both AMD and Nvidia) can be "passed-through" to a virtual machine. Unfortunately, at the moment this doesn't work for AMD APUs, with the AMD drivers. There are some reports of it working in both Windows and Linux guest VMs with default or generic drivers (albeit with poor performance). So, technically, the hardware is working in this enviroment already.
I initially thought this might be a bug, but @ckoenig informed me this is not supported. I've thus instead raised it as a feature request instead. If nothing else, this issue might serve as a handy link to post on forums where people are trying this, as a central source-of-truth of the status of VM support. It would also, at least, stop people wasting time attempting this if it's not going to be supported.
Describe the target user/application
This is for people that want to be able to virtualise their desktop with GPU acceleration, using the APU.
There are lots of people getting frustrated trying (and failing) to do this:
- https://forum.level1techs.com/t/amd-apu-passthrough-is-it-even-possible/163000
- https://forums.unraid.net/topic/112649-amd-apu-ryzen-5700g-igpu-passthrough-on-692/
- https://forum.proxmox.com/threads/amd-ryzen-7-renoir-4750g-apu-and-igpu-pass-thru-to-windows-10-guest.84849/
- https://forums.unraid.net/topic/100729-help-requested-for-amd-ryzen-5-pro-4650g-passthrough/
- https://www.reddit.com/r/VFIO/comments/sgfqys/ryzen_7_5700g_igpu_passthrough_proxmox/
That's just a sample - I've spent many hours looking for solutions.
How do you plan to validate this feature
Simply attempt to run a VM with the APU passed-through, and ensure video output works with reasonable performance.
I'm a software engineer, so very happy to apply and complile kernel patches, and try them out. However, I've no idea about the inner workings of the driver, so can't really help with a solution. @ckoenig mentioned @agd5f had attempted some workarounds - I think this is the relevant thread https://lore.kernel.org/all/314840412.1490602780.1638030522137.JavaMail.root@zimbra39-e7/
My understanding is the AMD driver assumes (quite reasonably) that for an APU, the Ryzen CPU itself is also available. This makes sense, and tallies with reports that it works with generic drivers.
I wonder then whether the hypervisor itself may need to be involved in any workaround here (emulating CPU register etc), so that it's not entirely down to the driver (be that in a Linux or Windows guest).
Business case
Expands the environments the APU can be used.
Draft of the userspace API
Not sure what to answer here - hopefully it would "just work". Or perhaps there could be a flag to inform the driver that it's in a virtual machine.