Skip to content

Instantly share code, notes, and snippets.

@PedroHLC
Last active January 5, 2018 00:23
Show Gist options
  • Save PedroHLC/5c54785a00efa3f08154 to your computer and use it in GitHub Desktop.
Save PedroHLC/5c54785a00efa3f08154 to your computer and use it in GitHub Desktop.
VGA Passthrough Situation Diagnose
Passing GTX780 at BUS 5 (PCIEX4)
OVMF: works even from the moment bios starts - weird perfomance - fps variates a lot,
ACUnity and RE6 runs at half fps it should, system interface is
almost as smooth as native.
SeaBios: tested only Windows setup, which also works, I can see bios working too.
Passing GTX780 at BUS 1 (PCIEX16)
OVMF: error code 43
SeaBios: error code 43
Even with MSI forced, audio through HDMI is sometimes cracking, sometimes not,
when audio cracks vps variations are higher...
Useless observations:
* I did tried to backup GPU ROM while on BUS5 using TechPowerUp's GPU-Z, and then try
it (still in BUS5), the result is no video + Windows freezing while loading. So probably
it's a bad ideia to use a ROM....
* Though I did enabled "ignore_msrs" as suggested in Arch's Wiki, GeForce Experience
still complains about my GPU being incompatible.
Radeon device:
VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Turks XT [Radeon HD 6670/7670]
Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Turks/Whistler HDMI Audio [Radeon HD 6000 Series]
Subsystem: XFX Pine Group Inc. Device aa90
NVIDIA device:
VGA compatible controller: NVIDIA Corporation GK110 [GeForce GTX 780] (rev a1)
Audio device: NVIDIA Corporation GK110 HDMI Audio (rev a1)
Subsystem: ZOTAC International (MCO) Ltd. Device 3255
CPU:
AMD FX(tm)-8350 Eight-Core Processor
AMD-V
Mobo:
Gigabyte 970A-DS3P (rev. 1.0)
BIOS:
American Megatrends Inc.
Ver: F2j (12/29/2014) #LATEST->BETA
RAM:
1x DDR3 1866Mhz 8GB KINGSTON - KHX1866C10D3 at clock speed 933Mhz
Linux:
+uname: Linux PedroHLC-PC 4.1.9-2-lts #1 SMP Thu Oct 1 15:21:06 CEST 2015 x86_64 GNU/Linux
+kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-lts root=UUID=0ce50b00-dcf6-4847-a552-fe744c9bcbac rw nofb amd_iommu=on iommu=pt iommu=1 pci-stub.ids=10de:1004,10de:0e1a
+ArchLinux x86_64 bleeding-edge updated
+GRUB i386-linux
PCI Buses:
01:00. *PCI Express x16 slot, running at x16 (PCIEX16)
05:00. *PCI Express x16 slot, running at x4 (PCIEX4)
Relevant Settings:
/etc/mkinitcpio.conf
MODULES="pci-stub vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
HOOKS="base udev autodetect modconf block filesystems keyboard fsck"
/etc/modprobe.d/*
options kvm-amd npt=0
options kvm ignore_msrs=1
blacklist nouveau
blacklist nvidia
blacklist nvidiafb
blacklist nvidia-lts
blacklist vesafb
blacklist uvesafb
# Commented by now as I'm testing pci-stub and using bind_gpu.sh when testing vfio
#options vfio-pci ids=10de:1004,10de:0e1a
/etc/default/grub
# "amd_iommu=on" seems to not change anything at all...
GRUB_CMDLINE_LINUX="nofb amd_iommu=on iommu=pt iommu=1 pci-stub.ids=10de:1004,10de:0e1a"
GRUB_GFXPAYLOAD_LINUX=text
/Windows
Installed using UEFI
MSI forced through registry
Tested games: GTAV, Portal 2, RE6, Assassin's Creed Unity (through Steam)
echo -n "Binding GPU..."
for dev in "0000:0X:00.0" "0000:0X:00.1"; do
vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
device=$(cat /sys/bus/pci/devices/${dev}/device)
if [ -e /sys/bus/pci/devices/${dev}/driver ]; then
echo "${dev}" | sudo tee /sys/bus/pci/devices/${dev}/driver/unbind > /dev/null
while [ -e /sys/bus/pci/devices/${dev}/driver ]; do
sleep 0.1
done
fi
echo "${vendor} ${device}" | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id > /dev/null
done
echo "done"
#!/bin/bash
export QEMU_AUDIO_DRV=pa
sudo qemu-system-x86_64 \
-drive if=pflash,format=raw,readonly,file=/usr/local/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd \
-name NEOWBOX \
-enable-kvm \
-cpu host,kvm=off \
-mem-path /dev/hugepages \
-mem-prealloc \
-smp sockets=1,cores=8,threads=1 \
-m 5120 \
-device virtio-scsi-pci,id=scsi0 \
-drive file=/opt/neowbox/maindisk.img,id=diskB,format=raw,if=none,cache=none,aio=native -device scsi-hd,drive=diskB \
-drive file=/dev/sdb,id=disk1,format=raw,if=none,cache=none,aio=native -device scsi-hd,drive=disk1 \
-serial none -parallel none \
-soundhw hda \
-net nic,macaddr=52:54:23:23:23:01 -net bridge,br=wbox0 \
\
-monitor stdio \
-device vfio-pci,host=05:00.0,addr=09.0,multifunction=on \
-device vfio-pci,host=05:00.1,addr=09.1 \
-usb -usbdevice host:046d:c534 \
-vga none -nographic
#!/bin/bash
export QEMU_AUDIO_DRV=pa
sudo qemu-system-x86_64 \
-name NEOWBOX \
-enable-kvm \
-cpu host,kvm=off \
-mem-path /dev/hugepages \
-mem-prealloc \
-smp sockets=1,cores=8,threads=1 \
-m 5120 \
-device ahci,id=ahci \
-drive id=diskBoot,file=/opt/neowbox/winboot.img,format=raw,if=none -device ide-drive,drive=diskBoot,bus=ahci.0 \
-drive id=diska,file=/dev/sda,format=raw,if=none -device ide-drive,drive=diska,bus=ahci.1 \
-drive id=diskb,file=/dev/sdb,format=raw,if=none -device ide-drive,drive=diskb,bus=ahci.2 \
-boot order=d \
-serial none -parallel none \
-soundhw hda \
-net nic,macaddr=52:54:23:23:23:01 -net bridge,br=wbox0 \
\
-monitor stdio \
-device vfio-pci,host=05:00.0,addr=09.0,multifunction=on,x-vga=on \
-device vfio-pci,host=05:00.1,addr=09.1 \
-usb -usbdevice host:046d:c534 \
-nographic -vga none
#PCI-STUB
[ 1.306440] pci-stub: add 10DE:1004 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[ 1.306451] pci-stub 0000:05:00.0: claimed by stub
[ 1.306456] pci-stub: add 10DE:0E1A sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[ 1.306464] pci-stub 0000:05:00.1: claimed by stub
#VFIO
[ 1.307798] vfio_pci: add [10de:1004[ffff:ffff]] class 0x000000/00000000
[ 1.307803] vfio_pci: add [10de:0e1a[ffff:ffff]] class 0x000000/00000000
#IOMMU
[ 1.212867] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[ 3.294591] AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[ 3.294594] AMD IOMMUv2 functionality not available on this system
#AMD-Vi
[ 1.212867] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[ 1.212869] AMD-Vi: Interrupt remapping enabled
[ 1.212987] AMD-Vi: Initialized for Passthrough Mode
#VGA Arbiter
count:2,PCI:0000:01:00.0,decodes=io+mem,owns=io+mem,locks=none(0:0)
#/proc/iomem
...
c0000000-cfffffff : PCI Bus 0000:01
c0000000-cfffffff : 0000:01:00.0
d0000000-d9ffffff : PCI Bus 0000:05
d0000000-d7ffffff : 0000:05:00.0
d8000000-d9ffffff : 0000:05:00.0
da100000-da1fffff : PCI Bus 0000:03
da100000-da103fff : 0000:03:00.0
da100000-da103fff : r8169
...
fd000000-fe0fffff : PCI Bus 0000:05
fd000000-fdffffff : 0000:05:00.0
fe000000-fe07ffff : 0000:05:00.0
fe080000-fe083fff : 0000:05:00.1
fe100000-fe1fffff : PCI Bus 0000:03
fe100000-fe100fff : 0000:03:00.0
fe100000-fe100fff : r8169
...
fe300000-fe3fffff : PCI Bus 0000:01
fe300000-fe31ffff : 0000:01:00.0
fe320000-fe33ffff : 0000:01:00.0
fe340000-fe343fff : 0000:01:00.1
fe340000-fe343fff : ICH HD audio
#PCI-STUB
#nothing changes
#VFIO
#add:
[ 350.408307] vfio-pci 0000:05:00.0: enabling device (0000 -> 0003)
[ 350.408598] vfio_ecap_init: 0000:05:00.0 hiding ecap 0x19@0x900
#IOMMU
#nothing changes
#AMD-Vi
#nothing changes
#VGA Arbiter
#nothing changes
#/proc/iomem
...
c0000000-cfffffff : PCI Bus 0000:01
c0000000-cfffffff : 0000:01:00.0
d0000000-d9ffffff : PCI Bus 0000:05
d0000000-d7ffffff : 0000:05:00.0
d0000000-d7ffffff : vfio-pci
d8000000-d9ffffff : 0000:05:00.0
d8000000-d9ffffff : vfio-pci
...
fd000000-fe0fffff : PCI Bus 0000:05
fd000000-fdffffff : 0000:05:00.0
fd000000-fdffffff : vfio-pci
fe000000-fe07ffff : 0000:05:00.0
fe080000-fe083fff : 0000:05:00.1
fe080000-fe083fff : vfio-pci
...
fe300000-fe3fffff : PCI Bus 0000:01
fe300000-fe31ffff : 0000:01:00.0
fe320000-fe33ffff : 0000:01:00.0
fe340000-fe343fff : 0000:01:00.1
fe340000-fe343fff : ICH HD audio
#PCI-STUB
[ 1.315320] pci-stub: add 10DE:1004 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[ 1.315331] pci-stub 0000:01:00.0: claimed by stub
[ 1.315336] pci-stub: add 10DE:0E1A sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[ 1.315343] pci-stub 0000:01:00.1: claimed by stub
#VFIO
[ 1.316881] vfio_pci: add [10de:1004[ffff:ffff]] class 0x000000/00000000
[ 1.316888] vfio_pci: add [10de:0e1a[ffff:ffff]] class 0x000000/00000000
#IOMMU
[ 1.222574] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[ 3.308552] AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[ 3.308554] AMD IOMMUv2 functionality not available on this system
#AMD-Vi
[ 1.222574] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[ 1.222575] AMD-Vi: Interrupt remapping enabled
[ 1.222689] AMD-Vi: Initialized for Passthrough Mode
#VGA Arbiter
count:2,PCI:0000:01:00.0,decodes=io+mem,owns=io+mem,locks=none(0:0)
#/proc/iomem
...
c0000000-cfffffff : PCI Bus 0000:05
c0000000-cfffffff : 0000:05:00.0
d0000000-d9ffffff : PCI Bus 0000:01
d0000000-d7ffffff : 0000:01:00.0
d8000000-d9ffffff : 0000:01:00.0
da100000-da1fffff : PCI Bus 0000:03
da100000-da103fff : 0000:03:00.0
...
fd000000-fe0fffff : PCI Bus 0000:01
fd000000-fdffffff : 0000:01:00.0
fe000000-fe07ffff : 0000:01:00.0
fe080000-fe083fff : 0000:01:00.1
fe100000-fe1fffff : PCI Bus 0000:05
fe100000-fe11ffff : 0000:05:00.0
fe120000-fe13ffff : 0000:05:00.0
fe140000-fe143fff : 0000:05:00.1
#PCI-STUB
#nothing changes
#VFIO
#add:
[ 502.042903] vfio_ecap_init: 0000:01:00.0 hiding ecap 0x19@0x900
[ 503.903199] vfio-pci 0000:01:00.0: Invalid ROM contents
[ 503.903277] vfio-pci 0000:01:00.0: Invalid ROM contents
#IOMMU
#nothing changes
#AMD-Vi
#nothing changes
#VGA Arbiter
#nothing changes
#/proc/iomem
...
d0000000-d9ffffff : PCI Bus 0000:01
d0000000-d7ffffff : 0000:01:00.0
d0000000-d7ffffff : vfio-pci
d8000000-d9ffffff : 0000:01:00.0
d8000000-d9ffffff : vfio-pci
da100000-da1fffff : PCI Bus 0000:03
da100000-da103fff : 0000:03:00.0
da100000-da103fff : r8169
...
fd000000-fe0fffff : PCI Bus 0000:01
fd000000-fdffffff : 0000:01:00.0
fd000000-fdffffff : vfio-pci
fe000000-fe07ffff : 0000:01:00.0
fe080000-fe083fff : 0000:01:00.1
fe080000-fe083fff : vfio-pci
fe100000-fe1fffff : PCI Bus 0000:05
fe100000-fe11ffff : 0000:05:00.0
fe120000-fe13ffff : 0000:05:00.0
fe140000-fe143fff : 0000:05:00.1
fe140000-fe143fff : ICH HD audio
Section "ServerLayout"
Identifier "Main"
Screen 0 "RadSc" 0 0
#Screen 1 "NvdSc" RightOf "RadSc"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "off"
Option "Clone" "off"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "Monitor"
Identifier "MonRadeon"
EndSection
#Section "Monitor"
#Identifier "MonNVIDIA"
#EndSection
Section "Device"
Identifier "DevRadeon"
Driver "radeon"
BusID "PCI:X:0:0"
Screen 0
EndSection
#Section "Device"
#Identifier "DevNVIDIA"
#Driver "nvidia"
#BusID "PCI:Y:0:0"
#Screen 0
#EndSection
Section "Screen"
Identifier "RadSc"
Device "DevRadeon"
Monitor "MonRadeon"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
#Section "Screen"
#Identifier "NvdSc"
#Device "DevNVIDIA"
#Monitor "MonNVIDIA"
#DefaultDepth 24
#SubSection "Display"
#Depth 24
#Modes "1920x1080_60.00"
#EndSubSection
#EndSection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment