Ryzen 5650G GTX 770 kvm libvirt passthrough code 43

Hi everyone,

Intro
I’m building a combo NAS, router & gaming HTPC based on a headless Ubuntu 20.04 using libvirt.

My problem
I’m struggling to make my GTX 770 work in my windows VM, the VM boots without issues, the graphics card is detected by the OS but the driver errors out with code 43.
I thought even for this old GPU that the driver lockdown was a thing of the past ?

What I tried
So I tried the basic counter measures of vendor_id and kvm hidden but no dice. And some more advanced ones.
Or with older drivers (but still more recent than R465)

I also tried to make it work with a ubuntu vm without success.

At this point I suspect that this error 43 is something else. To rule out hardware problems I succesfuly booted on windows and the GPU works as it should.

I don’t know where to look for troubleshooting.
All I find on the web are ways to bypass code 43 or to look for thermals. Not much info on where to look software wise to know what’s wrong.

So I’d be delighted to add whatever log or command output needed to troubleshoot this. Thank you very much

My hardware
Mobo : Asus X570F Gaming
CPU : Ryzen 5650G
RAM : 16G 3200 TridenZ RGB
GPU : MSI GTX 770
Storage :
2x HDD 160GO RAID 1 for the hypervisor root
2x HDD 8TO RAID 1 for the storage

Not in use at the moment
1x SSD 250GO that I will use passed through to the VM or as cache for the nas
2x HDD 2TO for backups and VM’s data

Also for the router end of things
4 port Gigabit PCIe NIC
WiFi N PCIe card

Config
/etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

vfio vfio_iommu_type1 vfio_virqfd vfio_pci ids=10de:1184,10de:0e0a

/etc/initramfs-tools/modules

# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
# Syntax:  module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod

vfio vhost-net vfio_iommu_type1 vfio_virqfd vfio_pci ids=10de:1184,10de:0e0a

/etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="amd_iommu=on iommu=pt kvm_amd.npt=1 video=efifb:off"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

VM’s config

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit 98e2532c-93cf-4265-a1ca-53bb316c4416
or other application using the libvirt API.
-->

<domain type='kvm'>
  <name>windows old</name>
  <uuid>98e2532c-93cf-4265-a1ca-53bb316c4416</uuid>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>6</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-4.2'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='1234567890ab'/>
    </hyperv>
    <kvm>
      <hidden state='on'/>
    </kvm>
    <vmport state='off'/>
    <ioapic driver='kvm'/>
  </features>
  <cpu mode='host-model' check='partial'/>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/media/hatchery/vms/windows.qcow2'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x2'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-to-pci-bridge'>
      <model name='pcie-pci-bridge'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x11'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x12'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
    </controller>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='5' port='0x13'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
    </controller>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='6' port='0x14'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:df:dc:96'/>
      <source bridge='br0'/>
      <model type='e1000'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' autoport='yes'>
      <listen type='address'/>
    </graphics>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </sound>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </memballoon>
  </devices>
</domain>

Has anyone had this issue before ? Or know of ways to troubleshoot it ?

Is my graphics card too old for vfio ?

I’d be very grateful for any help :pray: :pray:

I passthrough a GTX 750 ti…

Here is what I have in my file… Maybe the custom tag makes a difference?

    <hyperv mode='custom'>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='anything'/>
    </hyperv>
    <kvm>
      <hidden state='on'/>
    </kvm>

I am passing a GT710 without issues. I don’t remember having to do anything specific…

You are installing the latest drivers from nvidia?

When I add this tag the parser rejects my edit so I added it by nanoing the file directly but doesn’t seem to solve it sadly. Thanks for the help !

Thanks for the feedback ! Yes it seems everyone else manages to do this easily.

Yes I am, I also tried two older drivers

On what platform are you guys passing through your GPUs ? Intel ? AMD ? Which gen ?

I have a ryzen 3600. The host GPU is AMD and the guest is an Nvidia GTX 750 ti.

This is on debian bullseye/bullseye with a 5.10 or 5.15 kernel. Libvirt is 8.0.0. qemu is 6.2.

If I try to remove mode=‘custom’, the parser adds it back in.

/etc/modules

# gpu passthrough
vfio
vfio_iommu_type1

# gtx 750 ti
vfio_pci ids=10de:1380,10de:0fbc

/etc/modprobe.d/vfio_pci.conf

# gtx 750 ti
options vfio_pci ids=10de:1380,10de:0fbc

/etc/initramfs-tool/modules

softdep amdgpu pre: vfio vfio_pci
softdep nouveau pre: vfio vfio_pci

vfio
vfio_iommu_type1
vfio_virqfd

# gtx 750 ti
options vfio_pci ids=10de:1380,10de:0fbc
vfio_pci ids=10de:1380,10de:0fbc

vfio_pci
amdgpu
nouveau

/etc/default/grub

GRUB_CMDLINE_LINUX="iommu=1 amd_iommu=on"

I also used whatever drivers win10 installed automatically in the guest.

Thank you for your help, I’ll continue investigating