1. 29 May, 2016 4 commits
  2. 23 May, 2016 4 commits
  3. 19 May, 2016 1 commit
  4. 22 Mar, 2016 1 commit
    • Markus Armbruster's avatar
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster authored
      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: 's avatarMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  5. 14 Mar, 2016 2 commits
  6. 07 Mar, 2016 5 commits
  7. 01 Mar, 2016 2 commits
  8. 25 Feb, 2016 2 commits
    • Gonglei's avatar
      memory: optimize qemu_get_ram_ptr and qemu_ram_ptr_length · 3655cb9c
      Gonglei authored
      these two functions consume too much cpu overhead to
      find the RAMBlock by ram address.
      
      After this patch, we can pass the RAMBlock pointer
      to them so that they don't need to find the RAMBlock
      anymore most of the time. We can get better performance
      in address translation processing.
      Signed-off-by: 's avatarGonglei <arei.gonglei@huawei.com>
      Message-Id: <1455935721-8804-3-git-send-email-arei.gonglei@huawei.com>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      3655cb9c
    • Gonglei's avatar
      exec: store RAMBlock pointer into memory region · 58eaa217
      Gonglei authored
      Each RAM memory region has a unique corresponding RAMBlock.
      In the current realization, the memory region only stored
      the ram_addr which means the offset of RAM address space,
      We need to qurey the global ram.list to find the ram block
      by ram_addr if we want to get the ram block, which is very
      expensive.
      
      Now, we store the RAMBlock pointer into memory region
      structure. So, if we know the mr, we can easily get the
      RAMBlock.
      Signed-off-by: 's avatarGonglei <arei.gonglei@huawei.com>
      Message-Id: <1456130097-4208-2-git-send-email-arei.gonglei@huawei.com>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      58eaa217
  9. 08 Feb, 2016 2 commits
    • Eric Blake's avatar
      qom: Swap 'name' next to visitor in ObjectPropertyAccessor · d7bce999
      Eric Blake authored
      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: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      d7bce999
    • Eric Blake's avatar
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake authored
      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: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  10. 04 Feb, 2016 1 commit
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      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: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  11. 21 Jan, 2016 1 commit
    • Peter Crosthwaite's avatar
      memory: Add address_space_init_shareable() · f0c02d15
      Peter Crosthwaite authored
      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: 's avatarPeter 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: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Acked-by: 's avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
      f0c02d15
  12. 17 Dec, 2015 6 commits
  13. 12 Nov, 2015 1 commit
  14. 04 Nov, 2015 1 commit
  15. 09 Oct, 2015 1 commit
    • Paolo Bonzini's avatar
      memory: allow destroying a non-empty MemoryRegion · 2e2b8eb7
      Paolo Bonzini authored
      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: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1443689999-12182-2-git-send-email-armbru@redhat.com>
      2e2b8eb7
  16. 05 Oct, 2015 1 commit
    • David Gibson's avatar
      memory: Allow replay of IOMMU mapping notifications · a788f227
      David Gibson authored
      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: 's avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: 's avatarLaurent Vivier <lvivier@redhat.com>
      Acked-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: 's avatarAlex Williamson <alex.williamson@redhat.com>
      a788f227
  17. 18 Sep, 2015 1 commit
  18. 13 Aug, 2015 1 commit
  19. 27 Jul, 2015 1 commit
    • Paolo Bonzini's avatar
      memory: do not add a reference to the owner of aliased regions · 52c91dac
      Paolo Bonzini authored
      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: 's avatarMichael S. Tsirkin <mst@redhat.com>
      Tested-by: 's avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      52c91dac
  20. 24 Jul, 2015 1 commit
  21. 16 Jul, 2015 1 commit
    • Paolo Bonzini's avatar
      memory: fix refcount leak in memory_region_present · c6742b14
      Paolo Bonzini authored
      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: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      c6742b14