Last active
November 20, 2023 15:13
-
-
Save thecooldaniel/5926d679817b77000cb557df5e505744 to your computer and use it in GitHub Desktop.
VFIO Passthrough for Arch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for use with https://github.com/Witko/nvidia-xrun | |
if [ $# -gt 0 ]; then | |
$* | |
else | |
# On Antergos this forces an X0rg version of GNOME | |
export GDK_BACKEND=x11 | |
gnome-session | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/fstab | |
hugetlbfs /hugepages hugetlbfs mode=1770,gid=78 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/default/grub | |
# grub-mkconfig /boot/grub/grub.cfg | |
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on" | |
GRUB_CMDLINE_LINUX_DEFAULT="hugepagesz=1GB default_hugepagesz=1G transparent_hugepage=never" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/mkinitcpio.conf | |
# "sudo mkinitcpio -p linux" to rebuild initramfs | |
MODULES="vfio vfio_iommu_type1 vfio_pci vfio_virqfd i915 nouveau" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gfxstatus() { | |
echo -n "Card:" | |
lspci -nnk -d 10de:13c0 | |
echo -n "Audio:" | |
lspci -nnk -d 10de:0fbb | |
} | |
# Force remove the GPU from the system and rescan the PCI bus. | |
# This basically performs a hardware reset. | |
vfio_gpu_redetect() { | |
echo -n "Removing the GPU... " | |
echo 1 | sudo tee /sys/bus/pci/devices/0000:01:00.0/remove | |
echo -n "Removing HDMI Audio... " | |
echo 1 | sudo tee /sys/bus/pci/devices/0000:01:00.1/remove | |
echo -n "Rescanning PCI devices... " | |
echo 1 | sudo tee /sys/bus/pci/rescan | |
} | |
# Bind both GPU devices to the vfio-pci driver. | |
vfio_gpu_bind_vfio() { | |
sudo modprobe vfio-pci | |
echo "0000:01:00.0" | sudo tee /sys/bus/pci/drivers/vfio-pci/bind | |
echo "0000:01:00.1" | sudo tee /sys/bus/pci/drivers/vfio-pci/bind | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/modprobe.d/vfio.conf | |
options vfio-pci ids=10de:13c0,10de:0fbb disable_vga=1 | |
softdep nouveau pre: vfio-pci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> | |
<name>win10</name> | |
<uuid>4cf5f94f-ef0f-45ee-bd77-4bf70748ab24</uuid> | |
<metadata> | |
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0"> | |
<libosinfo:os id="http://microsoft.com/win/10"/> | |
</libosinfo:libosinfo> | |
</metadata> | |
<memory unit='KiB'>25600000</memory> | |
<currentMemory unit='KiB'>25600000</currentMemory> | |
<vcpu placement='static'>6</vcpu> | |
<iothreads>1</iothreads> | |
<iothreadids> | |
<iothread id='1'/> | |
</iothreadids> | |
<cputune> | |
<vcpupin vcpu='0' cpuset='1'/> | |
<vcpupin vcpu='1' cpuset='2'/> | |
<vcpupin vcpu='2' cpuset='3'/> | |
<vcpupin vcpu='3' cpuset='5'/> | |
<vcpupin vcpu='4' cpuset='6'/> | |
<vcpupin vcpu='5' cpuset='7'/> | |
<emulatorpin cpuset='0,4'/> | |
<iothreadpin iothread='1' cpuset='0,4'/> | |
</cputune> | |
<os> | |
<type arch='x86_64' machine='pc-i440fx-4.0'>hvm</type> | |
<loader readonly='yes' type='pflash'>/usr/share/ovmf/x64/OVMF_CODE.fd</loader> | |
<nvram>/var/lib/libvirt/qemu/nvram/win10_VARS.fd</nvram> | |
<bootmenu enable='yes'/> | |
</os> | |
<features> | |
<acpi/> | |
<apic/> | |
<hyperv> | |
<relaxed state='on'/> | |
<vapic state='on'/> | |
<spinlocks state='on' retries='8191'/> | |
<vendor_id state='on' value='ButteryButt'/> | |
</hyperv> | |
<kvm> | |
<hidden state='on'/> | |
</kvm> | |
<vmport state='off'/> | |
</features> | |
<cpu mode='host-passthrough' check='none'> | |
<topology sockets='1' cores='3' threads='2'/> | |
</cpu> | |
<clock offset='localtime'> | |
<timer name='rtc' tickpolicy='catchup'/> | |
<timer name='pit' tickpolicy='delay'/> | |
<timer name='hpet' present='no'/> | |
<timer name='hypervclock' present='yes'/> | |
</clock> | |
<on_poweroff>destroy</on_poweroff> | |
<on_reboot>restart</on_reboot> | |
<on_crash>destroy</on_crash> | |
<pm> | |
<suspend-to-mem enabled='no'/> | |
<suspend-to-disk enabled='no'/> | |
</pm> | |
<devices> | |
<emulator>/usr/bin/qemu-system-x86_64</emulator> | |
<disk type='file' device='disk'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/daniel/Windows10/win10.raw'/> | |
<target dev='sda' bus='scsi'/> | |
<boot order='1'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='0'/> | |
</disk> | |
<disk type='block' device='disk'> | |
<driver name='qemu' type='raw' cache='none' io='native'/> | |
<source dev='/dev/disk/by-id/<redacted>'/> | |
<target dev='sdd' bus='scsi'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='3'/> | |
</disk> | |
<disk type='block' device='disk'> | |
<driver name='qemu' type='raw' cache='none' io='native'/> | |
<source dev='/dev/disk/by-id/<redacted>'/> | |
<target dev='sde' bus='scsi'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='4'/> | |
</disk> | |
<disk type='file' device='cdrom'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/daniel/Windows10/Win10_1809Oct_English_x64.iso'/> | |
<target dev='sdb' bus='sata'/> | |
<readonly/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<disk type='file' device='cdrom'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/daniel/Windows10/virtio-win-0.1.164.iso'/> | |
<target dev='sdc' bus='sata'/> | |
<readonly/> | |
<address type='drive' controller='0' bus='0' target='0' unit='2'/> | |
</disk> | |
<controller type='usb' index='0' model='qemu-xhci' ports='15'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> | |
</controller> | |
<controller type='scsi' index='0' model='virtio-scsi'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> | |
</controller> | |
<controller type='pci' index='0' model='pci-root'/> | |
<controller type='sata' index='0'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</controller> | |
<interface type='network'> | |
<mac address='52:54:00:dc:b3:36'/> | |
<source network='default'/> | |
<model type='e1000e'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> | |
</interface> | |
<serial type='pty'> | |
<target type='isa-serial' port='0'> | |
<model name='isa-serial'/> | |
</target> | |
</serial> | |
<console type='pty'> | |
<target type='serial' port='0'/> | |
</console> | |
<input type='mouse' bus='virtio'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> | |
</input> | |
<input type='keyboard' bus='virtio'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/> | |
</input> | |
<input type='mouse' bus='ps2'/> | |
<input type='keyboard' bus='ps2'/> | |
<sound model='ich9'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> | |
</sound> | |
<hostdev mode='subsystem' type='pci' managed='yes'> | |
<source> | |
<address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> | |
</source> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> | |
</hostdev> | |
<hostdev mode='subsystem' type='pci' managed='yes'> | |
<source> | |
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/> | |
</source> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> | |
</hostdev> | |
<redirdev bus='usb' type='spicevmc'> | |
<address type='usb' bus='0' port='2'/> | |
</redirdev> | |
<redirdev bus='usb' type='spicevmc'> | |
<address type='usb' bus='0' port='3'/> | |
</redirdev> | |
<memballoon model='virtio'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> | |
</memballoon> | |
</devices> | |
<qemu:commandline> | |
<qemu:arg value='-object'/> | |
<qemu:arg value='input-linux,id=mouse1,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse'/> | |
<qemu:arg value='-object'/> | |
<qemu:arg value='input-linux,id=kbd1,evdev=/dev/input/by-id/usb-HID_Keyboard_HID_Keyboard-event-kbd,grab_all=on,repeat=on'/> | |
<qemu:env name='QEMU_AUDIO_DRV' value='pa'/> | |
<qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/> | |
</qemu:commandline> | |
</domain> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment