You are not logged in.

#1 2018-02-13 20:50:14

Planctron
Member
Registered: 2018-02-13
Posts: 2

(QEMU) Passthough boot GPU

Hello.
I try passthrough boot graphics adapter to virtual machine. I know it is possible.
I using EFI on host machine and OVMF on guest.
Here is my configuration for VM starting:

type="system-x86_64"

args=" \
-drive file=/dev/disk/by-id/ata-ST500DM002-1BD142_W3T506DV,if=virtio,format=raw \
-drive if=pflash,format=raw,readonly,file=/usr/share/ovmf/x64/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/usr/share/ovmf/x64/OVMF_VARS.fd \
-cpu host,kvm=off,hv_vendor_id=123456789ab \
-device vfio-pci,host=02:00.0 \
-device vfio-pci,host=02:00.1 \
-machine type=q35,accel=kvm \
-net nic \
-net bridge,br=br0 \
-m 4G \
-vnc :0 \
-enable-kvm \
-balloon virtio \
-usbdevice host:1c4f:000e \
-usbdevice host:09da:9090 \
"

It is working configuration for non-boot GPU. But I need passthough ALL graphics adapters to VM's.

Here is my dmesg output (also contains kernel parameters)

# dmesg | grep vfio
[    0.000000] Command line: root=UUID=e63968dd-4c76-491a-8ac6-18488de793e7 rw initrd=/initramfs-linux.img video=efifb:off,uvesafb:off intel_iommu=on earlymodules=vfio-pci nofb
[    0.000000] Kernel command line: root=UUID=e63968dd-4c76-491a-8ac6-18488de793e7 rw initrd=/initramfs-linux.img video=efifb:off,uvesafb:off intel_iommu=on earlymodules=vfio-pci nofb
[   17.002863] vfio-pci 0000:02:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[   17.038292] vfio-pci 0000:81:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none

I need passthough IOMMU groups 42 and 48:

IOMMU Group 42 02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP108 [GeForce GT 1030] [10de:1d01] (rev a1)
IOMMU Group 42 02:00.1 Audio device [0403]: NVIDIA Corporation GP108 High Definition Audio Controller [10de:0fb8] (rev a1)
IOMMU Group 48 81:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP108 [GeForce GT 1030] [10de:1d01] (rev a1)
IOMMU Group 48 81:00.1 Audio device [0403]: NVIDIA Corporation GP108 High Definition Audio Controller [10de:0fb8] (rev a1)

VGA controllers is identical. I have script for resolve this problem:

# cat /bin/vfio-pci-override.sh 
#!/bin/sh
echo "vfio-pci" > "/sys/devices/pci0000:00/0000:00:02.0/0000:02:00.0/driver_override"
echo "vfio-pci" > "/sys/devices/pci0000:00/0000:00:02.0/0000:02:00.1/driver_override"
echo "vfio-pci" > "/sys/devices/pci0000:80/0000:80:02.0/0000:81:00.0/driver_override"
echo "vfio-pci" > "/sys/devices/pci0000:80/0000:80:02.0/0000:81:00.1/driver_override"
modprobe -i vfio-pci

Driver overriding is working:

# ls /dev/vfio
42   48  vfio

But when I starting VM i receive an error:

feb 13 20:34:30 hypervisor env[719]: qemu-system-x86_64: -device vfio-pci,host=02:00.0: Failed to mmap 0000:02:00.0 BAR 1. Performance may be slow

After that, dmesg start flooding:

[ 1417.323909] vfio-pci 0000:02:00.0: BAR 1: can't reserve [mem 0x383fe0000000-0x383fefffffff 64bit pref]
[ 1417.323915] vfio-pci 0000:02:00.0: BAR 1: can't reserve [mem 0x383fe0000000-0x383fefffffff 64bit pref]
[ 1417.323921] vfio-pci 0000:02:00.0: BAR 1: can't reserve [mem 0x383fe0000000-0x383fefffffff 64bit pref]
[ 1417.323927] vfio-pci 0000:02:00.0: BAR 1: can't reserve [mem 0x383fe0000000-0x383fefffffff 64bit pref]
. . .

Address range really used by BOOTFB:

# cat /proc/iomem
380000000000-383fffffffff : PCI Bus 0000:00
  380000000000-3800001fffff : PCI Bus 0000:01
  383fe0000000-383ff1ffffff : PCI Bus 0000:02
    383fe0000000-383fefffffff : 0000:02:00.0
      383fe0000000-383fe21bffff : BOOTFB
    383ff0000000-383ff1ffffff : 0000:02:00.0
      383ff0000000-383ff1ffffff : vfio-pci
  383ffff00000-383ffff0ffff : 0000:00:14.0
    383ffff00000-383ffff0ffff : xhci-hcd
  383ffff10000-383ffff13fff : 0000:00:1b.0
    383ffff10000-383ffff13fff : ICH HD audio
  383ffff14000-383ffff17fff : 0000:00:04.7
    383ffff14000-383ffff17fff : ioatdma
  383ffff18000-383ffff1bfff : 0000:00:04.6
    383ffff18000-383ffff1bfff : ioatdma
  383ffff1c000-383ffff1ffff : 0000:00:04.5
    383ffff1c000-383ffff1ffff : ioatdma
  383ffff20000-383ffff23fff : 0000:00:04.4
    383ffff20000-383ffff23fff : ioatdma
  383ffff24000-383ffff27fff : 0000:00:04.3
    383ffff24000-383ffff27fff : ioatdma
  383ffff28000-383ffff2bfff : 0000:00:04.2
    383ffff28000-383ffff2bfff : ioatdma
  383ffff2c000-383ffff2ffff : 0000:00:04.1
    383ffff2c000-383ffff2ffff : ioatdma
  383ffff30000-383ffff33fff : 0000:00:04.0
    383ffff30000-383ffff33fff : ioatdma
  383ffff35000-383ffff350ff : 0000:00:1f.3
. . .

I tried remove VGA controller and rescan PCI bus.
Bad solution. In addition, it does not work.

# echo 1 > /sys/bus/pci/devices/0000\:02\:00.0/remove
# echo 1 > /sys/bus/pci/rescan
# sh /bin/vfio-pci-override.sh
# ls /dev/vfio
48  vfio

No more VFIO group with boot GPU (42). Need reboot.

How disable boot framebuffer? I don't need any graphics output from host system.
Hope for community help. Thanks in advance.

Last edited by Planctron (2018-02-13 21:15:58)

Offline

#2 2018-02-16 22:22:38

Planctron
Member
Registered: 2018-02-13
Posts: 2

Re: (QEMU) Passthough boot GPU

Possible solution - is forcefully-remove-bootfb script
Needs libelf-devel for compile. Cannot find this package in AUR.

Last edited by Planctron (2018-02-16 22:23:39)

Offline

Board footer

Powered by FluxBB