1. 24 9月, 2015 1 次提交
    • A
      vfio/pci: Cleanup RTL8168 quirk and tracing · d451008e
      Alex Williamson 提交于
      There's quite a bit of cleanup that can be done to the RTL8168 quirk,
      as well as the tracing to prevent a spew of uninteresting accesses
      for anything else the driver might choose to use the window registers
      for besides the MSI-X table.  There should be no functional change,
      but it's now possible to get compact and useful traces by enabling
      vfio_rtl8168_quirk*, ex:
      
      vfio_rtl8168_quirk_write 0000:04:00.0 [address]: 0x1f000
      vfio_rtl8168_quirk_read 0000:04:00.0 [address]: 0x8001f000
      vfio_rtl8168_quirk_read 0000:04:00.0 [data]: 0xfee0100c
      vfio_rtl8168_quirk_write 0000:04:00.0 [address]: 0x1f004
      vfio_rtl8168_quirk_read 0000:04:00.0 [address]: 0x8001f004
      vfio_rtl8168_quirk_read 0000:04:00.0 [data]: 0x0
      vfio_rtl8168_quirk_write 0000:04:00.0 [address]: 0x1f008
      vfio_rtl8168_quirk_read 0000:04:00.0 [address]: 0x8001f008
      vfio_rtl8168_quirk_read 0000:04:00.0 [data]: 0x49b1
      vfio_rtl8168_quirk_write 0000:04:00.0 [address]: 0x1f00c
      vfio_rtl8168_quirk_read 0000:04:00.0 [address]: 0x8001f00c
      vfio_rtl8168_quirk_read 0000:04:00.0 [data]: 0x0
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      d451008e
  2. 11 9月, 2015 2 次提交
  3. 23 7月, 2015 2 次提交
    • A
      vfio/pci: Fix bootindex · 759b484c
      Alex Williamson 提交于
      bootindex was incorrectly changed to a device Property during the
      platform code split, resulting in it no longer working.  Remove it.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: qemu-stable@nongnu.org # v2.3+
      759b484c
    • A
      vfio/pci: Fix RTL8168 NIC quirks · 69970fce
      Alex Williamson 提交于
      The RTL8168 quirk correctly describes using bit 31 as a signal to
      mark a latch/completion, but the code mistakenly uses bit 28.  This
      causes the Realtek driver to spin on this register for quite a while,
      20k cycles on Windows 7 v7.092 driver.  Then it gets frustrated and
      tries to set the bit itself and spins for another 20k cycles.  For
      some this still results in a working driver, for others not.  About
      the only thing the code really does in its current form is protect
      the guest from sneaking in writes to the real hardware MSI-X table.
      The fix is obviously to use bit 31 as we document that we should.
      
      The other problem doesn't seem to affect current drivers as nobody
      seems to use these window registers for writes to the MSI-X table, but
      we need to use the stored data when a write is triggered, not the
      value of the current write, which only provides the offset.
      
      Note that only the Windows drivers from Realtek seem to use these
      registers, the Microsoft drivers provided with Windows 8.1 do not
      access them, nor do Linux in-kernel drivers.
      
      Link: https://bugs.launchpad.net/qemu/+bug/1384892Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: qemu-stable@nongnu.org # v2.1+
      69970fce
  4. 07 7月, 2015 4 次提交
  5. 29 4月, 2015 3 次提交
    • A
      vfio-pci: Reset workaround for AMD Bonaire and Hawaii GPUs · 5655f931
      Alex Williamson 提交于
      Somehow these GPUs manage not to respond to a PCI bus reset, removing
      our primary mechanism for resetting graphics cards.  The result is
      that these devices typically work well for a single VM boot.  If the
      VM is rebooted or restarted, the guest driver is not able to init the
      card from the dirty state, resulting in a blue screen for Windows
      guests.
      
      The workaround is to use a device specific reset.  This is not 100%
      reliable though since it depends on the incoming state of the device,
      but it substantially improves the usability of these devices in a VM.
      
      Credit to Alex Deucher <alexander.deucher@amd.com> for his guidance.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      5655f931
    • A
      vfio-pci: Fix error path sign · c6d231e2
      Alex Williamson 提交于
      This is an impossible error path due to the fact that we're reading a
      kernel provided, rather than user provided link, which will certainly
      always fit in PATH_MAX.  Currently it returns a fixed 26 char path
      plus %d group number, which typically maxes out at double digits.
      However, the caller of the initfn certainly expects a less-than zero
      return value on error, not just a non-zero value.  Therefore we
      should correct the sign here.
      Reported-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      c6d231e2
    • A
      vfio-pci: Further fix BAR size overflow · 07ceaf98
      Alex Williamson 提交于
      In an analysis by Laszlo, the resulting type of our calculation for
      the end of the MSI-X table, and thus the start of memory after the
      table, is uint32_t.  We're therefore not correctly preventing the
      corner case overflow that we intended to fix here where a BAR >=4G
      could place the MSI-X table to end exactly at the 4G boundary.  The
      MSI-X table offset is defined by the hardware spec to 32bits, so we
      simply use a cast rather than changing data structure types.  This
      scenario is purely theoretically, typically the MSI-X table is located
      at the front of the BAR.
      Reported-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      07ceaf98
  6. 26 4月, 2015 1 次提交
  7. 03 3月, 2015 2 次提交
  8. 11 2月, 2015 4 次提交
    • A
      vfio: Fix debug message compile error · bc5baffa
      Alexey Kardashevskiy 提交于
      This fixes a compiler error which occurs if DEBUG_VFIO is defined.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      bc5baffa
    • P
      vfio: unmap and free BAR data in instance_finalize · ba5e6bfa
      Paolo Bonzini 提交于
      In the case of VFIO, the unrealize callback is too early to munmap the
      BARs.  The munmap must be delayed until memory accesses are complete.
      To do this, split vfio_unmap_bars in two.  The removal step, now called
      vfio_unregister_bars, remains in vfio_exitfn.  The reclamation step
      is vfio_unmap_bars and is moved to the instance_finalize callback.
      
      Similarly, quirk MemoryRegions have to be removed during
      vfio_unregister_bars, but freeing the data structure must be delayed
      to vfio_unmap_bars.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      ba5e6bfa
    • P
      vfio: free dynamically-allocated data in instance_finalize · 77a10d04
      Paolo Bonzini 提交于
      In order to enable out-of-BQL address space lookup, destruction of
      devices needs to be split in two phases.
      
      Unrealize is the first phase; once it complete no new accesses will
      be started, but there may still be pending memory accesses can still
      be completed.
      
      The second part is freeing the device, which only happens once all memory
      accesses are complete.  At this point the reference count has dropped to
      zero, an RCU grace period must have completed (because the RCU-protected
      FlatViews hold a reference to the device via memory_region_ref).  This is
      when instance_finalize is called.
      
      Freeing data belongs in an instance_finalize callback, because the
      dynamically allocated memory can still be used after unrealize by the
      pending memory accesses.
      
      This starts the process by creating an instance_finalize callback and
      freeing most of the dynamically-allocated data in instance_finalize.
      Because instance_finalize is also called on error paths or also when
      the device is actually not realized, the common code needs some changes
      to be ready for this.  The error path in vfio_initfn can be simplified too.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      77a10d04
    • P
      vfio: cleanup vfio_get_device error path, remove vfio_populate_device callback · 217e9fdc
      Paolo Bonzini 提交于
      Now that vfio_put_base_device is called unconditionally at instance_finalize
      time, it can be called twice if vfio_populate_device fails.  This works
      but it is slightly harder to follow.
      
      Change vfio_get_device to not touch the vbasedev struct until it will
      definitely succeed, moving the vfio_populate_device call back to vfio-pci.
      This way, vfio_put_base_device will only be called once.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      217e9fdc
  9. 05 2月, 2015 1 次提交
  10. 09 1月, 2015 2 次提交
    • A
      vfio-pci: Fix interrupt disabling · b3e27c3a
      Alex Williamson 提交于
      When disabling MSI/X interrupts the disable functions will leave the
      device in INTx mode (when available).  This matches how hardware
      operates, INTx is enabled unless MSI/X is enabled (DisINTx is handled
      separately).  Therefore when we really want to disable all interrupts,
      such as when removing the device, and we start with the device in
      MSI/X mode, we need to pass through INTx on our way to being
      completely quiesced.
      
      In well behaved situations, the guest driver will have shutdown the
      device and it will start vfio_exitfn() in INTx mode, producing the
      desired result.  If hot-unplug causes the guest to crash, we may get
      the device in MSI/X state, which will leave QEMU with a bogus handler
      installed.
      
      Fix this by re-ordering our disable routine so that it should always
      finish in VFIO_INT_NONE state, which is what all callers expect.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      b3e27c3a
    • A
      vfio-pci: Fix BAR size overflow · 29c6e6df
      Alex Williamson 提交于
      We use an unsigned int when working with the PCI BAR size, which can
      obviously overflow if the BAR is 4GB or larger.  This needs to change
      to a fixed length uint64_t.  A similar issue is possible, though even
      more unlikely, when mapping the region above an MSI-X table.  The
      start of the MSI-X vector table must be below 4GB, but the end, and
      therefore the start of the next mapping region, could still land at
      4GB.
      Suggested-by: NNishank Trivedi <nishank.trivedi@netapp.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Reviewed-by: NDon Slutz <dslutz@verizon.com>
      Tested-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      29c6e6df
  11. 23 12月, 2014 8 次提交
  12. 20 12月, 2014 6 次提交
  13. 15 12月, 2014 1 次提交
  14. 31 10月, 2014 1 次提交
  15. 15 10月, 2014 2 次提交