1. 19 May, 2016 1 commit
    • Alexey Kardashevskiy's avatar
      vfio_pci: Test for extended capabilities if config space > 256 bytes · f7055280
      Alexey Kardashevskiy authored
      PCI-Express spec says that reading 4 bytes at offset 100h should return
      zero if there is no extended capability so VFIO reads this dword to
      know if there are extended capabilities.
      
      However it is not always possible to access the extended space so
      generic PCI code in pci_cfg_space_size_ext() checks if
      pci_read_config_dword() can read beyond 100h and if the check fails,
      it sets the config space size to 100h.
      
      VFIO does its own extended capabilities check by reading at offset 100h
      which may produce 0xffffffff which VFIO treats as the extended config
      space presense and calls vfio_ecap_init() which fails to parse
      capabilities (which is expected) but right before the exit, it writes
      zero at offset 100h which is beyond the buffer allocated for
      vdev->vconfig (which is 256 bytes) which leads to random memory
      corruption.
      
      This makes VFIO only check for the extended capabilities if
      the discovered config size is more than 256 bytes.
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      f7055280
  2. 28 Apr, 2016 3 commits
    • Alexey Kardashevskiy's avatar
      vfio_iommu_spapr_tce: Remove unneeded iommu_group_get_iommudata · 5ed4aba1
      Alexey Kardashevskiy authored
      This removes iommu_group_get_iommudata() as the result is never used.
      As this is a minor cleanup, no change in behavior is expected.
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      5ed4aba1
    • Alex Williamson's avatar
      vfio/pci: Add test for BAR restore · dc928109
      Alex Williamson authored
      If a device is reset without the memory or i/o bits enabled in the
      command register we may not detect it, potentially leaving the device
      without valid BAR programming.  Add an additional test to check the
      BARs on each write to the command register.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      dc928109
    • Alex Williamson's avatar
      vfio/pci: Hide broken INTx support from user · 45074405
      Alex Williamson authored
      INTx masking has two components, the first is that we need the ability
      to prevent the device from continuing to assert INTx.  This is
      provided via the DisINTx bit in the command register and is the only
      thing we can really probe for when testing if INTx masking is
      supported.  The second component is that the device needs to indicate
      if INTx is asserted via the interrupt status bit in the device status
      register.  With these two features we can generically determine if one
      of the devices we own is asserting INTx, signal the user, and mask the
      interrupt while the user services the device.
      
      Generally if one or both of these components is broken we resort to
      APIC level interrupt masking, which requires an exclusive interrupt
      since we have no way to determine the source of the interrupt in a
      shared configuration.  This often makes it difficult or impossible to
      configure the system for userspace use of the device, for an interrupt
      mode that the user may not need.
      
      One possible configuration of broken INTx masking is that the DisINTx
      support is fully functional, but the interrupt status bit never
      signals interrupt assertion.  In this case we do have the ability to
      prevent the device from asserting INTx, but lack the ability to
      identify the interrupt source.  For this case we can simply pretend
      that the device lacks INTx support entirely, keeping DisINTx set on
      the physical device, virtualizing this bit for the user, and
      virtualizing the interrupt pin register to indicate no INTx support.
      We already support virtualization of the DisINTx bit and already
      virtualize the interrupt pin for platforms without INTx support.  By
      tying these components together, setting DisINTx on open and reset,
      and identifying devices broken in this particular way, we can provide
      support for them w/o the handicap of APIC level INTx masking.
      
      Intel i40e (XL710/X710) 10/20/40GbE NICs have been identified as being
      broken in this specific way.  We leave the vfio-pci.nointxmask option
      as a mechanism to bypass this support, enabling INTx on the device
      with all the requirements of APIC level masking.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: John Ronciak <john.ronciak@intel.com>
      Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
      45074405
  3. 24 Apr, 2016 2 commits
  4. 23 Apr, 2016 10 commits
  5. 22 Apr, 2016 24 commits