{"id":25115780,"url":"https://github.com/qaidvoid/complete-single-gpu-passthrough","last_synced_at":"2025-04-12T15:38:36.588Z","repository":{"id":44421197,"uuid":"286278178","full_name":"QaidVoid/Complete-Single-GPU-Passthrough","owner":"QaidVoid","description":"Single GPU VFIO Passthrough Guide","archived":false,"fork":false,"pushed_at":"2024-08-26T11:51:07.000Z","size":72,"stargazers_count":818,"open_issues_count":8,"forks_count":44,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T15:11:21.122Z","etag":null,"topics":["gpu","libvirt-hooks","linux","passthrough","qemu-kvm","vfio-pci","virtio"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QaidVoid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-09T16:50:25.000Z","updated_at":"2025-03-21T18:36:43.000Z","dependencies_parsed_at":"2024-11-05T20:44:53.194Z","dependency_job_id":null,"html_url":"https://github.com/QaidVoid/Complete-Single-GPU-Passthrough","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QaidVoid%2FComplete-Single-GPU-Passthrough","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QaidVoid%2FComplete-Single-GPU-Passthrough/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QaidVoid%2FComplete-Single-GPU-Passthrough/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QaidVoid%2FComplete-Single-GPU-Passthrough/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QaidVoid","download_url":"https://codeload.github.com/QaidVoid/Complete-Single-GPU-Passthrough/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590608,"owners_count":21129857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu","libvirt-hooks","linux","passthrough","qemu-kvm","vfio-pci","virtio"],"created_at":"2025-02-08T02:34:08.235Z","updated_at":"2025-04-12T15:38:36.560Z","avatar_url":"https://github.com/QaidVoid.png","language":"Shell","readme":"**Note**: I'm currently not using this, so my ability to provide support is limited. If you encounter issues or have questions about the setup, I recommend asking at [r/VFIO](https://reddit.com/r/vfio).\n\n## **Table Of Contents**\n* **[IOMMU Setup](#enable--verify-iommu)**\n* **[Installing Packages](#install-required-tools)**\n* **[Enabling Services](#enable-required-services)**\n* **[Guest Setup](#setup-guest-os)**\n* **[Attching PCI Devices](#attaching-pci-devices)**\n* **[Libvirt Hooks](#libvirt-hooks)**\n* **[Keyboard/Mouse Passthrough](#keyboardmouse-passthrough)**\n* **[Video Card Virtualisation Detection](#video-card-driver-virtualisation-detection)**\n* **[Audio Passthrough](#audio-passthrough)**\n* **[GPU vBIOS Patching](#vbios-patching)**\n\n### **Enable \u0026 Verify IOMMU**\n***BIOS Settings*** \\\nEnable ***Intel VT-d*** or ***AMD-Vi*** in BIOS settings. If these options are not present, it is likely that your hardware does not support IOMMU.\n\nDisable ***Resizable BAR Support*** in BIOS settings. \nCards that support Resizable BAR can cause problems with black screens following driver load if Resizable BAR is enabled in UEFI/BIOS. There doesn't seem to be a large performance penalty for disabling it, so turn it off for now until ReBAR support is available for KVM. \n\n***Set the kernel paramater depending on your CPU.***\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eGRUB\u003c/b\u003e\u003c/summary\u003e\n\n***Edit GRUB configuration***\n| /etc/default/grub |\n| ----- |\n| `GRUB_CMDLINE_LINUX_DEFAULT=\"... intel_iommu=on iommu=pt ...\"` |\n| OR |\n| `GRUB_CMDLINE_LINUX_DEFAULT=\"... amd_iommu=on iommu=pt ...\"` |\n\n***Generate grub.cfg***\n```sh\ngrub-mkconfig -o /boot/grub/grub.cfg\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eSystemd Boot\u003c/b\u003e\u003c/summary\u003e\n\n***Edit boot entry.***\n| /boot/loader/entries/*.conf |\n| ----- |\n| `options root=UUID=...intel_iommu=on iommu=pt..` |\n| OR |\n| `options root=UUID=...amd_iommu=on iommu=pt..` |\n\u003c/details\u003e\n\nReboot your system for the changes to take effect.\n\n***To verify IOMMU, run the following command.***\n```sh\ndmesg | grep IOMMU\n```\nThe output should include the message `Intel-IOMMU: enabled` for Intel CPUs or `AMD-Vi: AMD IOMMUv2 loaded and initialized` for AMD CPUs.\n\nTo view the IOMMU groups and attached devices, run the following script:\n```sh\n#!/bin/bash\nshopt -s nullglob\nfor g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do\n    echo \"IOMMU Group ${g##*/}:\"\n    for d in $g/devices/*; do\n        echo -e \"\\t$(lspci -nns ${d##*/})\"\n    done;\ndone;\n```\n\nWhen using passthrough, it is necessary to pass every device in the group that includes your GPU. \\\nYou can avoid having to pass everything by using [ACS override patch](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Bypassing_the_IOMMU_groups_(ACS_override_patch)).\n\n### **Install required tools**\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eGentoo Linux\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  emerge -av qemu virt-manager libvirt ebtables dnsmasq\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eArch Linux\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  pacman -S qemu libvirt edk2-ovmf virt-manager dnsmasq ebtables\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eFedora\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  dnf install @virtualization\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eUbuntu\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  apt install qemu-kvm qemu-utils libvirt-daemon-system libvirt-clients bridge-utils virt-manager ovmf\n  ```\n\u003c/details\u003e\n\n### **Enable required services**\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eSystemD\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  systemctl enable --now libvirtd\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eOpenRC\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  rc-update add libvirtd default\n  rc-service libvirtd start\n  ```\n\u003c/details\u003e\n\nSometimes, you might need to start default network manually.\n```sh\nvirsh net-start default\nvirsh net-autostart default\n```\n\n### **Setup Guest OS**\n***NOTE: You should replace win10 with your VM's name where applicable*** \\\nYou should add your user to ***libvirt*** group to be able to run VM without root. And, ***input*** and ***kvm*** group for passing input devices.\n```sh\nusermod -aG kvm,input,libvirt username\n```\n\nDownload [virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso) driver. \\\nLaunch ***virt-manager*** and create a new virtual machine. Select ***Customize before install*** on Final Step. \\\nIn ***Overview*** section, set ***Chipset*** to ***Q35***, and ***Firmware*** to ***UEFI*** \\\nIn ***CPUs*** section, set ***CPU model*** to ***host-passthrough***, and ***CPU Topology*** to whatever fits your system. \\\nFor ***SATA*** disk of VM, set ***Disk Bus*** to ***virtio***. \\\nIn ***NIC*** section, set ***Device Model*** to ***virtio*** \\\nAdd Hardware \u003e CDROM: virtio-win.iso \\\nNow, ***Begin Installation***. Windows can't detect the ***virtio disk***, so you need to ***Load Driver*** and select ***virtio-iso/amd64/win10*** when prompted. \\\nAfter successful installation of Windows, install virtio drivers from virtio CDROM. You can then remove virtio iso.\n\n### **Attaching PCI devices**\nRemove Channel Spice, Display Spice, Video QXL, Sound ich* and other unnecessary devices. \\\nNow, click on ***Add Hardware***, select ***PCI Devices*** and add the PCI Host devices for your GPU's VGA and HDMI Audio.\n\n### **Libvirt Hooks**\nLibvirt hooks automate the process of running specific tasks during VM state change. \\\nMore info at: [PassthroughPost](https://passthroughpo.st/simple-per-vm-libvirt-hooks-with-the-vfio-tools-hook-helper/)\n\n**Note**: Comment Unbind/rebind EFI framebuffer line from start and stop script if you're using AMD 6000 series cards (https://github.com/QaidVoid/Complete-Single-GPU-Passthrough/issues/9).\nAlso, move the line to unload AMD kernal module below detaching devices from host. These might also apply to older AMD cards.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eCreate Libvirt Hook\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  mkdir /etc/libvirt/hooks\n  touch /etc/libvirt/hooks/qemu\n  chmod +x /etc/libvirt/hooks/qemu\n  ```\n  \u003ctable\u003e\n  \u003ctr\u003e\n  \u003cth\u003e\n    /etc/libvirt/hooks/qemu\n  \u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n  \u003ctd\u003e\n\n  ```sh\n  #!/bin/bash\n\nGUEST_NAME=\"$1\"\nHOOK_NAME=\"$2\"\nSTATE_NAME=\"$3\"\nMISC=\"${@:4}\"\n\nBASEDIR=\"$(dirname $0)\"\n\nHOOKPATH=\"$BASEDIR/qemu.d/$GUEST_NAME/$HOOK_NAME/$STATE_NAME\"\nset -e # If a script exits with an error, we should as well.\n\nif [ -f \"$HOOKPATH\" ]; then\n  eval \\\"\"$HOOKPATH\"\\\" \"$@\"\nelif [ -d \"$HOOKPATH\" ]; then\n  while read file; do\n    eval \\\"\"$file\"\\\" \"$@\"\n  done \u003c\u003c\u003c \"$(find -L \"$HOOKPATH\" -maxdepth 1 -type f -executable -print;)\"\nfi\n  ```\n\n  \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/table\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eCreate Start Script\u003c/b\u003e\u003c/summary\u003e\n  \n  ```sh\n  mkdir -p /etc/libvirt/hooks/qemu.d/win10/prepare/begin\n  touch /etc/libvirt/hooks/qemu.d/win10/prepare/begin/start.sh\n  chmod +x /etc/libvirt/hooks/qemu.d/win10/prepare/begin/start.sh\n  ```\n**Note**: If you're on KDE Plasma (Wayland), you need to terminate user services alongside display-manager (https://github.com/QaidVoid/Complete-Single-GPU-Passthrough/issues/31).\n\n  \u003ctable\u003e\n  \u003ctr\u003e\n  \u003cth\u003e\n    /etc/libvirt/hooks/qemu.d/win10/prepare/begin/start.sh\n  \u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n  \u003ctd\u003e\n\n  ```sh\n#!/bin/bash\nset -x\n\n# Stop display manager\nsystemctl stop display-manager\n# systemctl --user -M YOUR_USERNAME@ stop plasma*\n\n# Unbind VTconsoles: might not be needed\necho 0 \u003e /sys/class/vtconsole/vtcon0/bind\necho 0 \u003e /sys/class/vtconsole/vtcon1/bind\n\n# Unbind EFI Framebuffer\necho efi-framebuffer.0 \u003e /sys/bus/platform/drivers/efi-framebuffer/unbind\n\n# Unload NVIDIA kernel modules\nmodprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia\n\n# Unload AMD kernel module\n# modprobe -r amdgpu\n\n# Detach GPU devices from host\n# Use your GPU and HDMI Audio PCI host device\nvirsh nodedev-detach pci_0000_01_00_0\nvirsh nodedev-detach pci_0000_01_00_1\n\n# Load vfio module\nmodprobe vfio-pci\n  ```\n\n  \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/table\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eCreate Stop Script\u003c/b\u003e\u003c/summary\u003e\n\n  ```sh\n  mkdir -p /etc/libvirt/hooks/qemu.d/win10/release/end\n  touch /etc/libvirt/hooks/qemu.d/win10/release/end/stop.sh\n  chmod +x /etc/libvirt/hooks/qemu.d/win10/release/end/stop.sh\n  ```\n  \u003ctable\u003e\n  \u003ctr\u003e\n  \u003cth\u003e\n    /etc/libvirt/hooks/qemu.d/win10/release/end/stop.sh\n  \u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n  \u003ctd\u003e\n\n  ```sh\n#!/bin/bash\nset -x\n\n# Attach GPU devices to host\n# Use your GPU and HDMI Audio PCI host device\nvirsh nodedev-reattach pci_0000_01_00_0\nvirsh nodedev-reattach pci_0000_01_00_1\n\n# Unload vfio module\nmodprobe -r vfio-pci\n\n# Load AMD kernel module\n#modprobe amdgpu\n\n# Rebind framebuffer to host\necho \"efi-framebuffer.0\" \u003e /sys/bus/platform/drivers/efi-framebuffer/bind\n\n# Load NVIDIA kernel modules\nmodprobe nvidia_drm\nmodprobe nvidia_modeset\nmodprobe nvidia_uvm\nmodprobe nvidia\n\n# Bind VTconsoles: might not be needed\necho 1 \u003e /sys/class/vtconsole/vtcon0/bind\necho 1 \u003e /sys/class/vtconsole/vtcon1/bind\n\n# Restart Display Manager\nsystemctl start display-manager\n```\n\n  \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/table\u003e\n\u003c/details\u003e\n\n### **Keyboard/Mouse Passthrough**\nIn order to be able to use keyboard/mouse in the VM, you can either passthrough the USB Host device or use Evdev passthrough.\n\nUsing USB Host Device is simple, \\\n***Add Hardware*** \u003e ***USB Host Device***, add your keyboard and mouse device.\n\nFor Evdev passthrough, follow these steps: \\\nModify libvirt configuration of your VM. \\\n**Note**: Save only after adding keyboard and mouse devices or the changes gets lost. \\\nChange first line to:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n\u003cdomain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'\u003e\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nFind your keyboard and mouse devices in ***/dev/input/by-id***. You'd generally use the devices ending with ***event-kbd*** and ***event-mouse***. And the devices in your configuration right before closing ***`\u003c/domain\u003e`*** tag. \\\nReplace ***MOUSE_NAME*** and ***KEYBOARD_NAME*** with your device id.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n  \u003cqemu:commandline\u003e\n    \u003cqemu:arg value='-object'/\u003e\n    \u003cqemu:arg value='input-linux,id=mouse1,evdev=/dev/input/by-id/MOUSE_NAME'/\u003e\n    \u003cqemu:arg value='-object'/\u003e\n    \u003cqemu:arg value='input-linux,id=kbd1,evdev=/dev/input/by-id/KEYBOARD_NAME,grab_all=on,repeat=on'/\u003e\n  \u003c/qemu:commandline\u003e\n\u003c/domain\u003e\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nYou need to include these devices in your qemu config.\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\n/etc/libvirt/qemu.conf\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```sh\n...\nuser = \"YOUR_USERNAME\"\ngroup = \"kvm\"\n...\ncgroup_device_acl = [\n    \"/dev/input/by-id/KEYBOARD_NAME\",\n    \"/dev/input/by-id/MOUSE_NAME\",\n    \"/dev/null\", \"/dev/full\", \"/dev/zero\",\n    \"/dev/random\", \"/dev/urandom\",\n    \"/dev/ptmx\", \"/dev/kvm\", \"/dev/kqemu\",\n    \"/dev/rtc\",\"/dev/hpet\", \"/dev/sev\"\n]\n...\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAlso, switch from PS/2 devices to virtio devices. Add the devices inside ***`\u003cdevices\u003e`*** block\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n\u003cdevices\u003e\n  ...\n  \u003cinput type='mouse' bus='virtio'/\u003e\n  \u003cinput type='keyboard' bus='virtio'/\u003e\n  ...\n\u003c/devices\u003e\n...\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### **Audio Passthrough**\nVM's audio can be routed to the host using ***Pipewire*** or ***Pulseaudio***. \\\nYou can also use [Scream](https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Passing_VM_audio_to_host_via_Scream) instead.\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003ePipewire\u003c/b\u003e\u003c/summary\u003e\n\nFrom [ArchWiki](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Passing_audio_from_virtual_machine_to_host_via_JACK_and_PipeWire)\n\nYou need to have Pipewire with JACK support.\n\n***Note***: You may use [Carla](https://kx.studio//Applications:Carla) to figure out appropriate input/output. Replace `1000` with your current user id.\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n  \u003cdevices\u003e\n    ...\n    \u003caudio id=\"1\" type=\"jack\"\u003e\n      \u003cinput clientName=\"win10\" connectPorts=\"your-input\"/\u003e\n      \u003coutput clientName=\"win10\" connectPorts=\"your-output\"/\u003e\n    \u003c/audio\u003e\n  \u003c/devices\u003e\n  \u003cqemu:commandline\u003e\n    \u003cqemu:env name=\"PIPEWIRE_RUNTIME_DIR\" value=\"/run/user/1000\"/\u003e\n    \u003cqemu:env name=\"PIPEWIRE_LATENCY\" value=\"512/48000\"/\u003e\n  \u003c/qemu:commandline\u003e\n\u003c/domain\u003e\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003ePulseaudio\u003c/b\u003e\u003c/summary\u003e\n\n***Note***: Replace `1000` with your current user id.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n  \u003cqemu:commandline\u003e\n    ...\n    \u003cqemu:arg value=\"-device\"/\u003e\n    \u003cqemu:arg value=\"ich9-intel-hda,bus=pcie.0,addr=0x1b\"/\u003e\n    \u003cqemu:arg value=\"-device\"/\u003e\n    \u003cqemu:arg value=\"hda-micro,audiodev=hda\"/\u003e\n    \u003cqemu:arg value=\"-audiodev\"/\u003e\n    \u003cqemu:arg value=\"pa,id=hda,server=/run/user/1000/pulse/native\"/\u003e\n  \u003c/qemu:commandline\u003e\n\u003c/domain\u003e\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\u003c/details\u003e\n\n\n### **Video card driver virtualisation detection**\nVideo Card drivers refuse to run in Virtual Machine, so you need to spoof Hyper-V Vendor ID.\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n\u003cfeatures\u003e\n  ...\n  \u003chyperv\u003e\n    ...\n    \u003cvendor_id state='on' value='whatever'/\u003e\n    ...\n  \u003c/hyperv\u003e\n  ...\n\u003c/features\u003e\n...\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nNVIDIA guest drivers also require hiding the KVM CPU leaf:\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\nvirsh edit win10\n\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n...\n\u003cfeatures\u003e\n  ...\n  \u003ckvm\u003e\n    \u003chidden state='on'/\u003e\n  \u003c/kvm\u003e\n  ...\n\u003c/features\u003e\n...\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### **vBIOS Patching**\n***NOTE: You are only making changes on dumped ROM file. Your hardware is safe.*** \\\nWhile most of the GPU can be passed with stock vBIOS, some GPU requires vBIOS patching to passthrough. \\\nIn order to patch vBIOS, you need to first dump the GPU vBIOS from your system. \\\nIf you have Windows installed, you can use [GPU-Z](https://www.techpowerup.com/gpuz) to dump vBIOS. \\\nTo dump vBIOS on Linux, you can use following command (replace PCI id with yours):\n```sh\necho 1 \u003e /sys/bus/pci/devices/0000:01:00.0/rom\ncat /sys/bus/pci/devices/0000:01:00.0/rom \u003e path/to/dump/vbios.rom\necho 0 \u003e /sys/bus/pci/devices/0000:01:00.0/rom\n```\nIf you're not in root shell, you should use the above commands with sudo as:\n```sh\necho 1 | sudo tee /sys/bus/pci/devices/0000:01:00.0/rom\nsudo cat /sys/bus/pci/devices/0000:01:00.0/rom \u003e path/to/dump/vbios.rom\necho 0 | sudo tee /sys/bus/pci/devices/0000:01:00.0/rom\n```\nTo patch vBIOS, you need to use Hex Editor (eg., [Okteta](https://utils.kde.org/projects/okteta)) and trim unnecessary header. \\\nFor NVIDIA GPU, using hex editor, search string “VIDEO”, and remove everything before HEX value 55. \\\nI'm not sure about AMD, but the process should be similar.\n\nTo use patched vBIOS, edit VM's configuration to include patched vBIOS inside ***hostdev*** block of VGA\n\n  \u003ctable\u003e\n  \u003ctr\u003e\n  \u003cth\u003e\n  virsh edit win10\n  \u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n  \u003ctd\u003e\n\n  ```xml\n  ...\n  \u003chostdev mode='subsystem' type='pci' managed='yes'\u003e\n    \u003csource\u003e\n      ...\n    \u003c/source\u003e\n    \u003crom file='/home/me/patched.rom'/\u003e\n    ...\n  \u003c/hostdev\u003e\n  ...\n  ```\n\n  \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/table\u003e\n\n### **See Also**\n\u003e [Single GPU Passthrough Troubleshooting](https://docs.google.com/document/d/17Wh9_5HPqAx8HHk-p2bGlR0E-65TplkG18jvM98I7V8)\u003cbr/\u003e\n\u003e [Single GPU Passthrough by joeknock90](https://github.com/joeknock90/Single-GPU-Passthrough)\u003cbr/\u003e\n\u003e [Single GPU Passthrough by YuriAlek](https://gitlab.com/YuriAlek/vfio)\u003cbr/\u003e\n\u003e [Single GPU Passthrough by wabulu](https://github.com/wabulu/Single-GPU-passthrough-amd-nvidia)\u003cbr/\u003e\n\u003e [ArchLinux PCI Passthrough](https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF)\u003cbr/\u003e\n\u003e [Gentoo GPU Passthrough](https://wiki.gentoo.org/wiki/GPU_passthrough_with_libvirt_qemu_kvm)\u003cbr/\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaidvoid%2Fcomplete-single-gpu-passthrough","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqaidvoid%2Fcomplete-single-gpu-passthrough","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaidvoid%2Fcomplete-single-gpu-passthrough/lists"}