kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 kvmtool 00/10] Add PCI passthrough support with VFIO
@ 2017-06-22 17:05 Jean-Philippe Brucker
  2017-06-22 17:05 ` [PATCH v2 kvmtool 01/10] pci: add config operations callbacks on the PCI header Jean-Philippe Brucker
                   ` (9 more replies)
  0 siblings, 10 replies; 24+ messages in thread
From: Jean-Philippe Brucker @ 2017-06-22 17:05 UTC (permalink / raw)
  To: kvm; +Cc: will.deacon, robin.murphy, lorenzo.pieralisi, marc.zyngier

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-08-22 11:25 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 17:05 [PATCH v2 kvmtool 00/10] Add PCI passthrough support with VFIO Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 01/10] pci: add config operations callbacks on the PCI header Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 02/10] pci: allow to specify IRQ type for PCI devices Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 03/10] irq: add irqfd helpers Jean-Philippe Brucker
2017-07-31 17:55   ` Punit Agrawal
2017-08-02 15:17     ` Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 04/10] Extend memory bank API with memory types Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 05/10] pci: add capability helpers Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 06/10] Add PCI device passthrough using VFIO Jean-Philippe Brucker
2017-07-31 17:52   ` Punit Agrawal
2017-08-02 15:17     ` Jean-Philippe Brucker
2017-08-03  9:36       ` Punit Agrawal
2017-08-03 11:24         ` Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 07/10] vfio-pci: add MSI-X support Jean-Philippe Brucker
2017-07-31 17:49   ` Punit Agrawal
2017-08-01 16:04     ` Punit Agrawal
2017-08-02 15:18       ` Jean-Philippe Brucker
2017-08-03 10:25         ` Punit Agrawal
2017-08-03 10:53           ` Jean-Philippe Brucker
2017-08-18 17:42   ` Jean-Philippe Brucker
2017-08-22 11:25     ` Punit Agrawal
2017-06-22 17:05 ` [PATCH v2 kvmtool 08/10] vfio-pci: add MSI support Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 09/10] Introduce reserved memory regions Jean-Philippe Brucker
2017-06-22 17:05 ` [PATCH v2 kvmtool 10/10] vfio: check reserved regions before mapping DMA Jean-Philippe Brucker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).