This series implements PCI pass-through using VFIO in kvmtool. We introduce a new parameter to lkvm run, --vfio-group, that takes an IOMMU group number as argument, and passes all devices in the group to the guest. This implementation is missing quite a few features. Most notably: * Apart from MSI/MSI-X, all capabilities are hidden. For instance, we don't support PCIe, which would require ECAM (we only do CAM). We also wouldn't support assigning virtio 1.0 devices, since they rely on the vendor-specific cap. * IOMMU reserved regions might clash with the hardcoded guest address space. Fixing this would require a complete rewrite of address space allocation. We would initially register reserved regions, then subsystems would register their addressing capabilities (MMIO, config space, RAM), and finally devices would request chunks of memory as needed. Memory regions would be presented to the guest using DT (ARM & PPC), kernel parameters (mips) or e820 map (x86). For now kvmtool will simply abort initialization when there is an overlap between reserved regions and guest memory map. Users can change the kvmtool memory map manually to work around it, or simply comment out the check if the guest is unlikely to trigger DMA to that particular region. * Non-ARM architectures are only build-tested. I don't have any hardware for x86 (though I might try Qemu when I find time). I also lack the knowledge for using VFIO on PowerPC. Since last version [1], I had to rewrite the MSI-X code, which didn't work with virtio legacy devices. I also refactored vfio.c to prepare for vfio-platform support, which I'll send later. Detailed changes since last version follow. You can pull the patches from [2]. Thanks, Jean Patch 3: * fixed deassign IRQFD Patch 6: * Split vfio.c into vfio/core.c and vfio/pci.c, preparing for platform support. * Cleanup on exit. * Fixed multifunction devices (hopefully). * Added dev_* printf helpers. * Fixed powerpc and mips build Patches 7-8: * Made all MSI routing setup lazy. We now closely follow virtual and physical state of MSI capabilities and vectors. * Added handling of mask/unmask MSI vector. * Merged MSI and MSI-X code where possible. * Added rlimit check, to reserve enough fds for MSIs upfront. [1] http://www.spinics.net/lists/kvm/msg147624.html [2] git://linux-arm.org/kvmtool-jpb.git vfio/v2 Jean-Philippe Brucker (10): pci: add config operations callbacks on the PCI header pci: allow to specify IRQ type for PCI devices irq: add irqfd helpers Extend memory bank API with memory types pci: add capability helpers Add PCI device passthrough using VFIO vfio-pci: add MSI-X support vfio-pci: add MSI support Introduce reserved memory regions vfio: check reserved regions before mapping DMA Makefile | 2 + arm/gic.c | 74 ++- arm/include/arm-common/gic.h | 6 + arm/kvm.c | 2 +- arm/pci.c | 4 +- builtin-run.c | 5 + hw/pci-shmem.c | 12 +- hw/vesa.c | 2 +- include/kvm/irq.h | 17 + include/kvm/kvm-config.h | 3 + include/kvm/kvm.h | 54 +- include/kvm/pci.h | 116 ++++- include/kvm/vfio.h | 111 +++++ irq.c | 24 + kvm.c | 99 +++- mips/kvm.c | 6 +- pci.c | 105 ++-- powerpc/kvm.c | 2 +- vfio/core.c | 430 ++++++++++++++++ vfio/pci.c | 1108 ++++++++++++++++++++++++++++++++++++++++++ virtio/net.c | 9 +- virtio/scsi.c | 10 +- x86/kvm.c | 6 +- 23 files changed, 2084 insertions(+), 123 deletions(-) create mode 100644 include/kvm/vfio.h create mode 100644 vfio/core.c create mode 100644 vfio/pci.c -- 2.13.1