Skip to contentSkip to conversation

Problems using vfio pcie passthrough (pci-assign works)

DISCUSSION Bruce Cran 2 participants 6 messages Oct 2, 2014 KVM

lore
Share & tools
lore

Bruce Cran

author
#0 lore raw

I have a PCIe card that's behind an Intel E3-1200 PCIe x16 controller bridge that I want to use in VMs: it works when using the pci-assign driver, but something goes wrong when trying to use vfio-pci - my driver in the guest gets so far through loading before failing to talk to the hardware, so I guess something's not being setup correctly. I'm wondering if this is a bug (do vfio and OVMF work together?) or a problem with the way I'm setting up vfio-pci. I'm using the script from http://www.linux-kvm.org/wiki/images/b/b4/2012-forum-VFIO.pdf page 30 to assign the card, but I know it's a fairly old document, and I'm running kernel 3.11 on openSUSE: is it still correct? Or should I not try to use vfio-pci for now?

Signature · 1 line
Bruce Cran
#1 lore raw
Quoted 11 lines · Bruce Cran

I have a PCIe card that's behind an Intel E3-1200 PCIe x16 controller bridge that I want to use in VMs: it works when using the pci-assign driver, but something goes wrong when trying to use vfio-pci - my driver in the guest gets so far through loading before failing to talk to the hardware, so I guess something's not being setup correctly. I'm wondering if this is a bug (do vfio and OVMF work together?) or a problem with the way I'm setting up vfio-pci. I'm using the script from
http://www.linux-kvm.org/wiki/images/b/b4/2012-forum-VFIO.pdf page 30 to assign the card, but I know it's a fairly old document, and I'm running
kernel 3.11 on openSUSE: is it still correct? Or should I not try to
use vfio-pci for now?

What's the device you're trying to assign and the scripts you're using to do so? vfio-pci is fully supported, but I'd recommend a kernel newer than 3.11 (maybe a newer QEMU too, you didn't specify a version) unless openSUSE is specifically pulling vfio features and fixes into their distro. vfio does work with OVMF, most of the testing of this is with GPU assignment. It does require an OVMF image built from a fairly recent tree (not more than a few months old), but if you're getting into the guest OS you're probably fine. Provide more details and I can try to help. Thanks,

Alex

author
#2 lore raw
Quoted 9 lines · Alex Williamson

What's the device you're trying to assign and the scripts you're using to do so? vfio-pci is fully supported, but I'd recommend a kernel newer than 3.11 (maybe a newer QEMU too, you didn't specify a version) unless openSUSE is specifically pulling vfio features and fixes into their distro. vfio does work with OVMF, most of the testing of this is with GPU assignment. It does require an OVMF image built from a fairly recent tree (not more than a few months old), but if you're getting into the guest OS you're probably fine. Provide more details and I can try to help.

Thanks, the device is a mass storage device that I work on; it's in iommu group 1 so the script I'm running is:

for i in $(ls /sys/kernel/iommu_groups/1/devices/); do
echo $i | sudo tee \
/sys/kernel/iommu_groups/1/devices/$i/driver/unbind VEN=$(cat /sys/kernel/iommu_groups/1/devices/$i/vendor) DEV=$(cat /sys/kernel/iommu_groups/1/devices/$i/device) echo $VEN $DEV | sudo tee \
/sys/bus/pci/drivers/vfio-pci/new_id
done

I started out trying to use the version of qemu that openSUSE provides which is 1.6.2 but I also built 2.1.2 from source and that didn't help. In terms of OVMF, I've tried an OVMF-pure-efi.fd binary from https://www.kraxel.org/repos/jenkins/edk2/ as well as building a debug OVMF.fd binary from the edk2 project (https://github.com/tianocore/edk2/commit/23a2df76783ad7694918916f28e24cd1a1f84daf).

If you think it might help, I can certainly install a newer kernel.

Signature · 1 line
Bruce
#3 lore raw
Quoted 14 lines · Bruce Cran
Quoted 9 lines · Alex Williamson

What's the device you're trying to assign and the scripts you're using to do so? vfio-pci is fully supported, but I'd recommend a kernel newer than 3.11 (maybe a newer QEMU too, you didn't specify a version) unless openSUSE is specifically pulling vfio features and fixes into their distro. vfio does work with OVMF, most of the testing of this is with GPU assignment. It does require an OVMF image built from a fairly recent tree (not more than a few months old), but if you're getting into the guest OS you're probably fine. Provide more details and I can try to help.

Thanks, the device is a mass storage device that I work on; it's in iommu group 1 so the script I'm running is:

Quoted 8 lines

for i in $(ls /sys/kernel/iommu_groups/1/devices/); do

   echo $i | sudo tee \
   /sys/kernel/iommu_groups/1/devices/$i/driver/unbind
   VEN=$(cat /sys/kernel/iommu_groups/1/devices/$i/vendor)
   DEV=$(cat /sys/kernel/iommu_groups/1/devices/$i/device)
   echo $VEN $DEV | sudo tee \
   /sys/bus/pci/drivers/vfio-pci/new_id

done

If you have reasonably new libvirt, you can just do this via virsh:

virsh nodedev-detach pci_0000_01_00_0 --driver vfio

(for example, assuming a pci address of 0000:01:00.0)

Quoted 6 lines

I started out trying to use the version of qemu that openSUSE provides which is 1.6.2 but I also built 2.1.2 from source and that didn't help. In terms of OVMF, I've tried an OVMF-pure-efi.fd binary from
https://www.kraxel.org/repos/jenkins/edk2/ as well as building a debug OVMF.fd binary from the edk2 project
(https://github.com/tianocore/edk2/commit/23a2df76783ad7694918916f28e24cd1a1f84daf).

That should be fine, that's where I get OVMF from too.

Quoted 1 line

If you think it might help, I can certainly install a newer kernel.

Yes, try on 3.16 with QEMU 2.1 and let's go from there. Thanks,

Alex

author
#4 lore raw
Quoted 1 line · Alex Williamson

Yes, try on 3.16 with QEMU 2.1 and let's go from there.

Upgrading to 3.16 fixed it and it all works fine now.

Signature · 1 line
Bruce
#5 lore raw
Quoted 4 lines · Bruce Cran
Quoted 1 line · Alex Williamson

Yes, try on 3.16 with QEMU 2.1 and let's go from there.

Upgrading to 3.16 fixed it and it all works fine now.

Great!