vfio-pci 的 softdep 不起作用

vfio-pci 的 softdep 不起作用

我正在尝试进行直通,以便我的设备在任何其他模块之前被 vfio-pci 抓取。这是我的/etc/modprobe.d/01-vfio-pci.conf

softdep nouveau pre: vfio-pci
softdep nvidiafb pre: vfio-pci
softdep snd_hda_intel pre: vfio-pci
softdep nvidia-gpu pre: vfio-pci
softdep i2c_nvidia_gpu pre: vfio-pci
softdep xhci_hcd pre: vfio-pci
options vfio-pci ids=10de:2184,10de:1aeb,10de:1aec,10de:1aed,1022:145f

但启动后的设备如下:

07:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU116 [GeForce GTX 1660] [10de:2184] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: NVIDIA Corporation TU116 [GeForce GTX 1660] [10de:1324]
    Flags: fast devsel, IRQ 10
    Memory at f6000000 (32-bit, non-prefetchable) [disabled] [size=16M]
    Memory at d0000000 (64-bit, prefetchable) [disabled] [size=256M]
    Memory at e0000000 (64-bit, prefetchable) [disabled] [size=32M]
    I/O ports at f000 [disabled] [size=128]
    Expansion ROM at f7000000 [disabled] [size=512K]
    Capabilities: <access denied>
    Kernel driver in use: vfio-pci
    Kernel modules: nvidiafb, nouveau

07:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:1aeb] (rev a1)
    Subsystem: NVIDIA Corporation Device [10de:1324]
    Flags: fast devsel, IRQ 11
    Memory at f7080000 (32-bit, non-prefetchable) [disabled] [size=16K]
    Capabilities: <access denied>
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel

07:00.2 USB controller [0c03]: NVIDIA Corporation Device [10de:1aec] (rev a1) (prog-if 30 [XHCI])
    Subsystem: NVIDIA Corporation Device [10de:1324]
    Flags: fast devsel, IRQ 47
    Memory at e2000000 (64-bit, prefetchable) [size=256K]
    Memory at e2040000 (64-bit, prefetchable) [size=64K]
    Capabilities: <access denied>
    Kernel driver in use: xhci_hcd

07:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device [10de:1aed] (rev a1)
    Subsystem: NVIDIA Corporation Device [10de:1324]
    Flags: bus master, fast devsel, latency 0, IRQ 61
    Memory at f7084000 (32-bit, non-prefetchable) [size=4K]
    Capabilities: <access denied>
    Kernel driver in use: nvidia-gpu
    Kernel modules: i2c_nvidia_gpu

08:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Zeppelin USB 3.0 Host controller [1022:145f] (prog-if 30 [XHCI])
    Subsystem: Gigabyte Technology Co., Ltd Zeppelin USB 3.0 Host controller [1458:5007]
    Flags: bus master, fast devsel, latency 0, IRQ 48
    Memory at f7200000 (64-bit, non-prefetchable) [size=1M]
    Capabilities: <access denied>
    Kernel driver in use: xhci_hcd

如您所见,只有一些被抓取。但它们并没有被我添加的 modprobe 规则抓取,即使没有它也可以工作。

lz@z:~$ cat /etc/initramfs-tools/modules
# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
# Syntax:  module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod
vfio 
vfio_iommu_type1 
vfio_virqfd 
options vfio_pci ids=10de:2184,10de:1aeb,10de:1aec,10de:1aed,1022:145f
vfio_pci ids=10de:2184,10de:1aeb,10de:1aec,10de:1aed,1022:145f
vfio_pci

lz@z:~$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

vfio 
vfio_iommu_type1 
vfio_pci ids=10de:2184,10de:1aeb,10de:1aec,10de:1aed,1022:145f

答案1

USB 模块 xhci_hcd 位于内核中。它在模块之前加载。

这应该在 grub 中作为内核参数工作:

GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on modprobe.blacklist=xhci_hcd"

答案2

我已经很多天无法让 Ubuntu 20.04(云映像)运行 vfio-pci。结果发现 /etc/modules /etc/initramfs-tools/ /etc/modprobe.d/*.conf 都没有影响。Vfio 模块已经内置到内核中。我认为黑名单文件可能已经起作用了。但是对于设置 pci id,只有 grub 内核参数起作用。而关键在于:只适用于vfio-pci.idsnot vfio-pci ids。啊!..终于恢复了活力。:)

相关内容