Ubuntu 20.04 Missing Kernel modules for VFIO-PCI and VFIO_IOMMU_TYPE1

Hi everybody. This is my first time with GPU passthrough.

Ryzen5 
Gigabyte X570 Auros Pro (Latest Bios, with all SMT etc enabled)
Sapphire RX 570 Nitro+ 8GB
XTX RX580 OC 8GB`

I’m trying to pass my RX 580 to the VM and leave RX 570 for my system.
Unfortunately I didn’t knew that these two cards will get same identifier which would give me extra headache…

I’ve been following this excellent guide by Mr wendell:
vfio-in-2019-pop-os-how-to-general-guide-though-draft/142287

After executing:
update-initramfs -u
I’ve got

W: Possible missing firmware /lib/firmware/amdgpu/navi12_vcn.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/arcturus_vcn.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/navi12_smc.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/arcturus_smc.bin for module amdgpu`

This shouldn’t concern me as navi12 is not my card so I’ve tried
lsinitramfs /boot/initrd.img-5.4.0-26-generic |grep vfio

result:

usr/lib/modules/5.4.0-26-generic/kernel/drivers/vfio
usr/lib/modules/5.4.0-26-generic/kernel/drivers/vfio/mdev
usr/lib/modules/5.4.0-26-generic/kernel/drivers/vfio/mdev/mdev.ko
usr/lib/modules/5.4.0-26-generic/kernel/drivers/vfio/mdev/vfio_mdev.ko

so I’ve added

vfio-pci, vfio and vfio_iommu_type1

to /etc/initramfs-tools/modules and rerun previous commands. No luck.

I’ve decided to see if these are /lib/modules/5.4.0-26-generic/
running sudo find . *| grep vfio gave me:

./kernel/drivers/vfio
./kernel/drivers/vfio/mdev
./kernel/drivers/vfio/mdev/mdev.ko
./kernel/drivers/vfio/mdev/vfio_mdev.ko
kernel/drivers/vfio
kernel/drivers/vfio/mdev
kernel/drivers/vfio/mdev/mdev.ko
kernel/drivers/vfio/mdev/vfio_mdev.ko

I don’t know if that’s correct so I checked which options were used in kernel

CONFIG_VFIO_IOMMU_TYPE1=y
CONFIG_VFIO_VIRQFD=y
CONFIG_VFIO=y
CONFIG_VFIO_NOIOMMU=y
CONFIG_VFIO_PCI=y
CONFIG_VFIO_PCI_VGA=y
CONFIG_VFIO_PCI_MMAP=y
CONFIG_VFIO_PCI_INTX=y
CONFIG_VFIO_PCI_IGD=y
CONFIG_VFIO_MDEV=m
CONFIG_VFIO_MDEV_DEVICE=m
CONFIG_IRQ_BYPASS_MANAGER=y
CONFIG_VIRT_DRIVERS=y
# CONFIG_VBOXGUEST is not set
CONFIG_VIRTIO=y
CONFIG_VIRTIO_MENU=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_PCI_LEGACY=y
CONFIG_VIRTIO_PMEM=m
CONFIG_VIRTIO_BALLOON=y
CONFIG_VIRTIO_INPUT=m
CONFIG_VIRTIO_MMIO=y
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y

I don’t know why I don’t have vfio-pci and vifio_iommu_type1
¯_(ツ)_/¯

Any suggestions are welcome.

Thanks!

Since the VFIO module is included in the kernel from kernel 5.4.26, it is necessary to specify it with the kernel parameter of grub.

/ etc / default / grub
GRUB_CMDLINE_LINUX = “amd_iommu = on iommu = pt pcie_aspm = off vfio_iommu_type1.allow_unsafe_interrupts = 1 vfio_pci.disable_vga = 1 vfio_pci.disable_idle_d3 = 1”

So this means that the VFIO module shipped with Ubuntu 20.04?

CONFIG_VFIO_IOMMU_TYPE1=y
CONFIG_VFIO_VIRQFD=y
CONFIG_VFIO=y
CONFIG_VFIO_NOIOMMU=y
CONFIG_VFIO_PCI=y
CONFIG_VFIO_PCI_VGA=y
CONFIG_VFIO_PCI_MMAP=y
CONFIG_VFIO_PCI_INTX=y
CONFIG_VFIO_PCI_IGD=y
CONFIG_VFIO_MDEV=m
CONFIG_VFIO_MDEV_DEVICE=m

Since the kernel config is [y], it is not a kernel module.
It is included in the kernel.
For kernel modules, the kernel config is [m].

Awesome. Thanks. I have not yet upgraded to 20.04, but I am hoping that this will make getting Looking Glass easier on Ubuntu hosts. I wish this had received more attention the way that the inclusion of Wireguard into the 20.04 kernel did even though it was backported. I guess there is more of a widespread interest in Wireguard than Looking Glass.

I’ve never yet given Looking Glass a try, but given that Ubuntu now also has client support in its repos, this should make things a bit easier. I’m looking forward to trying it out soon.