# KVM et passthrough afin de se passer du dual-boot

**URL:** <https://www.debian-fr.org/t/kvm-et-passthrough-afin-de-se-passer-du-dual-boot/60794>\
**Category:** Support Debian\
**Created:** [Février 21, 2016, 7:44 UTC](https://www.debian-fr.org/t/kvm-et-passthrough-afin-de-se-passer-du-dual-boot/60794 "2016-02-21T19:44:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![NHiX](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/ebca7d/32.png) [@NHiX](https://www.debian-fr.org/u/NHiX)\
**Post date:** [Février 21, 2016, 7:44 UTC](https://www.debian-fr.org/t/kvm-et-passthrough-afin-de-se-passer-du-dual-boot/60794/5 "2016-02-21T19:44:31Z")

</div>

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 ☹  
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](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:

```

```auto
    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

```

```auto
    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

```

```auto
    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:

```

```auto
    pci-stub.ids=1002:679a,1002:aaa0
```

```
dmesg | grep pci-stub

```

```auto
    [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:

```auto
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:

```auto
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:

```auto
#!/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

```auto
chmod 755 /usr/bin/vfio-bind
```

Bind the GPU:

```auto
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 ☹

J’obitens:

```auto
    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
```

---

_[View the full topic](https://www.debian-fr.org/t/kvm-et-passthrough-afin-de-se-passer-du-dual-boot/60794)._
