PCI Passthrough Error | QEMU/KVM

Hmmm, looks like your IOMMU isn’t enabled.

cat /proc/cmdline?

Are you on Intel or AMD?

I’m using Intel. lscpu output:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Core(TM) i3-9100F CPU @ 3.60GHz
    CPU family:          6
    Model:               158
    Thread(s) per core:  1
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            10
    CPU(s) scaling MHz:  19%
    CPU max MHz:         4200.0000
    CPU min MHz:         800.0000
    BogoMIPS:            7200.00
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology
                          nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowpr
                         efetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt x
                         savec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Virtualization features: 
  Virtualization:        VT-x
Caches (sum of all):     
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    1 MiB (4 instances)
  L3:                    6 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-3
Vulnerabilities:         
  Itlb multihit:         KVM: Mitigation: VMX disabled
  L1tf:                  Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled
  Mds:                   Mitigation; Clear CPU buffers; SMT disabled
  Meltdown:              Mitigation; PTI
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling
  Srbds:                 Mitigation; Microcode
  Tsx async abort:       Not affected

Cat output:

BOOT_IMAGE=/boot/vmlinuz-linux-zen root=UUID=410846cc-9432-4b2b-92fe-55c5c565602b rw resume=UUID=c96fd141-6fba-4e51-901b-5e3e734d6486 loglevel=3 nowatchdog nvme_load=YES

Ok, your CPU has IOMMU support, but it’s not enabled for some reason.

There are multiple “levels” of Intel virtualization.

You’ll notice in your “Virtualization Features” section of the lscpu output, it say VT-x. You’re looking for VT-d.

I would peruse your bios and add intel_iommu=pt to the grub flags.

I see, where do I append that in the grub configuration file(s)?

/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT variable.

Odd, that variable doesn’t exist. My grub.cfg file and my /default/grub file are the same.

What docs have you been following to try PCI passthrough out?
Any decent docs should list the steps to enable IOMMU on each platform, and usually has a script to detcst whether it’s working.

1 Like

that’s incredibly strange.

I have to step out for probably the rest of the day, for work. I can return to this later.

I skimmed through this page to append GRUB_CMDLINE_LINUX_DEFAULT to my grub file, which I seem to have never done, because as I stated, it’s the same as grub.cfg.

Take your time, thank you for your help so far.

1 Like

Could this be the auto vs full enable thing? On some boards you have to switch IOMMU from “auto” to “on” otherwise it won’t work properly.

I don’t believe that is the issue in this case. My motherboard (ASRock) doesn’t have an IOMMU option to my knowledge, instead simply containing a VT-d toggle, which I have enabled.

That is correct for Intel.

I kinda wrote the book on this topic, this should help:

Have you read the linked wiki page on how to apply changes to grub once you have edited the config file?
https://wiki.archlinux.org/title/Kernel_parameters#GRUB

Edit /etc/default/grub and append your kernel options between the quotes in the GRUB_CMDLINE_LINUX_DEFAULT line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
And then automatically re-generate the grub.cfg file with:
# grub-mkconfig -o /boot/grub/grub.cfg

I’ve resolved the grub files mix-up, and have read a bit of this guide, but I’m confused as to my Intel equivalent of the Kernel Driver Overrides | VFIO section.

Edit: Ran through the entire guide, still faced with the same error.

1 Like

Thanks, my only obstacle now is to find out which device to use for my QEMU bridge. How do I find this?

These are only for GPU drivers, not for the CPU.

With VFIO, we need to stop AMDGPU or Nvidia from loading and attaching to a GPU, because it’s very difficult to detach them.

With something like a USB controller, it’s easy, QEMU just issues an unbind command.

Which bridge are you talking about?

In QEMU, it asks me for a bridge device, which I am supposed to provide as stated in your guide. The problem is, I don’t have a bridge device, nor any clue as to how to create one.

network bridge, probably.

Are you building this in libvirt or straight command line?

If libvirt, it should have set one up automatically. If not, you’ll need to create a network bridge, this should help:

I’m building in libvirt, though when executing

sudo virsh net-list --all

from the provided guide, this spits out in the terminal:

error: failed to connect to the hypervisor
error: Operation not supported: Cannot use direct socket mode if no URI is set