Skip to content

Support virtio-intel native context

Dmitry Osipenko requested to merge digetx/mesa:native-context-iris into main

Similarly to AMDGPU !21658 and Freedreno !14900 (merged) native contexts, add virtio-gpu native context support for Intel GPUs.

Native context (or DRM context) is a mediated method of Linux graphics virtualization which operates on a level of Linux kernel driver UAPI, making a host GPU appear in a guest like a native one. It's implemented using existing virtio-gpu infrastructure (guest virtio-gpu driver, virtio-gpu guest/host protocol, host Qemu/Crosvm VMMs and virglrenderer).

Here is initial-experimental version of virtio-intel native context. This version covers TigerLake+ GPUs using i915 KMD UAPI. Both Iris and ANV drivers are supported, passing VK-GL-CTS and playing Steam games well. The plan is to get this version reviewed and merged, continuing to extend and improve virtio-intel with a follow up patches.

Virtio-intel works by overriding ioctl() used by Intel Mesa code and translating it into virtio-intel commands that are sent to host for execution. There are very few changes made to the Intel driver code with this approach.

Virglrender MR part: virgl/virglrenderer!1384

Qemu WIP patches: https://gitlab.freedesktop.org/digetx/qemu/-/commits/native-context-iris

Host/guest kernel patches: https://gitlab.freedesktop.org/digetx/linux/-/commits/native-context-iris

Crosvm already supports native contexts, no extra patches needed.

To test this MR you'll need to set up several guest/host components. On host you'll need to build virglrenderer, VMM (wip Qemu or crosvm) and wip host kernel. On guest you'll need to build this MR Mesa and wip guest kernel. See https://gist.github.com/digetx/083a0e2100c34ad90f52fdf977878b1c for examples of how to build and run. There are a lot of moving parts and you may need specific quirks depending on your machine setup/configuration, best to ask me if you'll run into a question or problem. The main trouble usually is around host-kernel KVM patches, they are mandatory for TTM/DG2 and may crash kernel, for iGPU KVM patches could be made optional by disabling transparent huge pages in the kernel config.

Virtio-intel was started out of ChromeOS needs. Today's version works best with crosvm and its Sommelier compositor that proxies Wayland from guest to host, such that guest application appears as a native/host one. I.e. you can run Steam in guest with Sommelier and it will look like a native application. Note that crosvm doesn't support KMS for native contexts, KMS works only in Qemu today.

For many games virtio-intel is able to hit native performance, where virgl/venus may struggle.

@robclark @pepp @llandwerlin @zehortigoza @gurchetansingh @ryanneph @zzyiwei @tursulin @DemiMarie

Edited by Dmitry Osipenko

Merge request reports