1. 23 3月, 2016 8 次提交
  2. 18 3月, 2016 1 次提交
    • E
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake 提交于
      Simple unions were carrying a special case that hid their 'data'
      QMP member from the resulting C struct, via the hack method
      QAPISchemaObjectTypeVariant.simple_union_type().  But by using
      the work we started by unboxing flat union and alternate
      branches, coupled with the ability to visit the members of an
      implicit type, we can now expose the simple union's implicit
      type in qapi-types.h:
      
      | struct q_obj_ImageInfoSpecificQCow2_wrapper {
      |     ImageInfoSpecificQCow2 *data;
      | };
      |
      | struct q_obj_ImageInfoSpecificVmdk_wrapper {
      |     ImageInfoSpecificVmdk *data;
      | };
      ...
      | struct ImageInfoSpecific {
      |     ImageInfoSpecificKind type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        ImageInfoSpecificQCow2 *qcow2;
      |-        ImageInfoSpecificVmdk *vmdk;
      |+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
      |+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
      |     } u;
      | };
      
      Doing this removes asymmetry between QAPI's QMP side and its
      C side (both sides now expose 'data'), and means that the
      treatment of a simple union as sugar for a flat union is now
      equivalent in both languages (previously the two approaches used
      a different layer of dereferencing, where the simple union could
      be converted to a flat union with equivalent C layout but
      different {} on the wire, or to an equivalent QMP wire form
      but with different C representation).  Using the implicit type
      also lets us get rid of the simple_union_type() hack.
      
      Of course, now all clients of simple unions have to adjust from
      using su->u.member to using su->u.member.data; while this touches
      a number of files in the tree, some earlier cleanup patches
      helped minimize the change to the initialization of a temporary
      variable rather than every single member access.  The generated
      qapi-visit.c code is also affected by the layout change:
      
      |@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
      |     }
      |     switch (obj->type) {
      |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
      |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
      |+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
      |         break;
      |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
      |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
      |+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
      |         break;
      |     default:
      |         abort();
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  3. 17 3月, 2016 21 次提交
  4. 16 3月, 2016 10 次提交
    • 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
      spapr_pci: Remove finish_realize hook · a36304fd
      David Gibson 提交于
      Now that spapr-pci-vfio-host-bridge is reduced to just a stub, there is
      only one implementation of the finish_realize hook in sPAPRPHBClass.  So,
      we can fold that implementation into its (single) caller, and remove the
      hook.  That's the last thing left in sPAPRPHBClass, so that can go away as
      well.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      a36304fd
    • D
      spapr_pci: (Mostly) remove spapr-pci-vfio-host-bridge · 72700d7e
      David Gibson 提交于
      Now that the regular spapr-pci-host-bridge can handle EEH, there are only
      two things that spapr-pci-vfio-host-bridge does differently:
          1. automatically sizes its DMA window to match the host IOMMU
          2. checks if the attached VFIO container is backed by the
             VFIO_SPAPR_TCE_IOMMU type on the host
      
      (1) is not particularly useful, since the default window used by the
      regular host bridge will work with the host IOMMU configuration on all
      current systems anyway.
      
      Plus, automatically changing guest visible configuration (such as the DMA
      window) based on host settings is generally a bad idea.  It's not
      definitively broken, since spapr-pci-vfio-host-bridge is only supposed to
      support VFIO devices which can't be migrated anyway, but still.
      
      (2) is not really useful, because if a guest tries to configure EEH on a
      different host IOMMU, the first call will fail and that will be that.
      
      It's possible there are scripts or tools out there which expect
      spapr-pci-vfio-host-bridge, so we don't remove it entirely.  This patch
      reduces it to just a stub for backwards compatibility.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      72700d7e
    • D
      spapr_pci: Allow EEH on spapr-pci-host-bridge · c1fa017c
      David Gibson 提交于
      Now that the EEH code is independent of the special
      spapr-vfio-pci-host-bridge device, we can allow it on all spapr PCI
      host bridges instead.  We do this by changing spapr_phb_eeh_available()
      to be based on the vfio_eeh_as_ok() call instead of the host bridge class.
      
      Because the value of vfio_eeh_as_ok() can change with devices being
      hotplugged or unplugged, this can potentially lead to some strange edge
      cases where the guest starts using EEH, then it starts failing because
      of a change in status.
      
      However, it's not really any worse than the current situation.  Cases that
      would have worked previously will still work (i.e. VFIO devices from at
      most one VFIO IOMMU group per vPHB), it's just that it's no longer
      necessary to use spapr-vfio-pci-host-bridge with the groupid pre-specified.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      c1fa017c
    • D
      spapr_pci: Eliminate class callbacks · fbb4e983
      David Gibson 提交于
      The EEH operations in the spapr-vfio-pci-host-bridge no longer rely on the
      special groupid field in sPAPRPHBVFIOState.  So we can simplify, removing
      the class specific callbacks with direct calls based on a simple
      spapr_phb_eeh_enabled() helper.  For now we implement that in terms of
      a boolean in the class, but we'll continue to clean that up later.
      
      On its own this is a rather strange way of doing things, but it's a useful
      intermediate step to further cleanups.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      fbb4e983
    • D
      spapr_pci: Switch to vfio_eeh_as_op() interface · 76a9e9f6
      David Gibson 提交于
      This switches all EEH on VFIO operations in spapr_pci_vfio.c from the
      broken vfio_container_ioctl() interface to the new vfio_as_eeh_op()
      interface.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      76a9e9f6
    • 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
    • G
      spapr_rng: fix race with main loop · f1a6cf3e
      Greg Kurz 提交于
      Since commit "60253ed1 rng: add request queue support to rng-random",
      the use of a spapr_rng device may hang vCPU threads.
      
      The following path is taken without holding the lock to the main loop mutex:
      
      h_random()
        rng_backend_request_entropy()
          rng_random_request_entropy()
            qemu_set_fd_handler()
      
      The consequence is that entropy_available() may be called before the vCPU
      thread could even queue the request: depending on the scheduling, it may
      happen that entropy_available() does not call random_recv()->qemu_sem_post().
      The vCPU thread will then sleep forever in h_random()->qemu_sem_wait().
      
      This could not happen before 60253ed1 because entropy_available() used
      to call random_recv() unconditionally.
      
      This patch ensures the lock is held to avoid the race.
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Reviewed-by: NCédric Le Goater <clg@fr.ibm.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f1a6cf3e
    • D
      target-ppc: Eliminate kvmppc_kern_htab global · c18ad9a5
      David Gibson 提交于
      fa48b432 "target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM"
      purports to remove a hack in the handling of hash page tables (HPTs)
      managed by KVM instead of qemu.  However, it actually went in the wrong
      direction.
      
      That patch requires anything looking for an external HPT (that is one not
      managed by the guest itself) to check both env->external_htab (for a qemu
      managed HPT) and kvmppc_kern_htab (for a KVM managed HPT).  That's a
      problem because kvmppc_kern_htab is local to mmu-hash64.c, but some places
      which need to check for an external HPT are outside that, such as
      kvm_arch_get_registers().  The latter was subtly broken by the earlier
      patch such that gdbstub can no longer access memory.
      
      Basically a KVM managed HPT is much more like a qemu managed HPT than it is
      like a guest managed HPT, so the original "hack" was actually on the right
      track.
      
      This partially reverts fa48b432, so we again mark a KVM managed external HPT
      by putting a special but non-NULL value in env->external_htab.  It then
      goes further, using that marker to eliminate the kvmppc_kern_htab global
      entirely.  The ppc_hash64_set_external_hpt() helper function is extended
      to set that marker if passed a NULL value (if you're setting an external
      HPT, but don't have an actual HPT to set, the assumption is that it must
      be a KVM managed HPT).
      
      This also has some flow-on changes to the HPT access helpers, required by
      the above changes.
      Reported-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Tested-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      c18ad9a5
    • D
      target-ppc: Add helpers for updating a CPU's SDR1 and external HPT · e5c0d3ce
      David Gibson 提交于
      When a Power cpu with 64-bit hash MMU has it's hash page table (HPT)
      pointer updated by a write to the SDR1 register we need to update some
      derived variables.  Likewise, when the cpu is configured for an external
      HPT (one not in the guest memory space) some derived variables need to be
      updated.
      
      Currently the logic for this is (partially) duplicated in ppc_store_sdr1()
      and in spapr_cpu_reset().  In future we're going to need it in some other
      places, so make some common helpers for this update.
      
      In addition the new ppc_hash64_set_external_hpt() helper also updates
      SDR1 in KVM - it's not updated by the normal runtime KVM <-> qemu CPU
      synchronization.  In a sense this belongs logically in the
      ppc_hash64_set_sdr1() helper, but that is called from
      kvm_arch_get_registers() so can't itself call cpu_synchronize_state()
      without infinite recursion.  In practice this doesn't matter because
      the only other caller is TCG specific.
      
      Currently there aren't situations where updating SDR1 at runtime in KVM
      matters, but there are going to be in future.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      e5c0d3ce