![VFIO 不能用于内存控制器](https://linux22.com/image/116058/VFIO%20%E4%B8%8D%E8%83%BD%E7%94%A8%E4%BA%8E%E5%86%85%E5%AD%98%E6%8E%A7%E5%88%B6%E5%99%A8.png)
我正在尝试在 QEMU/KVM 中设置音频设备的 PCI 直通。音频设备与其他三个设备一起位于组 9 中:
IOMMU Group 9 00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:9d4e] (rev 21)
IOMMU Group 9 00:1f.2 Memory controller [0580]: Intel Corporation Sunrise Point-LP PMC [8086:9d21] (rev 21)
IOMMU Group 9 00:1f.3 Audio device [0403]: Intel Corporation Device [8086:9d71] (rev 21)
IOMMU Group 9 00:1f.4 SMBus [0c05]: Intel Corporation Sunrise Point-LP SMBus [8086:9d23] (rev 21)
因此,我/etc/modprobe.d/vfio
用我想要附加的设备修改了我的:
00:1f.0 0601: 8086:9d4e (rev 21)
00:1f.2 0580: 8086:9d21 (rev 21)
00:1f.3 0403: 8086:9d71 (rev 21)
00:1f.4 0c05: 8086:9d23 (rev 21)
所以文件读取
options vfio-pci ids=8086:9d4e,8086:9d21,8086:9d71,8086:9d23
另外,为了在启动时给它们充电,我修改了mkinitcpio
所以它加载vfio vfio_iommu_type1 vfio_pci vfio_virqfd
它起作用了:
$ dmesg | grep vfio
[ 0.746712] vfio_pci: add [8086:9d4e[ffff:ffff]] class 0x000000/00000000
[ 0.746715] vfio_pci: add [8086:9d21[ffff:ffff]] class 0x000000/00000000
[ 0.762942] vfio_pci: add [8086:9d71[ffff:ffff]] class 0x000000/00000000
[ 0.762968] vfio_pci: add [8086:9d23[ffff:ffff]] class 0x000000/00000000
但是,由于某种原因,内存控制器继续使用intel_pmc_core
内核驱动程序,而不是vfio-pci
像所有其他控制器一样使用内核驱动程序
$ lspci -k -s 00:1f
00:1f.0 ISA bridge: Intel Corporation Device 9d4e (rev 21)
Subsystem: Hewlett-Packard Company Device 827e
Kernel driver in use: vfio-pci
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
Subsystem: Hewlett-Packard Company Device 827e
Kernel driver in use: intel_pmc_core
00:1f.3 Audio device: Intel Corporation Device 9d71 (rev 21)
Subsystem: Hewlett-Packard Company Device 827e
Kernel driver in use: vfio-pci
Kernel modules: snd_hda_intel, snd_soc_skl
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
Subsystem: Hewlett-Packard Company Device 827e
Kernel driver in use: vfio-pci
Kernel modules: i2c_i801
因此,qemu 抱怨并非所有 IOMMU 组都经过:
$ qemu-system-x86_64 -hda /home/janus/qemu/win10qemu.img -enable-kvm -device vfio-pci,host=0000:00:1f.0 -device vfio-pci,host=0000:00:1f.2 -device vfio-pci,host=0000:00:1f.3 -device vfio-pci,host=0000:00:1f.4
qemu-system-x86_64: -device vfio-pci,host=0000:00:1f.0: vfio error: 0000:00:1f.0: group 9 is not viable
Please ensure all devices within the iommu_group are bound to their vfio bus driver.
我做错了什么?
答案1
答案似乎是:我当然不能将内存控制器传递给虚拟机。由于声卡与内存控制器位于同一 IOMMU 组中,因此我无法将其传递给 VM。