Skip to content

freedreno: virtgpu support for freedreno in VM guest

Rob Clark requested to merge robclark/mesa:fd/virtgpu into main

Add a new freedreno/drm backend to enable using native driver in a VM guest, via a new "virtio_gpu" context type which (indirectly) makes host kernel interface available in guest. In the guest, freedreno will try to bind to the virtio_gpu device, if the host advertises support for the VIRGL_RENDERER_CAPSET_VNC_MSM context type, before falling back to virgl. A driver specific protocol is used, with request messages to host (mostly) tunneled over the VIRTGPU_EXECBUFFER ioctl, and response messages from host via a shmem buffer.

The pipe-loader part could possibly be done better somehow. Currently it requires the guest mesa build to enable virgl in addition to freedreno. (Although maybe having the virgl fallback available isn't such a bad thing for the VM, if you don't know what hw the VM image would be running on.) The FD_NO_VIRTIO environment variable can be used to force fallback to virgl.

Generally 99+% of native performance. A few games/benchmarks that hit userspace bo-cache misses (and end up doing synchronous GEM obj allocation mid-frame) drop down to low/mid 90's. By comparison virgl ranges from 42-83% of native on the same set of games/benchmarks.

I expect further improvements to be possible with GPU iova allocation in userspace, which would let us make GEM buffer allocation asynchronous, but that will require some new host kernel uabi.

Note that the guest<->host protocol should be considered unstable/experimental at this point. But is complete enough at this point to land and do further development in-tree.

Obligatory screenshot: Screenshot_2022-03-15_14.18.37

Corresponding virglrenderer MR: virgl/virglrenderer!693 (merged)

Edited by Rob Clark

Merge request reports