1. 09 2月, 2016 2 次提交
    • E
      qom: Swap 'name' next to visitor in ObjectPropertyAccessor · d7bce999
      Eric Blake 提交于
      Similar to the previous patch, it's nice to have all functions
      in the tree that involve a visitor and a name for conversion to
      or from QAPI to consistently stick the 'name' parameter next
      to the Visitor parameter.
      
      Done by manually changing include/qom/object.h and qom/object.c,
      then running this Coccinelle script and touching up the fallout
      (Coccinelle insisted on adding some trailing whitespace).
      
          @ rule1 @
          identifier fn;
          typedef Object, Visitor, Error;
          identifier obj, v, opaque, name, errp;
          @@
           void fn
          - (Object *obj, Visitor *v, void *opaque, const char *name,
          + (Object *obj, Visitor *v, const char *name, void *opaque,
             Error **errp) { ... }
      
          @@
          identifier rule1.fn;
          expression obj, v, opaque, name, errp;
          @@
           fn(obj, v,
          -   opaque, name,
          +   name, opaque,
              errp)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d7bce999
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  2. 05 2月, 2016 1 次提交
    • P
      all: Clean up includes · d38ea87a
      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>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  3. 21 1月, 2016 1 次提交
    • P
      memory: Add address_space_init_shareable() · f0c02d15
      Peter Crosthwaite 提交于
      This will either create a new AS or return a pointer to an
      already existing equivalent one, if we have already created
      an AS for the specified root memory region.
      
      The motivation is to reuse address spaces as much as possible.
      It's going to be quite common that bus masters out in device land
      have pointers to the same memory region for their mastering yet
      each will need to create its own address space. Let the memory
      API implement sharing for them.
      
      Aside from the perf optimisations, this should reduce the amount
      of redundant output on info mtree as well.
      
      Thee returned value will be malloced, but the malloc will be
      automatically freed when the AS runs out of refs.
      Signed-off-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
      [PMM: dropped check for NULL root as unused; added doc-comment;
       squashed Peter C's reference-counting patch into this one;
       don't compare name string when deciding if we can share ASes;
       read as->malloced before the unref of as->root to avoid possible
       read-after-free if as->root was the owner of as]
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Acked-by: NEdgar E. Iglesias <edgar.iglesias@xilinx.com>
      f0c02d15
  4. 18 12月, 2015 3 次提交
  5. 17 12月, 2015 3 次提交
  6. 12 11月, 2015 1 次提交
  7. 04 11月, 2015 1 次提交
  8. 09 10月, 2015 1 次提交
    • P
      memory: allow destroying a non-empty MemoryRegion · 2e2b8eb7
      Paolo Bonzini 提交于
      This is legal; the MemoryRegion will simply unreference all the
      existing subregions and possibly bring them down with it as well.
      However, it requires a bit of care to avoid an infinite loop.
      Finalizing a memory region cannot trigger an address space update,
      but memory_region_del_subregion errs on the side of caution and
      might trigger a spurious update: avoid that by resetting mr->enabled
      first.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1443689999-12182-2-git-send-email-armbru@redhat.com>
      2e2b8eb7
  9. 06 10月, 2015 1 次提交
    • D
      memory: Allow replay of IOMMU mapping notifications · a788f227
      David Gibson 提交于
      When we have guest visible IOMMUs, we allow notifiers to be registered
      which will be informed of all changes to IOMMU mappings.  This is used by
      vfio to keep the host IOMMU mappings in sync with guest IOMMU mappings.
      
      However, unlike with a memory region listener, an iommu notifier won't be
      told about any mappings which already exist in the (guest) IOMMU at the
      time it is registered.  This can cause problems if hotplugging a VFIO
      device onto a guest bus which had existing guest IOMMU mappings, but didn't
      previously have an VFIO devices (and hence no host IOMMU mappings).
      
      This adds a memory_region_iommu_replay() function to handle this case.  It
      replays any existing mappings in an IOMMU memory region to a specified
      notifier.  Because the IOMMU memory region doesn't internally remember the
      granularity of the guest IOMMU it has a small hack where the caller must
      specify a granularity at which to replay mappings.
      
      If there are finer mappings in the guest IOMMU these will be reported in
      the iotlb structures passed to the notifier which it must handle (probably
      causing it to flag an error).  This isn't new - the VFIO iommu notifier
      must already handle notifications about guest IOMMU mappings too short
      for it to represent in the host IOMMU.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      a788f227
  10. 18 9月, 2015 1 次提交
  11. 13 8月, 2015 1 次提交
  12. 28 7月, 2015 1 次提交
    • P
      memory: do not add a reference to the owner of aliased regions · 52c91dac
      Paolo Bonzini 提交于
      Very often the owner of the aliased region is the same as the owner of the alias
      region itself.  When this happens, the reference count can never go back to 0 and
      the owner is leaked.  This is for example breaking hot-unplug of virtio-pci
      devices (the device cannot be plugged back again with the same id).
      
      Another common use for alias is to transform the system I/O address space
      into an MMIO regions; in this case the aliased region never dies, so there
      is no problem.  Otherwise the owner is always the same for aliasing
      and aliased region.
      
      I checked all calls to memory_region_init_alias introduced after commit
      dfde4e6e (memory: add ref/unref calls, 2013-05-06) and they do not need the
      reference in order to keep the owner of the aliased region alive.
      Reported-by: NMichael S. Tsirkin <mst@redhat.com>
      Tested-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      52c91dac
  13. 24 7月, 2015 1 次提交
  14. 17 7月, 2015 1 次提交
    • P
      memory: fix refcount leak in memory_region_present · c6742b14
      Paolo Bonzini 提交于
      memory_region_present() leaks a reference to a MemoryRegion in the
      case "mr == container".  While fixing it, avoid reference counting
      altogether for memory_region_present(), by using RCU only.
      
      The return value could in principle be already invalid immediately
      after memory_region_present returns, but presumably the caller knows
      that and it's using memory_region_present to probe for devices that
      are unpluggable, or something like that.  The RCU critical section
      is needed anyway, because it protects as->current_map.
      Reported-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c6742b14
  15. 01 7月, 2015 2 次提交
  16. 05 6月, 2015 8 次提交
  17. 30 4月, 2015 2 次提交
  18. 28 4月, 2015 1 次提交
  19. 26 4月, 2015 2 次提交
    • P
      memory: Replace io_mem_read/write with memory_region_dispatch_read/write · 3b643495
      Peter Maydell 提交于
      Rather than retaining io_mem_read/write as simple wrappers around
      the memory_region_dispatch_read/write functions, make the latter
      public and change all the callers to use them, since we need to
      touch all the callsites anyway to add MemTxAttrs and MemTxResult
      support. Delete io_mem_read and io_mem_write entirely.
      
      (All the callers currently pass MEMTXATTRS_UNSPECIFIED
      and convert the return value back to bool or ignore it.)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      3b643495
    • P
      memory: Define API for MemoryRegionOps to take attrs and return status · cc05c43a
      Peter Maydell 提交于
      Define an API so that devices can register MemoryRegionOps whose read
      and write callback functions are passed an arbitrary pointer to some
      transaction attributes and can return a success-or-failure status code.
      This will allow us to model devices which:
       * behave differently for ARM Secure/NonSecure memory accesses
       * behave differently for privileged/unprivileged accesses
       * may return a transaction failure (causing a guest exception)
         for erroneous accesses
      
      This patch defines the new API and plumbs the attributes parameter through
      to the memory.c public level functions io_mem_read() and io_mem_write(),
      where it is currently dummied out.
      
      The success/failure response indication is also propagated out to
      io_mem_read() and io_mem_write(), which retain the old-style
      boolean true-for-error return.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      cc05c43a
  20. 17 3月, 2015 1 次提交
  21. 12 2月, 2015 1 次提交
  22. 11 2月, 2015 1 次提交
  23. 02 2月, 2015 3 次提交