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 |
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 |
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
$ 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 |
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)
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.
$ sudo apt install libglib2.0-dev \ libpixman-1-dev \ libaio-dev (optional) \ liburing-dev (optional) \ libslirp-dev \ libudev-dev (optional) \ libsdl2-dev \ libgtk-3-dev $ PKG_CONFIG_PATH=${INSTDIR}/lib/x86_64-linux-gnu/pkgconfig $ mkdir build $ cd build $ ../configure \ --prefix=${INSTDIR} \ --extra-cflags="-I${INSTDIR}/include " \ --extra-ldflags="-L${INSTDIR}/lib/x86_64-linux-gnu" \ --target-list=x86_64-softmmu \ --enable-kvm \ --disable-werror \ --enable-slirp \ --enable-opengl \ --enable-virglrenderer \ --enable-gtk \ --enable-sdl $ ninja install |
[1] https://gitlab.freedesktop.org/digetx/qemu.git branch:venus-v4
[2] https://patchew.org/QEMU/20230915111130.24064-1-ray.huang@amd.com/
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 |
$ sudo usermod -a -G kvm ${YOURID} # for /dev/udmabuf $ export VK_DRIVER_FILES=${INSTDIR}/share/vulkan/icd.d/radeon_icd.x86_64.json $ {INSTDIR}/bin/qemu-system-x86_64 \ -enable-kvm \ -smp 1 \ -m 4G \ -hda ${ROOTFS_IMG} \ -serial mon:stdio \ -device virtio-vga-gl,iommu_platform=on,hostmem=4G,blob=true,context_init=true \ -display gtk,gl=on \ -object memory-backend-memfd,id=mem1,size=4G,share=on \ -machine q35,accel=kvm,kernel-irqchip=split,memory-backend=mem1 \ -device intel-iommu,intremap=on \ -device virtio-balloon \ -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 \ -d guest_errors \ -boot d |
(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.
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index dd92361f41b3..f0a9ae22f691 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7556,7 +7556,7 @@ static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) return MTRR_TYPE_UNCACHABLE << VMX_EPT_MT_EPTE_SHIFT; if (!kvm_arch_has_noncoherent_dma(vcpu->kvm)) - return (MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT) | VMX_EPT_IPAT_BIT; + return (MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT); if (kvm_read_cr0(vcpu) & X86_CR0_CD) { if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED)) |
[4] https://drive.google.com/file/d/1gaF2FCv8lmD_tsVDbrdvGgaxCK-RdDkX/view?usp=sharing
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