1. 07 Apr, 2015 3 commits
    • Alex Williamson's avatar
      vfio-pci: Allow PCI IDs to be specified as module options · 80c7e8cc
      Alex Williamson authored
      This copies the same support from pci-stub for exactly the same
      purpose, enabling a set of PCI IDs to be automatically added to the
      driver's dynamic ID table at module load time.  The code here is
      pretty simple and both vfio-pci and pci-stub are fairly unique in
      being meta drivers, capable of attaching to any device, so there's no
      attempt made to generalize the code into pci-core.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    • Alex Williamson's avatar
      vfio-pci: Add VGA arbiter client · ecaa1f6a
      Alex Williamson authored
      If VFIO VGA access is disabled for the user, either by CONFIG option
      or module parameter, we can often opt-out of VGA arbitration.  We can
      do this when PCI bridge control of VGA routing is possible.  This
      means that we must have a parent bridge and there must only be a
      single VGA device below that bridge.  Fortunately this is the typical
      case for discrete GPUs.
      Doing this allows us to minimize the impact of additional GPUs, in
      terms of VGA arbitration, when they are only used via vfio-pci for
      non-VGA applications.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    • Alex Williamson's avatar
      vfio-pci: Add module option to disable VGA region access · 88c0dead
      Alex Williamson authored
      Add a module option so that we don't require a CONFIG change and
      kernel rebuild to disable VGA support.  Not only can VGA support be
      troublesome in itself, but by disabling it we can reduce the impact
      to host devices by doing a VGA arbitration opt-out.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  2. 17 Mar, 2015 1 commit
    • Alex Williamson's avatar
      vfio: Split virqfd into a separate module for vfio bus drivers · 71be3423
      Alex Williamson authored
      An unintended consequence of commit 42ac9bd1
       ("vfio: initialize
      the virqfd workqueue in VFIO generic code") is that the vfio module
      is renamed to vfio_core so that it can include both vfio and virqfd.
      That's a user visible change that may break module loading scritps
      and it imposes eventfd support as a dependency on the core vfio code,
      which it's really not.  virqfd is intended to be provided as a service
      to vfio bus drivers, so instead of wrapping it into vfio.ko, we can
      make it a stand-alone module toggled by vfio bus drivers.  This has
      the additional benefit of removing initialization and exit from the
      core vfio code.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  3. 16 Mar, 2015 6 commits
  4. 12 Mar, 2015 1 commit
  5. 10 Feb, 2015 2 commits
  6. 07 Jan, 2015 1 commit
  7. 23 Nov, 2014 1 commit
  8. 07 Nov, 2014 1 commit
  9. 29 Sep, 2014 2 commits
    • Alex Williamson's avatar
      vfio-pci: Fix remove path locking · 93899a67
      Alex Williamson authored
      Locking both the remove() and release() path results in a deadlock
      that should have been obvious.  To fix this we can get and hold the
      vfio_device reference as we evaluate whether to do a bus/slot reset.
      This will automatically block any remove() calls, allowing us to
      remove the explict lock.  Fixes 61d79256
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: stable@vger.kernel.org	[3.17]
    • Gavin Shan's avatar
      vfio/pci: Restore MSIx message prior to enabling · b8f02af0
      Gavin Shan authored
      The MSIx vector table lives in device memory, which may be cleared as
      part of a backdoor device reset. This is the case on the IBM IPR HBA
      when the BIST is run on the device. When assigned to a QEMU guest,
      the guest driver does a pci_save_state(), issues a BIST, then does a
      pci_restore_state(). The BIST clears the MSIx vector table, but due
      to the way interrupts are configured the pci_restore_state() does not
      restore the vector table as expected. Eventually this results in an
      EEH error on Power platforms when the device attempts to signal an
      interrupt with the zero'd table entry.
      Fix the problem by restoring the host cached MSI message prior to
      enabling each vector.
      Reported-by: default avatarWen Xiong <wenxiong@linux.vnet.ibm.com>
      Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  10. 25 Sep, 2014 1 commit
  11. 08 Aug, 2014 1 commit
  12. 07 Aug, 2014 3 commits
    • Alex Williamson's avatar
      vfio-pci: Attempt bus/slot reset on release · bc4fba77
      Alex Williamson authored
      Each time a device is released, mark whether a local reset was
      successful or whether a bus/slot reset is needed.  If a reset is
      needed and all of the affected devices are bound to vfio-pci and
      unused, allow the reset.  This is most useful when the userspace
      driver is killed and releases all the devices in an unclean state,
      such as when a QEMU VM quits.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    • Alex Williamson's avatar
      vfio-pci: Use mutex around open, release, and remove · 61d79256
      Alex Williamson authored
      Serializing open/release allows us to fix a refcnt error if we fail
      to enable the device and lets us prevent devices from being unbound
      or opened, giving us an opportunity to do bus resets on release.  No
      restriction added to serialize binding devices to vfio-pci while the
      mutex is held though.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    • Alex Williamson's avatar
      vfio-pci: Release devices with BusMaster disabled · 9c22e660
      Alex Williamson authored
      Our current open/release path looks like this:
      pci_enable_device() doesn't modify PCI_COMMAND_MASTER, so if a device
      comes to us with it enabled, it persists through the open and gets
      stored as part of the device saved state.  We then restore that saved
      state when released, which can allow the device to attempt to continue
      to do DMA.  When the group is disconnected from the domain, this will
      get caught by the IOMMU, but if there are other devices in the group,
      the device may continue running and interfere with the user.  Even in
      the former case, IOMMUs don't necessarily behave well and a stream of
      blocked DMA can result in unpleasant behavior on the host.
      Explicitly disable Bus Master as we're enabling the device and
      slightly re-work release to make sure that pci_disable_device() is
      the last thing that touches the device.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  13. 04 Aug, 2014 1 commit
  14. 30 May, 2014 3 commits
  15. 14 Feb, 2014 1 commit
  16. 15 Jan, 2014 1 commit
    • Alex Williamson's avatar
      vfio-pci: Use pci "try" reset interface · 890ed578
      Alex Williamson authored
      PCI resets will attempt to take the device_lock for any device to be
      reset.  This is a problem if that lock is already held, for instance
      in the device remove path.  It's not sufficient to simply kill the
      user process or skip the reset if called after .remove as a race could
      result in the same deadlock.  Instead, we handle all resets as "best
      effort" using the PCI "try" reset interfaces.  This prevents the user
      from being able to induce a deadlock by triggering a reset.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
  17. 14 Jan, 2014 1 commit
    • Alex Williamson's avatar
      vfio-pci: Don't use device_lock around AER interrupt setup · 3be3a074
      Alex Williamson authored
      device_lock is much too prone to lockups.  For instance if we have a
      pending .remove then device_lock is already held.  If userspace
      attempts to modify AER signaling after that point, a deadlock occurs.
      eventfd setup/teardown is already protected in vfio with the igate
      mutex.  AER is not a high performance interrupt, so we can also use
      the same mutex to protect signaling versus setup races.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  18. 17 Dec, 2013 1 commit
  19. 04 Sep, 2013 2 commits
    • Alex Williamson's avatar
      vfio-pci: PCI hot reset interface · 8b27ee60
      Alex Williamson authored
      The current VFIO_DEVICE_RESET interface only maps to PCI use cases
      where we can isolate the reset to the individual PCI function.  This
      means the device must support FLR (PCIe or AF), PM reset on D3hot->D0
      transition, device specific reset, or be a singleton device on a bus
      for a secondary bus reset.  FLR does not have widespread support,
      PM reset is not very reliable, and bus topology is dictated by the
      system and device design.  We need to provide a means for a user to
      induce a bus reset in cases where the existing mechanisms are not
      available or not reliable.
      This device specific extension to VFIO provides the user with this
      ability.  Two new ioctls are introduced:
      The first provides the user with information about the extent of
      devices affected by a hot reset.  This is essentially a list of
      devices and the IOMMU groups they belong to.  The user may then
      initiate a hot reset by calling the second ioctl.  We must be
      careful that the user has ownership of all the affected devices
      found via the first ioctl, so the second ioctl takes a list of file
      descriptors for the VFIO groups affected by the reset.  Each group
      must have IOMMU protection established for the ioctl to succeed.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    • Alex Williamson's avatar
      vfio-pci: Test for extended config space · 17638db1
      Alex Williamson authored
      Having PCIe/PCI-X capability isn't enough to assume that there are
      extended capabilities.  Both specs define that the first capability
      header is all zero if there are no extended capabilities.  Testing
      for this avoids an erroneous message about hiding capability 0x0 at
      offset 0x100.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  20. 28 Aug, 2013 1 commit
    • Alex Williamson's avatar
      vfio-pci: Use fdget() rather than eventfd_fget() · 20e77457
      Alex Williamson authored
      eventfd_fget() tests to see whether the file is an eventfd file, which
      we then immediately pass to eventfd_ctx_fileget(), which again tests
      whether the file is an eventfd file.  Simplify slightly by using
      fdget() so that we only test that we're looking at an eventfd once.
      fget() could also be used, but fdget() makes use of fget_light() for
      another slight optimization.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  21. 24 Jul, 2013 1 commit
    • Alex Williamson's avatar
      vfio-pci: Avoid deadlock on remove · d24cdbfd
      Alex Williamson authored
      If an attempt is made to unbind a device from vfio-pci while that
      device is in use, the request is blocked until the device becomes
      unused.  Unfortunately, that unbind path still grabs the device_lock,
      which certain things like __pci_reset_function() also want to take.
      This means we need to try to acquire the locks ourselves and use the
      pre-locked version, __pci_reset_function_locked().
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
  22. 29 Jun, 2013 1 commit
  23. 24 Apr, 2013 2 commits
  24. 15 Apr, 2013 1 commit
  25. 01 Apr, 2013 1 commit