Hardware pass-through

This may come off as unhinged ramblings of a mad woman, but I've spent more of my life than I want to admit getting this to work on consumer hardware, so I'll write it up here. The general thing conclusion I have come to is...maybe don't do this on consumer hardware if you're not willing to fight the machine a bit. Personally...I find that fun.

How this is supposed to work is you pass in a device not being used by anyone\anything so it's being used by any software applications. This may require blacklisting drivers on the device. That part is fairly simple, you just get the driver ID and verify it blacklisted after a reboot with lspci -k. You also don't have to do this from boot as you programmatically cut any services using the device (ex audio daemon off for a sound card) at any point so if you want to say drop into a VM for a game jam so all your dev tools are there and then drop back into your host you can do that, but this is very brittle. My understanding is that the respective hardware needs to properly respond to a reset command which isn't really standardized fully. This is fairly esoteric, but you can dabble with /sys/bus/pci/devices/ on /remove and /rescan to try and force a reset, but it's not guaranteed to work.

It gets even more flaky on consumer hardware. You may have to disable power management and resizable bar in some circumstances. This is because it can introduce transient errors on the pass-through if the implementation isn't correct (for consumer hardware...it probably is not) and the other reason based upon my understanding is the dynamic memory sizing on the card can cause issues with the virtualization process due to being read-only in the kernel. Unless this changes its best to just disable it for now.

You will need well setup IOMMU groups so that you can cleanly pass in only parts of your hardware. You can get a pretty decent idea of this by reviewing the motherboard block diagram before purchasing the board. What you are ideally looking for is a clean breakdown on the PCIe lanes used...what are your direct lanes, what is shared with the lanes for this device, etc. Or finding someone who has confirmed VFIO works (as this is what many people will refer to this as in gaming spaces). And yes it is possible at times to accidentally pass in your GPU without the corresponding audio device on the PCIe, this applies for any device that has multiple PCIe devices exposed, but that is just what I have bitten by in the past.

Even with all this you may find certain slots on the motherboard just cannot do a hardware pass-through (or the vendor breaks it in a bios update...maybe refrain from installing that without a good reason), in general the top PCIe tends to work which for VFIO and running a Windows VM is likely all you need, but this is something to be mindful of if you intend to pass through multiple PCIe cards.

And sometimes you get really strange gremlins. For example this can happen on consumer motherboards (and some hardware in industrial applications as well) you will have situations where the hardware functions differently if you perform a shutdown vs a reboot. This is likely because the device was not fully initialized when you did a reboot vs a shutdown. On a host system you might not notice this at all, but it can be enough to break passing the card through into a VM because the device is just not initialized correctly. If this happens...you might be able to fix it with a bios update or by only doing a cold boot (from shutdown only) for your virtualization workloads that need hardware pass-through.

On the note of USB. For QEMU this is implemented largely in user space meaning interrupts are actually very computationally expensive so if you want to have reasonable performance with I\O sensitive devices connected via USB a PCIe card will likely give you better results. You'll also get things like hot plugging without needing to adjust a virtual machine configuration.

Do I recommend you do this...well...if you want to run virtual machines, and you have a few consumer systems lying around it will likely keep you busy for a bit. I do it out of a sense of...this sounds like a fun challenge, and it's just an added bonus that the hardware is cheaper overall. I do not recommend this to a company unless it is with hardware that is designed for this (ex not a gaming PC motherboard).

Website Stats:

Website Build Version: 2026/07/24 07:53:18 PM (+00:00)

Last Website Update: c1f020f

Site Generator: Serpent Page Generator created by Lucia Smith