Building QEMU and Linux with virtio-vulkan and venus support
A couple of patches are required for the kernel and qemu on the host side. You should use the latest version of mesa (host and guest) and virglrenderer libraries (host) from the upstream main branches.
Series | What |
---|---|
https://patchew.org/QEMU/20240623152343.328436-1-dmitry.osipenko@collabora.com/ | QEMU support for blob memory and Venus |
https://lore.kernel.org/lkml/20240726235234.228822-1-seanjc@google.com/ | KVM support to avoid pinning device memory |
Dependencies
Host
You will also need to build the latest mesa and virglrenderer with support. The graphics stacks loads a lot of libraries dynamically so it’s important to make sure you set all the environment variables so things point at the right place. Specifically:
Env Variable | Purpose |
|
---|---|---|
PKG_CONFIG_PATH | Configure can find the newer libs | $INSTALL/lib/pkconfig and $INSTALL/lib/$TRIPLE/pkgconfig |
LD_LIBRARY_PATH | So dlopen() searchs the right place | $INSTALL/lib/ $INSTALL/lib/$TRIPLE $INSTALL/lib/$TRIPLE/dri |
VK_ICD_FILENAMES | So the latest Vulkan driver is loaded | $INSTALL/share/vulkan/icd.d/$GPU.$ARCH.json |
Guest Dependencies
Debian Sid now has the latest Mesa bits (24.2) which should get promoted to Testing (Trixie) in due couse. However if you do want to install a newer Mesa you will want to ensure you boot up in console mode and then only start the GUI making sure you are using the newer Mesa and not the system version.
There is a test kernel+initramfs here: https://fileserver.linaro.org/s/ce5jXBFinPxtEdx
Build virglrenderer
$ sudo apt install libdrm-dev libepoxy-dev pkg-config cmake meson libvulkan-dev libva-dev
$ meson setup build \
-Dvenus=true \
-Drender-server=true \
-Drender-server-worker=thread \
-Dbuildtype=release \
-Dprefix=${INSTDIR}
$ ninja -C build install
Build mesa
LLVM is required to build mesa libaray. If llvm doesn't enable cpp_rtti, add the following line to meson.build.
-rtti = false
and add "-cpp_rtti=false" to the following meson setup.
$ sudo apt install \
yacc \
bison \
cmake \
llvm-15 \
glslang-tools \
libglvnd-dev \
libwayland-egl-backend-dev \
libxext-dev \
libxfixes-dev \
libxcb-glx0-dev \
libxcb-shm0-dev \
libx11-xcb-dev \
libxcb-dri2-0-dev \
libxcb-dri3-dev \
libxcb-present-dev \
libxshmfence-dev \
libxxf86vm-dev \
libxrandr-dev \
libudev-dev \
libelf-dev \
libdrm-dev
$ meson setup build \
-Dgallium-nine=false -Dgallium-xa=disabled -Dglx=dri \
-Dshared-glapi=enabled -Ddri3=enabled -Degl=enabled -Dgbm=enabled \
-Dglvnd=true -Dgallium-drivers=radeonsi,virgl -Dplatforms=x11,wayland \
-Dgles1=disabled -Dgles2=enabled -Dvulkan-drivers=virtio,amd \
-Dlibunwind=disabled -Dbuildtype=release \
-Dprefix=${INSTDIR}
$ ninja -C build install
For guest, use the following command to configure
(TBD)
Build qemu
Download the source code[1] from Collabora or the patch[2] from AMD should also work. Replacee “x86_64-linux-gnu” with “aarch64-linux-gnu” on AVA.
[1] https://gitlab.freedesktop.org/digetx/qemu.git branch:venus-v4
[2] https://patchew.org/QEMU/20230915111130.24064-1-ray.huang@amd.com/
Build kernel
As of v6.10.5 the kernel should have everything you need for the guest (baring any host specific hacks e.g. for AVA memory consistancy). The PFNMAP patches should only be needed on the host and only when you have a GPU with on-card memory.
You will need the following options enabled:
Kernel Flag | Reason |
---|---|
CONFIG_DRM_VIRTIO_GPU | Enable VirtIO GPU support |
CONFIG_UDMABUF | Userspace access to DMA buffers |
Run the guest on x86
(Note for Intel platform only)
If you see a problem similar to [4] when you run vkmark or vulkan applications, apply the following tweak to the host kernel.
[4] https://drive.google.com/file/d/1gaF2FCv8lmD_tsVDbrdvGgaxCK-RdDkX/view?usp=sharing
Run the guest on AVA
Host and Guest Kernel
This kernel tree contains the PFN patches and a few local hacks for AVA hardware weirdness: https://git.linaro.org/people/alex.bennee/linux.git/log/?h=review/pfn-references-v12-with-altra-tweaks