1. 19 5月, 2016 1 次提交
  2. 10 2月, 2016 4 次提交
  3. 07 2月, 2016 1 次提交
    • S
      fix MSI injection on Xen · 428c3ece
      Stefano Stabellini 提交于
      On Xen MSIs can be remapped into pirqs, which are a type of event
      channels. It's mostly for the benefit of PCI passthrough devices, to
      avoid the overhead of interacting with the emulated lapic.
      
      However remapping interrupts and MSIs is also supported for emulated
      devices, such as the e1000 and virtio-net.
      
      When an interrupt or an MSI is remapped into a pirq, masking and
      unmasking is done by masking and unmasking the event channel. The
      masking bit on the PCI config space or MSI-X table should be ignored,
      but it isn't at the moment.
      
      As a consequence emulated devices which use MSI or MSI-X, such as
      virtio-net, don't work properly (the guest doesn't receive any
      notifications). The mechanism was working properly when xen_apic was
      introduced, but I haven't narrowed down which commit in particular is
      causing the regression.
      
      Fix the issue by ignoring the masking bit for MSI and MSI-X which have
      been remapped into pirqs.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      428c3ece
  4. 29 1月, 2016 1 次提交
    • P
      xen: Clean up includes · 21cbfe5f
      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: 1453832250-766-14-git-send-email-peter.maydell@linaro.org
      21cbfe5f
  5. 27 1月, 2016 3 次提交
    • I
      xen: Switch uses of xc_map_foreign_{pages,bulk} to use libxenforeignmemory API. · e0cb42ae
      Ian Campbell 提交于
      In Xen 4.7 we are refactoring parts libxenctrl into a number of
      separate libraries which will provide backward and forward API and ABI
      compatiblity.
      
      One such library will be libxenforeignmemory which provides access to
      privileged foreign mappings and which will provide an interface
      equivalent to xc_map_foreign_{pages,bulk}.
      
      The new xenforeignmemory_map() function behaves like
      xc_map_foreign_pages() when the err argument is NULL and like
      xc_map_foreign_bulk() when err is non-NULL, which maps into the shim
      here onto checking err == NULL and calling the appropriate old
      function.
      
      Note that xenforeignmemory_map() takes the number of pages before the
      arrays themselves, in order to support potentially future use of
      variable-length-arrays in the prototype (in the future, when Xen's
      baseline toolchain requirements are new enough to ensure VLAs are
      supported).
      
      In preparation for adding support for libxenforeignmemory add support
      to the <=4.0 and <=4.6 compat code in xen_common.h to allow us to
      switch to using the new API. These shims will disappear for versions
      of Xen which include libxenforeignmemory.
      
      Since libxenforeignmemory will have its own handle type but for <= 4.6
      the functionality is provided by using a libxenctrl handle we
      introduce a new global xen_fmem alongside the existing xen_xc. In fact
      we make xen_fmem a pointer to the existing xen_xc, which then works
      correctly with both <=4.0 (xc handle is an int) and <=4.6 (xc handle
      is a pointer). In the latter case xen_fmem is actually a double
      indirect pointer, but it all falls out in the wash.
      
      Unlike libxenctrl libxenforeignmemory has an explicit unmap function,
      rather than just specifying that munmap should be used, so the unmap
      paths are updated to use xenforeignmemory_unmap, which is a shim for
      munmap on these versions of xen. The mappings in xen-hvm.c do not
      appear to be unmapped (which makes sense for a qemu-dm process)
      
      In fb_disconnect this results in a change from simply mmap over the
      existing mapping (with an implicit munmap) to expliclty unmapping with
      xenforeignmemory_unmap and then mapping the required anonymous memory
      in the same hole. I don't think this is a problem since any other
      thread which was racily touching this region would already be running
      the risk of hitting the mapping halfway through the call. If this is
      thought to be a problem then we could consider adding an extra API to
      the libxenforeignmemory interface to replace a foreign mapping with
      anonymous shared memory, but I'd prefer not to.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      e0cb42ae
    • I
      xen: Switch uses of xc_map_foreign_range into xc_map_foreign_pages · 9ed257d1
      Ian Campbell 提交于
      In Xen 4.7 we are refactoring parts libxenctrl into a number of
      separate libraries which will provide backward and forward API and ABI
      compatiblity.
      
      One such library will be libxenforeignmemory which provides access to
      privileged foreign mappings and which will provide an interface
      equivalent to xc_map_foreign_{pages,bulk}.
      
      In preparation for this switch all uses of xc_map_foreign_range to
      xc_map_foreign_pages. This is trivial because size was always
      XC_PAGE_SIZE so the necessary adjustments are trivial:
      
        * Pass &mfn (an array of length 1) instead of mfn. The function
          takes a pointer to const, so there is no possibily of mfn changing
          due to this change.
        * Pass nr_pages=1 instead of size=XC_PAGE_SIZE
      
      There is one wrinkle in xen_console.c:con_initialise() where
      con->ring_ref is an int but can in some code paths (when !xendev->dev)
      be treated as an mfn. I think this is an existing latent truncation
      hazard on platforms where xen_pfn_t is 64-bit and int is 32-bit (e.g.
      amd64, both arm* variants). I'm unsure under what circumstances
      xendev->dev can be NULL or if anything elsewhere ensures the value
      fits into an int. For now I just use a temporary xen_pfn_t to in
      effect upcast the pointer from int* to xen_pfn_t*.
      
      In xenfb.c:common_bind we now explicitly launder the mfn into a
      xen_pfn_t, so it has the correct type to be passed to
      xc_map_foreign_pages and doesn't provoke warnings on 32-bit x86.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      9ed257d1
    • I
      xen: Switch to libxenevtchn interface for compat shims. · a2db2a1e
      Ian Campbell 提交于
      In Xen 4.7 we are refactoring parts libxenctrl into a number of
      separate libraries which will provide backward and forward API and ABI
      compatiblity.
      
      One such library will be libxenevtchn which provides access to event
      channels.
      
      In preparation for this switch the compatibility layer in xen_common.h
      (which support building with older versions of Xen) to use what will
      be the new library API. This means that the evtchn shim will disappear
      for versions of Xen which include libxenevtchn.
      
      To simplify things for the <= 4.0.0 support we wrap the int fd in a
      malloc(sizeof int) such that the handle is always a pointer. This
      leads to less typedef headaches and the need for
      XC_HANDLER_INITIAL_VALUE etc for these interfaces.
      
      Note that this patch does not add any support for actually using
      libxenevtchn, it just adjusts the existing shims.
      
      Note that xc_evtchn_alloc_unbound functionality remains in libxenctrl,
      since that functionality is not exposed by /dev/xen/evtchn.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      a2db2a1e
  6. 15 1月, 2016 2 次提交
  7. 13 1月, 2016 1 次提交
  8. 18 9月, 2015 1 次提交
    • M
      Fix bad error handling after memory_region_init_ram() · f8ed85ac
      Markus Armbruster 提交于
      Symptom:
      
          $ qemu-system-x86_64 -m 10000000
          Unexpected error in ram_block_add() at /work/armbru/qemu/exec.c:1456:
          upstream-qemu: cannot set up guest memory 'pc.ram': Cannot allocate memory
          Aborted (core dumped)
      
      Root cause: commit ef701d7b screwed up handling of out-of-memory
      conditions.  Before the commit, we report the error and exit(1), in
      one place, ram_block_add().  The commit lifts the error handling up
      the call chain some, to three places.  Fine.  Except it uses
      &error_abort in these places, changing the behavior from exit(1) to
      abort(), and thus undoing the work of commit 39228250 "exec: Don't
      abort when we can't allocate guest memory".
      
      The three places are:
      
      * memory_region_init_ram()
      
        Commit 49946538 (right after commit ef701d7b) lifted the error
        handling further, through memory_region_init_ram(), multiplying the
        incorrect use of &error_abort.  Later on, imitation of existing
        (bad) code may have created more.
      
      * memory_region_init_ram_ptr()
      
        The &error_abort is still there.
      
      * memory_region_init_rom_device()
      
        Doesn't need fixing, because commit 33e0eb52 (soon after commit
        ef701d7b) lifted the error handling further, and in the process
        changed it from &error_abort to passing it up the call chain.
        Correct, because the callers are realize() methods.
      
      Fix the error handling after memory_region_init_ram() with a
      Coccinelle semantic patch:
      
          @r@
          expression mr, owner, name, size, err;
          position p;
          @@
                  memory_region_init_ram(mr, owner, name, size,
          (
          -                              &error_abort
          +                              &error_fatal
          |
                                         err@p
          )
                                        );
          @script:python@
              p << r.p;
          @@
          print "%s:%s:%s" % (p[0].file, p[0].line, p[0].column)
      
      When the last argument is &error_abort, it gets replaced by
      &error_fatal.  This is the fix.
      
      If the last argument is anything else, its position is reported.  This
      lets us check the fix is complete.  Four positions get reported:
      
      * ram_backend_memory_alloc()
      
        Error is passed up the call chain, ultimately through
        user_creatable_complete().  As far as I can tell, it's callers all
        handle the error sanely.
      
      * fsl_imx25_realize(), fsl_imx31_realize(), dp8393x_realize()
      
        DeviceClass.realize() methods, errors handled sanely further up the
        call chain.
      
      We're good.  Test case again behaves:
      
          $ qemu-system-x86_64 -m 10000000
          qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
          [Exit 1 ]
      
      The next commits will repair the rest of commit ef701d7b's damage.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1441983105-26376-3-git-send-email-armbru@redhat.com>
      Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
      f8ed85ac
  9. 10 9月, 2015 4 次提交
  10. 08 9月, 2015 1 次提交
  11. 24 6月, 2015 1 次提交
    • S
      Revert "xen-hvm: increase maxmem before calling xc_domain_populate_physmap" · ffffbb36
      Stefano Stabellini 提交于
      This reverts commit c1d322e6.
      
      The original commit fixes a bug when assigning a large number of
      devices which require option roms to a guest.  (One known
      configuration that needs extra memory is having more than 4 emulated
      NICs assigned.  Three or fewer NICs seems to work without this
      functionality.)
      
      However, by unilaterally increasing maxmem, it introduces two
      problems.
      
      First, now libxl's calculation of the required maxmem during migration
      is broken -- any guest which exercised this functionality will fail on
      migration.  (Guests which have the default number of devices are not
      affected.)
      
      Secondly, it makes it impossible for a higher-level toolstack or
      administer to predict how much memory a VM will actually use, making
      it much more difficult to effectively use all of the memory on a
      machine.
      Signed-off-by: NGeorge Dunlap <george.dunlap@eu.citrix.com>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      ffffbb36
  12. 05 6月, 2015 2 次提交
    • P
      memory: prepare for multiple bits in the dirty log mask · b2dfd71c
      Paolo Bonzini 提交于
      When the dirty log mask will also cover other bits than DIRTY_MEMORY_VGA,
      some listeners may be interested in the overall zero/non-zero value of
      the dirty log mask; others may be interested in the value of single bits.
      
      For this reason, always call log_start/log_stop if bits have respectively
      appeared or disappeared, and pass the old and new values of the dirty log
      mask so that listeners can distinguish the kinds of change.
      
      For example, KVM checks if dirty logging used to be completely disabled
      (in log_start) or is now completely disabled (in log_stop).  On the
      other hand, Xen has to check manually if DIRTY_MEMORY_VGA changed,
      since that is the only bit it cares about.
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b2dfd71c
    • P
      memory: differentiate memory_region_is_logging and memory_region_get_dirty_log_mask · 2d1a35be
      Paolo Bonzini 提交于
      For now memory regions only track DIRTY_MEMORY_VGA individually, but
      this will change soon.  To support this, split memory_region_is_logging
      in two functions: one that returns a given bit from dirty_log_mask,
      and one that returns the entire mask.  memory_region_is_logging gets an
      extra parameter so that the compiler flags misuse.
      
      While VGA-specific users (including the Xen listener!) will want to keep
      checking that bit, KVM and vhost check for "any bit except migration"
      (because migration is handled via the global start/stop listener
      callbacks).
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2d1a35be
  13. 20 1月, 2015 1 次提交
  14. 14 1月, 2015 1 次提交
  15. 11 11月, 2014 1 次提交
  16. 30 10月, 2014 1 次提交
  17. 20 9月, 2014 1 次提交
  18. 09 9月, 2014 1 次提交
  19. 28 8月, 2014 2 次提交
  20. 01 8月, 2014 1 次提交
  21. 18 7月, 2014 1 次提交
  22. 07 7月, 2014 1 次提交
  23. 23 6月, 2014 2 次提交
  24. 11 6月, 2014 1 次提交
  25. 08 5月, 2014 2 次提交
  26. 06 5月, 2014 1 次提交
  27. 05 3月, 2014 1 次提交