Skip to content

Instantly share code, notes, and snippets.

@csullivan
Last active May 14, 2024 12:12
Show Gist options
  • Save csullivan/b0fcc67a3ecf5e1f463efabfa23079d8 to your computer and use it in GitHub Desktop.
Save csullivan/b0fcc67a3ecf5e1f463efabfa23079d8 to your computer and use it in GitHub Desktop.
QEMU/KVM GPU passthrough on 18.04 LTS notes

For blacklisting an Nvidia GTX1070 gpu on Ubuntu 18.04 with Intel integrated graphics for the host

Blacklist the nvidia driver:

sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf" 
sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

/etc/default/grub:

GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt rd.driver.pre=vfio-pci vfio_iommu_type1.allow_unsafe_interrupts=1"

*$ sudo update-grub

/etc/modprobe.d/local.conf:

options vfio-pci ids=10de:1b81,10de:10f0
options vfio-pci disable_vga=1

/etc/modules:

/etc/initramfs-tools/modules:

vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
options vfio_pci ids=10de:1b81,10de:10f0
vfio_pci ids=10de:1b81,10de:10f0

Note fore kernels earlier than 4.1 we can use the pci_stub method:

pci_stub ids=10de:1b81,10de:10f0
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

*$ sudo update-initramfs -u

Confirmation

vfio_pci method:

sullivan@qubit:~$ sudo tree /sys/bus/pci/drivers/vfio-pci/
/sys/bus/pci/drivers/vfio-pci/
├── 0000:01:00.0 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.0
├── 0000:01:00.1 -> ../../../../devices/pci0000:00/0000:00:01.0/0000:01:00.1
├── bind
├── module -> ../../../../module/vfio_pci
├── new_id
├── remove_id
├── uevent
└── unbind

pci_stub method:

sullivan@qubit:~$ dmesg | grep pci-stub
[    2.438797] pci-stub: add 10DE:1B81 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    2.438809] pci-stub 0000:01:00.0: claimed by stub
[    2.438824] pci-stub: add 10DE:10F0 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    2.438829] pci-stub 0000:01:00.1: claimed by stub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment