Skip to content
  • Jean-Philippe Brucker's avatar
    Add PCI device passthrough using VFIO · 6078a454
    Jean-Philippe Brucker authored
    
    
    Assigning devices using VFIO allows the guest to have direct access to the
    device, whilst filtering accesses to sensitive areas by trapping config
    space accesses and mapping DMA with an IOMMU.
    
    This patch adds a new option to lkvm run: --vfio-pci=<BDF>. Before
    assigning a device to a VM, some preparation is required. As described in
    Linux Documentation/vfio.txt, the device driver needs to be changed to
    vfio-pci:
    
      $ dev=0000:00:00.0
    
      $ echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
      $ echo vfio-pci > /sys/bus/pci/devices/$dev/driver_override
      $ echo $dev > /sys/bus/pci/drivers_probe
    
    Adding --vfio-pci=$dev to lkvm-run will pass the device to the guest.
    Multiple devices can be passed to the guest by adding more --vfio-pci
    parameters.
    
    This patch only implements PCI with INTx. MSI-X routing will be added in a
    subsequent patch, and at some point we might add support for passing
    platform devices to guests.
    
    Reviewed-by: default avatarPunit Agrawal <punit.agrawal@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
    Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    6078a454