Manjaro - Win10 - GPU passthrough

Just alike the waltkthrough for Fedora 30, I also did all of that work for Manjaro just because I wanted to cover those two basis. Chances are the steps etc. are going to be rather identical for the KVM configuration part and Windows install so I won't redoing this again, KVM is consitent across OSes (phew..).

So, let's dive into it!

Note

TLDR; if you are already familiar with Arch Linux and Manjaro, you could simply pull the configuration files from Github

Softwares and versions used in Manjaro

# QEMU - Libvirt
pacman -Qs qemu
local/libvirt 5.6.0-1
  API for controlling virtualization engines (openvz,kvm,qemu,virtualbox,xen,etc)
local/ovmf 1:r26214.20d2e5a125-1
  Tianocore UEFI firmware for qemu.
local/qemu 4.1.0-2
  A generic and open source machine emulator and virtualizer
local/vde2 2.3.2-11
  Virtual Distributed Ethernet for emulators like qemu

# MANJARO
uname -a
Linux MANJA-02 5.3.6-1-MANJARO #1 SMP PREEMPT Sat Oct 12 09:30:05 UTC 2019 x86_64 GNU/Linux

Enable IOMMU

/etc/default/grub

GRUB_DEFAULT=saved
GRUB_TIMEOUT=3
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR='Manjaro'
GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt"
update-grub

Note

Just alike in Fedora, you will need to reboot and check that your IOMMU groups map properly before proceeding forward.

Enable VFIO for your device(s)

For the non familiar people with Arch Linux specific commands, coming from another OS like Fedora (like I was) this was the most painful experience to port from that other OS to Arch Linux, however I found that the way to do it in Arch Linux to make a lot of sense and be very clean, just would benefit a lot from more steps and details from people online!

/etc/modprobe.d/vfio.conf

install vfio-pci /usr/bin/vfio-pci-override.sh options vfio-pci disable_vga=1

/etc/mkinitcpio.conf

MODULES="vfio vfio_pci vfio_iommu_type1 vfio_virqfd"
BINARIES=(/usr/bin/vfio-pci-override.sh)
FILES=(/etc/modprobe.d/vfio.conf)
HOOKS="base udev autodetect modconf block keyboard keymap filesystems vfio"

/etc/initcpio/hooks/vfio

#!/bin/bash

run_hook() {
    msg ":: Triggering vfio-pci override"
    /bin/sh /usr/bin/vfio-pci-override.sh
}

/etc/initcpio/install/vfio

#!/bin/bash
build() {
    add_file /usr/bin/vfio-pci-override.sh
    add_runscript
}

/usr/bin/vfio-pci-override.sh

#!/bin/sh

DEVS="0000:03:00.0 0000:03:00.1"

if [ ! -z "$(ls -A /sys/class/iommu)" ]; then
    for DEV in $DEVS; do
        echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override
    done
fi
modprobe -i vfio-pci

/etc/default/grub

GRUB_DEFAULT=saved
GRUB_TIMEOUT=3
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR='Manjaro'
GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt rd.driver.pre=vfio-pci video=vesafb:off,efifb:off"

Now we update our initramfs

$> mkinitcpio -p linux53
==> Building image from preset: /etc/mkinitcpio.d/linux53.preset: 'default'
-> -k /boot/vmlinuz-5.3-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.3-x86_64.img
==> Starting build: 5.3.6-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [keyboard]
-> Running build hook: [keymap]
-> Running build hook: [filesystems]
-> Running build hook: [vfio]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.3-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux53.preset: 'fallback'
-> -k /boot/vmlinuz-5.3-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.3-x86_64-fallback.img -S autodetect
==> Starting build: 5.3.6-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [keyboard]
-> Running build hook: [keymap]
-> Running build hook: [filesystems]
-> Running build hook: [vfio]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.3-x86_64-fallback.img
==> Image generation successful

$> update-grub

Note that the vfio module is included now in our bootstrap

Warning

I have changed the script from the fedora install because for some reason it was throwing an error on condition so I decided I had better things to do and just go with a simpler script

Install OVMF

pacman -S ovmf

The location of the OVMF files will be likely to be different on manjaro than Fedora if you followed the previous post. Adapt the qemu configuration file accordingly.

find /usr -name "*.fd" -type f -print
/usr/share/ovmf/x64/OVMF_CODE.fd
/usr/share/ovmf/x64/OVMF_VARS.fd

/etc/libvirt/qemu.conf

nvram = ["/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd"]

That's it, now for the steps to create the Windows 10 Virtual Machine and work around the core error 43 of NVIDIA, follow the instructions in my previous blog post