Skip to content
Snippets Groups Projects
  1. Feb 17, 2017
  2. Jan 31, 2017
  3. Jan 27, 2017
  4. Jan 10, 2017
  5. Oct 31, 2016
    • Alex Williamson's avatar
      memory: Don't use memcpy for ram_device regions · 4a2e242b
      Alex Williamson authored
      
      With a vfio assigned device we lay down a base MemoryRegion registered
      as an IO region, giving us read & write accessors.  If the region
      supports mmap, we lay down a higher priority sub-region MemoryRegion
      on top of the base layer initialized as a RAM device pointer to the
      mmap.  Finally, if we have any quirks for the device (ie. address
      ranges that need additional virtualization support), we put another IO
      sub-region on top of the mmap MemoryRegion.  When this is flattened,
      we now potentially have sub-page mmap MemoryRegions exposed which
      cannot be directly mapped through KVM.
      
      This is as expected, but a subtle detail of this is that we end up
      with two different access mechanisms through QEMU.  If we disable the
      mmap MemoryRegion, we make use of the IO MemoryRegion and service
      accesses using pread and pwrite to the vfio device file descriptor.
      If the mmap MemoryRegion is enabled and results in one of these
      sub-page gaps, QEMU handles the access as RAM, using memcpy to the
      mmap.  Using either pread/pwrite or the mmap directly should be
      correct, but using memcpy causes us problems.  I expect that not only
      does memcpy not necessarily honor the original width and alignment in
      performing a copy, but it potentially also uses processor instructions
      not intended for MMIO spaces.  It turns out that this has been a
      problem for Realtek NIC assignment, which has such a quirk that
      creates a sub-page mmap MemoryRegion access.
      
      To resolve this, we disable memory_access_is_direct() for ram_device
      regions since QEMU assumes that it can use memcpy for those regions.
      Instead we access through MemoryRegionOps, which replaces the memcpy
      with simple de-references of standard sizes to the host memory.
      
      With this patch we attempt to provide unrestricted access to the RAM
      device, allowing byte through qword access as well as unaligned
      access.  The assumption here is that accesses initiated by the VM are
      driven by a device specific driver, which knows the device
      capabilities.  If unaligned accesses are not supported by the device,
      we don't want them to work in a VM by performing multiple aligned
      accesses to compose the unaligned access.  A down-side of this
      philosophy is that the xp command from the monitor attempts to use
      the largest available access weidth, unaware of the underlying
      device.  Using memcpy had this same restriction, but at least now an
      operator can dump individual registers, even if blocks of device
      memory may result in access widths beyond the capabilities of a
      given device (RTL NICs only support up to dword).
      
      Reported-by: default avatarThorsten Kohfeldt <thorsten.kohfeldt@gmx.de>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4a2e242b
    • Alex Williamson's avatar
      memory: Replace skip_dump flag with "ram_device" · 21e00fa5
      Alex Williamson authored
      
      Setting skip_dump on a MemoryRegion allows us to modify one specific
      code path, but the restriction we're trying to address encompasses
      more than that.  If we have a RAM MemoryRegion backed by a physical
      device, it not only restricts our ability to dump that region, but
      also affects how we should manipulate it.  Here we recognize that
      MemoryRegions do not change to sometimes allow dumps and other times
      not, so we replace setting the skip_dump flag with a new initializer
      so that we know exactly the type of region to which we're applying
      this behavior.
      
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      21e00fa5
  6. Oct 24, 2016
  7. Sep 27, 2016
    • Paolo Bonzini's avatar
      migration: sync all address spaces · 9c1f8f44
      Paolo Bonzini authored
      
      Migrating a VM during reboot sometimes results in differences
      between the source and destination in the SMRAM area.
      
      This is because migration_bitmap_sync() only fetches from KVM
      the dirty log of address_space_memory.  SMRAM memory slots
      are ignored and the modifications to SMRAM are not sent to the
      destination.
      
      Reported-by: default avatarHe Rongguang <herongguang.he@huawei.com>
      Reviewed-by: default avatarHe Rongguang <herongguang.he@huawei.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9c1f8f44
    • Peter Xu's avatar
      memory: introduce IOMMUOps.notify_flag_changed · 5bf3d319
      Peter Xu authored
      
      The new interface can be used to replace the old notify_started() and
      notify_stopped(). Meanwhile it provides explicit flags so that IOMMUs
      can know what kind of notifications it is requested for.
      
      Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <1474606948-14391-3-git-send-email-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5bf3d319
    • Peter Xu's avatar
      memory: introduce IOMMUNotifier and its caps · cdb30812
      Peter Xu authored
      
      IOMMU Notifier list is used for notifying IO address mapping changes.
      Currently VFIO is the only user.
      
      However it is possible that future consumer like vhost would like to
      only listen to part of its notifications (e.g., cache invalidations).
      
      This patch introduced IOMMUNotifier and IOMMUNotfierFlag bits for a
      finer grained control of it.
      
      IOMMUNotifier contains a bitfield for the notify consumer describing
      what kind of notification it is interested in. Currently two kinds of
      notifications are defined:
      
      - IOMMU_NOTIFIER_MAP:    for newly mapped entries (additions)
      - IOMMU_NOTIFIER_UNMAP:  for entries to be removed (cache invalidates)
      
      When registering the IOMMU notifier, we need to specify one or multiple
      types of messages to listen to.
      
      When notifications are triggered, its type will be checked against the
      notifier's type bits, and only notifiers with registered bits will be
      notified.
      
      (For any IOMMU implementation, an in-place mapping change should be
       notified with an UNMAP followed by a MAP.)
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <1474606948-14391-2-git-send-email-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cdb30812
  8. Sep 14, 2016
  9. Jul 04, 2016
    • Peter Maydell's avatar
      memory: Assert that memory_region_init_rom_device() ops aren't NULL · 39e0b03d
      Peter Maydell authored
      
      It doesn't make sense to pass a NULL ops argument to
      memory_region_init_rom_device(), because the effect will
      be that if the guest tries to write to the memory region
      then QEMU will segfault. Catch the bug earlier by sanity
      checking the arguments to this function, and remove the
      misleading documentation that suggests that passing NULL
      might be sensible.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1467122287-24974-4-git-send-email-peter.maydell@linaro.org
      39e0b03d
    • Peter Maydell's avatar
      memory: Provide memory_region_init_rom() · a1777f7f
      Peter Maydell authored
      
      Provide a new helper function memory_region_init_rom() for memory
      regions which are read-only (and unlike those created by
      memory_region_init_rom_device() don't have special behaviour
      for writes). This has the same behaviour as calling
      memory_region_init_ram() and then memory_region_set_readonly()
      (which is what we do today in boards with pure ROMs) but is a
      more easily discoverable API for the purpose.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1467122287-24974-2-git-send-email-peter.maydell@linaro.org
      a1777f7f
  10. Jun 30, 2016
  11. Jun 22, 2016
  12. May 29, 2016
  13. May 23, 2016
  14. May 19, 2016
  15. Mar 22, 2016
    • 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: default avatarMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  16. Mar 14, 2016
  17. Mar 07, 2016
  18. Mar 01, 2016
  19. Feb 25, 2016
Loading