1. 23 10月, 2015 3 次提交
    • D
      spapr_iommu: Provide a function to switch a TCE table to allowing VFIO · c10325d6
      David Gibson 提交于
      Because of the way non-VFIO guest IOMMU operations are KVM accelerated, not
      all TCE tables (guest IOMMU contexts) can support VFIO devices.  Currently,
      this is decided at creation time.
      
      To support hotplug of VFIO devices, we need to allow a TCE table which
      previously didn't allow VFIO devices to be switched so that it can.  This
      patch adds an spapr_tce_set_need_vfio() function to do this, by
      reallocating the table in userspace if necessary.
      
      Currently this doesn't allow the KVM acceleration to be re-enabled if all
      the VFIO devices are removed.  That's an optimization for another time.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      c10325d6
    • D
      spapr_iommu: Rename vfio_accel parameter · 6a81dd17
      David Gibson 提交于
      The vfio_accel parameter used when creating a new TCE table (guest IOMMU
      context) has a confusing name.  What it really means is whether we need the
      TCE table created to be able to support VFIO devices.
      
      VFIO is relevant, because when available we use in-kernel acceleration of
      the TCE table, but that may not work with VFIO devices because updates to
      the table are handled in kernel, bypass qemu and so don't hit qemu's
      infrastructure for keeping the VFIO host IOMMU state in sync with the guest
      IOMMU state.
      
      Rename the parameter to "need_vfio" throughout.  This is a cosmetic change,
      with no impact on the logic.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      6a81dd17
    • D
      spapr_pci: Allow PCI host bridge DMA window to be configured · f93caaac
      David Gibson 提交于
      At present the PCI host bridge (PHB) for the pseries machine type has a
      fixed DMA window from 0..1GB (in PCI address space) which is mapped to real
      memory via the PAPR paravirtualized IOMMU.
      
      For better support of VFIO devices, we're going to want to allow for
      different configurations of the DMA window.
      
      Eventually we'll want to allow the guest itself to reconfigure the window
      via the PAPR dynamic DMA window interface, but as a preliminary this patch
      allows the user to reconfigure the window with new properties on the PHB
      device.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      f93caaac
  2. 22 10月, 2015 8 次提交
  3. 19 10月, 2015 2 次提交
  4. 18 10月, 2015 1 次提交
  5. 12 10月, 2015 1 次提交
  6. 09 10月, 2015 1 次提交
    • M
      qdev: Protect device-list-properties against broken devices · 4c315c27
      Markus Armbruster 提交于
      Several devices don't survive object_unref(object_new(T)): they crash
      or hang during cleanup, or they leave dangling pointers behind.
      
      This breaks at least device-list-properties, because
      qmp_device_list_properties() needs to create a device to find its
      properties.  Broken in commit f4eb32b5 "qmp: show QOM properties in
      device-list-properties", v2.1.  Example reproducer:
      
          $ qemu-system-aarch64 -nodefaults -display none -machine none -S -qmp stdio
          {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
          { "execute": "qmp_capabilities" }
          {"return": {}}
          { "execute": "device-list-properties", "arguments": { "typename": "pxa2xx-pcmcia" } }
          qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
          Aborted (core dumped)
          [Exit 134 (SIGABRT)]
      
      Unfortunately, I can't fix the problems in these devices right now.
      Instead, add DeviceClass member cannot_destroy_with_object_finalize_yet
      to mark them:
      
      * Hang during cleanup (didn't debug, so I can't say why):
        "realview_pci", "versatile_pci".
      
      * Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic",
        "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such
        CPUs
      
      * Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu",
        "host-powerpc64-cpu", "host-embedded-powerpc-cpu",
        "host-powerpc-cpu" (the powerpc ones can't currently reach the
        assertion, because the CPUs are only registered when KVM is enabled,
        but the assertion is arguably in the wrong place all the same)
      
      Make qmp_device_list_properties() fail cleanly when the device is so
      marked.  This improves device-list-properties from "crashes, hangs or
      leaves dangling pointers behind" to "fails".  Not a complete fix, just
      a better-than-nothing work-around.  In the above reproducer,
      device-list-properties now fails with "Can't list properties of device
      'pxa2xx-pcmcia'".
      
      This also protects -device FOO,help, which uses the same machinery
      since commit ef523587 "qdev-monitor: include QOM properties in -device
      FOO, help output", v2.2.  Example reproducer:
      
          $ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help
      
      Before:
      
          qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
      
      After:
      
          Can't list properties of device 'pxa2xx-pcmcia'
      
      Cc: "Andreas Färber" <afaerber@suse.de>
      Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Anthony Green <green@moxielogic.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
      Cc: Blue Swirl <blauwirbel@gmail.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Jia Liu <proljc@gmail.com>
      Cc: Leon Alrae <leon.alrae@imgtec.com>
      Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Walle <michael@walle.cc>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: qemu-ppc@nongnu.org
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1443689999-12182-10-git-send-email-armbru@redhat.com>
      4c315c27
  7. 08 10月, 2015 1 次提交
  8. 06 10月, 2015 4 次提交
    • D
      vfio: Record host IOMMU's available IO page sizes · 7a140a57
      David Gibson 提交于
      Depending on the host IOMMU type we determine and record the available page
      sizes for IOMMU translation.  We'll need this for other validation in
      future patches.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      7a140a57
    • D
      vfio: Check guest IOVA ranges against host IOMMU capabilities · 3898aad3
      David Gibson 提交于
      The current vfio core code assumes that the host IOMMU is capable of
      mapping any IOVA the guest wants to use to where we need.  However, real
      IOMMUs generally only support translating a certain range of IOVAs (the
      "DMA window") not a full 64-bit address space.
      
      The common x86 IOMMUs support a wide enough range that guests are very
      unlikely to go beyond it in practice, however the IOMMU used on IBM Power
      machines - in the default configuration - supports only a much more limited
      IOVA range, usually 0..2GiB.
      
      If the guest attempts to set up an IOVA range that the host IOMMU can't
      map, qemu won't report an error until it actually attempts to map a bad
      IOVA.  If guest RAM is being mapped directly into the IOMMU (i.e. no guest
      visible IOMMU) then this will show up very quickly.  If there is a guest
      visible IOMMU, however, the problem might not show up until much later when
      the guest actually attempt to DMA with an IOVA the host can't handle.
      
      This patch adds a test so that we will detect earlier if the guest is
      attempting to use IOVA ranges that the host IOMMU won't be able to deal
      with.
      
      For now, we assume that "Type1" (x86) IOMMUs can support any IOVA, this is
      incorrect, but no worse than what we have already.  We can't do better for
      now because the Type1 kernel interface doesn't tell us what IOVA range the
      IOMMU actually supports.
      
      For the Power "sPAPR TCE" IOMMU, however, we can retrieve the supported
      IOVA range and validate guest IOVA ranges against it, and this patch does
      so.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      3898aad3
    • D
      vfio: Remove unneeded union from VFIOContainer · ee0bf0e5
      David Gibson 提交于
      Currently the VFIOContainer iommu_data field contains a union with
      different information for different host iommu types.  However:
         * It only actually contains information for the x86-like "Type1" iommu
         * Because we have a common listener the Type1 fields are actually used
      on all IOMMU types, including the SPAPR TCE type as well
      
      In fact we now have a general structure for the listener which is unlikely
      to ever need per-iommu-type information, so this patch removes the union.
      
      In a similar way we can unify the setup of the vfio memory listener in
      vfio_connect_container() that is currently split across a switch on iommu
      type, but is effectively the same in both cases.
      
      The iommu_data.release pointer was only needed as a cleanup function
      which would handle potentially different data in the union.  With the
      union gone, it too can be removed.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      ee0bf0e5
    • E
      hw/vfio/platform: change interrupt/unmask fields into pointer · a22313de
      Eric Auger 提交于
      unmask EventNotifier might not be initialized in case of edge
      sensitive irq. Using EventNotifier pointers make life simpler to
      handle the edge-sensitive irqfd setup.
      Signed-off-by: NEric Auger <eric.auger@linaro.org>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      a22313de
  9. 03 10月, 2015 4 次提交
  10. 02 10月, 2015 2 次提交
  11. 01 10月, 2015 1 次提交
  12. 25 9月, 2015 11 次提交
  13. 24 9月, 2015 1 次提交