VFIO 2.0 Episode 2 Reborn: Global Offensive Infinite U Vita
To pass through a generic PCI device into the VM, we need to take care of:
IOMMU grouping
Simple to check in sysfs as soon as iommu is enabled. Ignore PCI bridges (maybe figure out why?) but make sure we're passing everything else, no exceptions.
Resetting
Device supports resetting: Easy. Just run vfio-bind on startup and bind back to the old driver on exit.
Device is a GPU (and thus doesn't support resetting): Need to bind in initrd, before any other driver can mess with the device. Rest should be fine?
Device is not a GPU but still doesn't support resetting: In theory there is no reason why this shouldn't "just work (tm)" if we bind on boot, like GPU (since GPU doesn't support resetting either and that works just fine). Arch wiki however says that you're fucked in this case and the qemu hangs forever on shutdown. TODO: Figure out if they're right. In any case, blacklisting builtin drivers (like xhci) is hard.
Bind the device
The easy part: Look at what devices we have and translate that into qemu parameters.
Simplify the world
Just learn more about vfio-pci and device binding in general - we might be able to work without kernel parameters or without these weird config changes. The tool as it is today only replicates a setup that worked for me once, it does not try very hard at being robust or elegant.
vfio-bind
New tool: suid binary that rebinds all resettable PCI devices from the config to vfio-pci via the simple sysfs trick (modern version):
Things are simple, really.
VFIO 2.0 Episode 2 Reborn: Global Offensive Infinite U Vita
To pass through a generic PCI device into the VM, we need to take care of:
IOMMU grouping
Simple to check in sysfs as soon as iommu is enabled. Ignore PCI bridges (maybe figure out why?) but make sure we're passing everything else, no exceptions.
Resetting
Bind the device
The easy part: Look at what devices we have and translate that into qemu parameters.
Simplify the world
Just learn more about vfio-pci and device binding in general - we might be able to work without kernel parameters or without these weird config changes. The tool as it is today only replicates a setup that worked for me once, it does not try very hard at being robust or elegant.
vfio-bind
New tool: suid binary that rebinds all resettable PCI devices from the config to vfio-pci via the simple sysfs trick (modern version):