KVM et passthrough afin de se passer du dual-boot

Mon carte-mère supporte bien le Vt-d, mon cpu 4770s aussi.
Là où je bloque c’est sur l’attribution de la carte graphique en passthrough à la VM Windows :frowning:
Si vous savez comment faire ?

J’ai suivi ce tutoriel, mais adapté sur ma Debian Jessie
https://bbs.archlinux.org/viewtopic.php?id=162768&p=1

Preparing the GPU so we can bind it to vfio

For the next step we need to:

Blacklist radeon or nouveau or nvidia or fglrx on /etc/modprobe.d/blacklist.conf

Example, blacklisting the opensource radeon module:
    echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf 
Use pci-stub

In my case since i have 2 radeon cards blacklisting the radeon module is not an option, so i use pci-stub.

NOTE: If pci-stub was built as a module, you'll need to modify /etc/mkinitcpio.conf and add pci-stub in the MODULES section, after that you need to update your initramfs like this.

mkinitcpio -p linux-mainline

lspci
    01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cayman PRO [Radeon HD 7950] <-- radeon 7950
    01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Cayman/Antilles HDMI Audio [Radeon HD 7900 Series] <-- radeon 7950 audio
lspci -n
    01:00.0 0300: 1002:679a <-- radeon 7950
    01:00.1 0403: 1002:aaa0 <-- radeon 7950 audio
Now add this to your grub cfg file:
    pci-stub.ids=1002:679a,1002:aaa0
dmesg | grep pci-stub
    [    2.096151] pci-stub: add 1002:679a sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
    [    2.096160] pci-stub 0000:01:00.0: claimed by stub
    [    2.096165] pci-stub: add 1002:AAA0 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
    [    2.096174] pci-stub 0000:01:00.1: claimed by stub
    [    2.096178] pci-stub: add 1B21:1042 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000

Setting up vfio and kvm modules

If your board doesn’t enable interrupt remapping, you need to add this to your grub cfg:

vfio_iommu_type1.allow_unsafe_interrupts=1

Or if vfio-pci was built as a module ( default on arch )

echo “options vfio_iommu_type1 allow_unsafe_interrupts=1” > /etc/modprobe.d/vfio_iommu_type1.conf

Some applications like Passmark Performance Test and SiSoftware Sandra crash the VM without this:

echo "options kvm ignore_msrs=1" >> /etc/modprobe.d/kvm.conf

Binding a device to vfio-pci

Assuming the kernel, qemu and seabios are built and working, lets bind some devices.
You can use this script to make life easier:

#!/bin/bash

modprobe vfio-pci

for dev in "$@"; 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 > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

Save it as /usr/bin/vfio-bind

chmod 755 /usr/bin/vfio-bind

Bind the GPU:

vfio-bind 0000:01:00.0 0000:01:00.1

J’en suis ici, et je ne sais pas comment recompiler un noyau ou Qemu avec leurs options :frowning:

J’obitens:

    qemu-system-x86_64: -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: Device does not support requested feature x-vga
    qemu-system-x86_64: -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: failed to get device 0000:01:00.0
    qemu-system-x86_64: -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on: Device initialization failed.
    qemu-system-x86_64: -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on: Device 'vfio-pci' could not be initialized