1. 19 7月, 2016 1 次提交
    • A
      vfio/pci: Hide ARI capability · 383a7af7
      Alex Williamson 提交于
      QEMU supports ARI on downstream ports and assigned devices may support
      ARI in their extended capabilities.  The endpoint ARI capability
      specifies the next function, such that the OS doesn't need to walk
      each possible function, however this next function is relative to the
      host, not the guest.  This leads to device discovery issues when we
      combine separate functions into virtual multi-function packages in a
      guest.  For example, SR-IOV VFs are not enumerated by simply probing
      the function address space, therefore the ARI next-function field is
      zero.  When we combine multiple VFs together as a multi-function
      device in the guest, the guest OS identifies ARI is enabled, relies on
      this next-function field, and stops looking for additional function
      after the first is found.
      
      Long term we should expose the ARI capability to the guest to enable
      configurations with more than 8 functions per slot, but this requires
      additional QEMU PCI infrastructure to manage the next-function field
      for multiple, otherwise independent devices.  In the short term,
      hiding this capability allows equivalent functionality to what we
      currently have on non-express chipsets.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      383a7af7
  2. 18 7月, 2016 1 次提交
  3. 12 7月, 2016 1 次提交
  4. 05 7月, 2016 4 次提交
    • C
      pci: Convert msi_init() to Error and fix callers to check it · 1108b2f8
      Cao jin 提交于
      msi_init() reports errors with error_report(), which is wrong
      when it's used in realize().
      
      Fix by converting it to Error.
      
      Fix its callers to handle failure instead of ignoring it.
      
      For those callers who don't handle the failure, it might happen:
      when user want msi on, but he doesn't get what he want because of
      msi_init fails silently.
      
      cc: Gerd Hoffmann <kraxel@redhat.com>
      cc: John Snow <jsnow@redhat.com>
      cc: Dmitry Fleytman <dmitry@daynix.com>
      cc: Jason Wang <jasowang@redhat.com>
      cc: Michael S. Tsirkin <mst@redhat.com>
      cc: Hannes Reinecke <hare@suse.de>
      cc: Paolo Bonzini <pbonzini@redhat.com>
      cc: Alex Williamson <alex.williamson@redhat.com>
      cc: Markus Armbruster <armbru@redhat.com>
      cc: Marcel Apfelbaum <marcel@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NCao jin <caoj.fnst@cn.fujitsu.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      1108b2f8
    • A
      vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2) · 2e4109de
      Alexey Kardashevskiy 提交于
      New VFIO_SPAPR_TCE_v2_IOMMU type supports dynamic DMA window management.
      This adds ability to VFIO common code to dynamically allocate/remove
      DMA windows in the host kernel when new VFIO container is added/removed.
      
      This adds a helper to vfio_listener_region_add which makes
      VFIO_IOMMU_SPAPR_TCE_CREATE ioctl and adds just created IOMMU into
      the host IOMMU list; the opposite action is taken in
      vfio_listener_region_del.
      
      When creating a new window, this uses heuristic to decide on the TCE table
      levels number.
      
      This should cause no guest visible change in behavior.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      [dwg: Added some casts to prevent printf() warnings on certain targets
       where the kernel headers' __u64 doesn't match uint64_t or PRIx64]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      2e4109de
    • A
      vfio: Add host side DMA window capabilities · f4ec5e26
      Alexey Kardashevskiy 提交于
      There are going to be multiple IOMMUs per a container. This moves
      the single host IOMMU parameter set to a list of VFIOHostDMAWindow.
      
      This should cause no behavioral change and will be used later by
      the SPAPR TCE IOMMU v2 which will also add a vfio_host_win_del() helper.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f4ec5e26
    • A
      vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2) · 318f67ce
      Alexey Kardashevskiy 提交于
      This makes use of the new "memory registering" feature. The idea is
      to provide the userspace ability to notify the host kernel about pages
      which are going to be used for DMA. Having this information, the host
      kernel can pin them all once per user process, do locked pages
      accounting (once) and not spent time on doing that in real time with
      possible failures which cannot be handled nicely in some cases.
      
      This adds a prereg memory listener which listens on address_space_memory
      and notifies a VFIO container about memory which needs to be
      pinned/unpinned. VFIO MMIO regions (i.e. "skip dump" regions) are skipped.
      
      The feature is only enabled for SPAPR IOMMU v2. The host kernel changes
      are required. Since v2 does not need/support VFIO_IOMMU_ENABLE, this does
      not call it when v2 is detected and enabled.
      
      This enforces guest RAM blocks to be host page size aligned; however
      this is not new as KVM already requires memory slots to be host page
      size aligned.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      [dwg: Fix compile error on 32-bit host]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      318f67ce
  5. 01 7月, 2016 4 次提交
  6. 22 6月, 2016 1 次提交
  7. 21 6月, 2016 1 次提交
  8. 17 6月, 2016 2 次提交
  9. 27 5月, 2016 9 次提交
  10. 26 5月, 2016 1 次提交
  11. 19 5月, 2016 1 次提交
  12. 29 3月, 2016 1 次提交
  13. 23 3月, 2016 1 次提交
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  14. 16 3月, 2016 2 次提交
    • D
      vfio: Eliminate vfio_container_ioctl() · 3356128c
      David Gibson 提交于
      vfio_container_ioctl() was a bad interface that bypassed abstraction
      boundaries, had semantics that sat uneasily with its name, and was unsafe
      in many realistic circumstances.  Now that spapr-pci-vfio-host-bridge has
      been folded into spapr-pci-host-bridge, there are no more users, so remove
      it.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Acked-by: NAlex Williamson <alex.williamson@redhat.com>
      3356128c
    • D
      vfio: Start improving VFIO/EEH interface · 3153119e
      David Gibson 提交于
      At present the code handling IBM's Enhanced Error Handling (EEH) interface
      on VFIO devices operates by bypassing the usual VFIO logic with
      vfio_container_ioctl().  That's a poorly designed interface with unclear
      semantics about exactly what can be operated on.
      
      In particular it operates on a single vfio container internally (hence the
      name), but takes an address space and group id, from which it deduces the
      container in a rather roundabout way.  groupids are something that code
      outside vfio shouldn't even be aware of.
      
      This patch creates new interfaces for EEH operations.  Internally we
      have vfio_eeh_container_op() which takes a VFIOContainer object
      directly.  For external use we have vfio_eeh_as_ok() which determines
      if an AddressSpace is usable for EEH (at present this means it has a
      single container with exactly one group attached), and vfio_eeh_as_op()
      which will perform an operation on an AddressSpace in the unambiguous case,
      and otherwise returns an error.
      
      This interface still isn't great, but it's enough of an improvement to
      allow a number of cleanups in other places.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Acked-by: NAlex Williamson <alex.williamson@redhat.com>
      3153119e
  15. 11 3月, 2016 7 次提交
    • N
      vfio/pci: replace fixed string limit by g_strdup_printf · 062ed5d8
      Neo Jia 提交于
      A trivial change to remove string limit by using g_strdup_printf
      Tested-by: NNeo Jia <cjia@nvidia.com>
      Signed-off-by: NNeo Jia <cjia@nvidia.com>
      Signed-off-by: NKirti Wankhede <kwankhede@nvidia.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      062ed5d8
    • A
      vfio/pci: Split out VGA setup · e593c021
      Alex Williamson 提交于
      This could be setup later by device specific code, such as IGD
      initialization.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      e593c021
    • A
      vfio/pci: Fixup PCI option ROMs · e2e5ee9c
      Alex Williamson 提交于
      Devices like Intel graphics are known to not only have bad checksums,
      but also the wrong device ID.  This is not so surprising given that
      the video BIOS is typically part of the system firmware image rather
      that embedded into the device and needs to support any IGD device
      installed into the system.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      e2e5ee9c
    • A
      vfio/pci: Convert all MemoryRegion to dynamic alloc and consistent functions · 2d82f8a3
      Alex Williamson 提交于
      Match common vfio code with setup, exit, and finalize functions for
      BAR, quirk, and VGA management.  VGA is also changed to dynamic
      allocation to match the other MemoryRegions.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      2d82f8a3
    • A
      vfio: Generalize region support · db0da029
      Alex Williamson 提交于
      Both platform and PCI vfio drivers create a "slow", I/O memory region
      with one or more mmap memory regions overlayed when supported by the
      device. Generalize this to a set of common helpers in the core that
      pulls the region info from vfio, fills the region data, configures
      slow mapping, and adds helpers for comleting the mmap, enable/disable,
      and teardown.  This can be immediately used by the PCI MSI-X code,
      which needs to mmap around the MSI-X vector table.
      
      This also changes VFIORegion.mem to be dynamically allocated because
      otherwise we don't know how the caller has allocated VFIORegion and
      therefore don't know whether to unreference it to destroy the
      MemoryRegion or not.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      db0da029
    • A
      vfio: Wrap VFIO_DEVICE_GET_REGION_INFO · 46900226
      Alex Williamson 提交于
      In preparation for supporting capability chains on regions, wrap
      ioctl(VFIO_DEVICE_GET_REGION_INFO) so we don't duplicate the code for
      each caller.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      46900226
    • A
      vfio: Add sysfsdev property for pci & platform · 7df9381b
      Alex Williamson 提交于
      vfio-pci currently requires a host= parameter, which comes in the
      form of a PCI address in [domain:]<bus:slot.function> notation.  We
      expect to find a matching entry in sysfs for that under
      /sys/bus/pci/devices/.  vfio-platform takes a similar approach, but
      defines the host= parameter to be a string, which can be matched
      directly under /sys/bus/platform/devices/.  On the PCI side, we have
      some interest in using vfio to expose vGPU devices.  These are not
      actual discrete PCI devices, so they don't have a compatible host PCI
      bus address or a device link where QEMU wants to look for it.  There's
      also really no requirement that vfio can only be used to expose
      physical devices, a new vfio bus and iommu driver could expose a
      completely emulated device.  To fit within the vfio framework, it
      would need a kernel struct device and associated IOMMU group, but
      those are easy constraints to manage.
      
      To support such devices, which would include vGPUs, that honor the
      VFIO PCI programming API, but are not necessarily backed by a unique
      PCI address, add support for specifying any device in sysfs.  The
      vfio API already has support for probing the device type to ensure
      compatibility with either vfio-pci or vfio-platform.
      
      With this, a vfio-pci device could either be specified as:
      
      -device vfio-pci,host=02:00.0
      
      or
      
      -device vfio-pci,sysfsdev=/sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0
      
      or even
      
      -device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:02:00.0
      
      When vGPU support comes along, this might look something more like:
      
      -device vfio-pci,sysfsdev=/sys/devices/virtual/intel-vgpu/vgpu0@0000:00:02.0
      
      NB - This is only a made up example path
      
      The same change is made for vfio-platform, specifying sysfsdev has
      precedence over the old host option.
      Tested-by: NEric Auger <eric.auger@linaro.org>
      Reviewed-by: NEric Auger <eric.auger@linaro.org>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      7df9381b
  16. 23 2月, 2016 1 次提交
    • P
      all: Clean up includes · 974dc73d
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      ---
      This just catches a couple of stragglers since I posted
      the last clean-includes patchset last week.
      974dc73d
  17. 20 2月, 2016 2 次提交