Vga Passthrough Using kvm

August 2014 ยท 2 minute read

VGA Passthrough is one of the things you can do when you have more then one gpus. In my case I have one HD 7750 and GTX 770.

System config

Hardware Model
Processor AMD FX-8350
Motherboard Asus M5a97 R2.0 (Ubuntu) / Asus M5a99FX R2.0 (Arch)
Ram 4x 8GB Corsair Vengeance
SSD 128G Corsair force GS
Primary GPU Nvidia GTX 770 ( Ubuntu/Arch )
Secondary GPU AMD/ATI Radeon HD 7750
Software Version
Ubuntu 14.04 Gnome
Kernel 3.13.0 - generic
Qemu 2.0.0

Make sure your processor supports VT-d, motherboard supports IOMMU and also enable it. Note : I have seen few posts regarding some motherboards having lousy support for IOMMU.

Working settings for me

1. First thing to disable radeon drivers

2. Assigning it to pci_stub

pci_stub ids=1002:683f,1002:aab0

3. Set flags for KVM

options kvm allow_unsafe_assigned_interrupts=1 ignore_msrs=1

then execute

sudo update-initramfs

then reboot

4. Create script

    qemu-system-x86_64 -enable-kvm \
    -m 4096 \
    -hda win7.img -cdrom /path/to/iso \
    -cpu host
    -smp cores=8,threads=1,sockets=1 \
    -net nic -net tap \
    -vga cirrus \
    -device pci-assign,host=06:00.0 \
    -device pci-assign,host=06:00.1 \
    -soundhw hda

Video


Update : Benchmark

Bare metal - GTX 770


Bare metal - HD 7750

Novabench says GTX 770, but its HD 7750 (runnig on secondary).


VGA Passthrough - HD 7750 - Take 1


VGA Passthrough - HD 7750 - Take 2

Using

echo "options kvm-amd npt=0" > /etc/modprobe.d/kvm-amd.conf</code>

Refer : https://bbs.archlinux.org/viewtopic.php?pid=1270311#p1270311


VGA Passthrough - HD 7750 - Archlinux

Take 3

Assigning GTX 770

I wasn’t able to assign GTX 770 as passthrough device, few notes about it.


Update : Using VFIO in Archlinux

VGA Passthrough with VFIO works in Archlinux on my new upgraded motherboard Asus M5A99FX R2.0. Here are configurations for that.

System configuration

Arch System Config

version 2.4.0.1
1. Add vfio modules to initial ramdisk
MODULES="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
2. Run mkinitcpio -p linux
3. Add pci addresses to vfio options
options vfio-pci ids=1002:683f,1002:aab0
4. Qemu command

qemu-system-x86_64 -m 4096 -enable-kvm \
-drive file=/path/to/disk/disk.img,format=raw \
-device vfio-pci,host=03:00.0 -device vfio-pci,host=03:00.1  -cpu host -smp cores=8,threads=1,sockets=1 \
-net nic -net bridge,br=bridge0 \
-vga cirrus \
-soundhw hda


References


contact - social@apurv.me