Skip to content
Snippets Groups Projects
  1. Dec 08, 2020
  2. Nov 17, 2020
  3. Nov 16, 2020
  4. Nov 12, 2020
    • Stefan Hajnoczi's avatar
      vhost-user: fix VHOST_USER_ADD/REM_MEM_REG truncation · 3009edff
      Stefan Hajnoczi authored
      
      QEMU currently truncates the mmap_offset field when sending
      VHOST_USER_ADD_MEM_REG and VHOST_USER_REM_MEM_REG messages. The struct
      layout looks like this:
      
        typedef struct VhostUserMemoryRegion {
            uint64_t guest_phys_addr;
            uint64_t memory_size;
            uint64_t userspace_addr;
            uint64_t mmap_offset;
        } VhostUserMemoryRegion;
      
        typedef struct VhostUserMemRegMsg {
            uint32_t padding;
            /* WARNING: there is a 32-bit hole here! */
            VhostUserMemoryRegion region;
        } VhostUserMemRegMsg;
      
      The payload size is calculated as follows when sending the message in
      hw/virtio/vhost-user.c:
      
        msg->hdr.size = sizeof(msg->payload.mem_reg.padding) +
            sizeof(VhostUserMemoryRegion);
      
      This calculation produces an incorrect result of only 36 bytes.
      sizeof(VhostUserMemRegMsg) is actually 40 bytes.
      
      The consequence of this is that the final field, mmap_offset, is
      truncated. This breaks x86_64 TCG guests on s390 hosts. Other guest/host
      combinations may get lucky if either of the following holds:
      1. The guest memory layout does not need mmap_offset != 0.
      2. The host is little-endian and mmap_offset <= 0xffffffff so the
         truncation has no effect.
      
      Fix this by extending the existing 32-bit padding field to 64-bit. Now
      the padding reflects the actual compiler padding. This can be verified
      using pahole(1).
      
      Also document the layout properly in the vhost-user specification.  The
      vhost-user spec did not document the exact layout. It would be
      impossible to implement the spec without looking at the QEMU source
      code.
      
      Existing vhost-user frontends and device backends continue to work after
      this fix has been applied. The only change in the wire protocol is that
      QEMU now sets hdr.size to 40 instead of 36. If a vhost-user
      implementation has a hardcoded size check for 36 bytes, then it will
      fail with new QEMUs. Both QEMU and DPDK/SPDK don't check the exact
      payload size, so they continue to work.
      
      Fixes: f1aeb14b ("Transmit vhost-user memory regions individually")
      Cc: Raphael Norwitz <raphael.norwitz@nutanix.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20201109174355.1069147-1-stefanha@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Fixes: f1aeb14b ("Transmit vhost-user memory regions individually")
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarRaphael Norwitz <raphael.norwitz@nutanix.com>
      3009edff
  5. Nov 03, 2020
  6. Oct 27, 2020
  7. Oct 26, 2020
  8. Oct 23, 2020
  9. Oct 09, 2020
  10. Sep 29, 2020
  11. Sep 23, 2020
    • Stefan Hajnoczi's avatar
      qemu/atomic.h: rename atomic_ to qatomic_ · d73415a3
      Stefan Hajnoczi authored
      
      clang's C11 atomic_fetch_*() functions only take a C11 atomic type
      pointer argument. QEMU uses direct types (int, etc) and this causes a
      compiler error when a QEMU code calls these functions in a source file
      that also included <stdatomic.h> via a system header file:
      
        $ CC=clang CXX=clang++ ./configure ... && make
        ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
      
      Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
      used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
      and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
      searched GitHub for existing "qatomic_" users but there seem to be none.
      
      This patch was generated using:
      
        $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
          sort -u >/tmp/changed_identifiers
        $ for identifier in $(</tmp/changed_identifiers); do
              sed -i "s%\<$identifier\>%q$identifier%g" \
                  $(git grep -I -l "\<$identifier\>")
          done
      
      I manually fixed line-wrap issues and misaligned rST tables.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
      d73415a3
    • Marc Hartmayer's avatar
      libvhost-user: handle endianness as mandated by the spec · 2ffc5470
      Marc Hartmayer authored
      Since virtio existed even before it got standardized, the virtio
      standard defines the following types of virtio devices:
      
       + legacy device (pre-virtio 1.0)
       + non-legacy or VIRTIO 1.0 device
       + transitional device (which can act both as legacy and non-legacy)
      
      Virtio 1.0 defines the fields of the virtqueues as little endian,
      while legacy uses guest's native endian [1]. Currently libvhost-user
      does not handle virtio endianness at all, i.e. it works only if the
      native endianness matches with whatever is actually needed. That means
      things break spectacularly on big-endian targets. Let us handle virtio
      endianness for non-legacy as required by the virtio specification [1]
      and fence legacy virtio, as there is no safe way to figure out the
      needed endianness conversions for all cases. The fencing of legacy
      virtio devices is done in `vu_set_features_exec`.
      
      [1] https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-210003
      
      
      
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMarc Hartmayer <mhartmay@linux.ibm.com>
      Message-id: 20200901150019.29229-3-mhartmay@linux.ibm.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      2ffc5470
  12. Sep 17, 2020
  13. Sep 10, 2020
    • Alex Bennée's avatar
      plugins: move the more involved plugins to contrib · c17a386b
      Alex Bennée authored
      
      We have an exploding complexity problem in the testing so lets just
      move the more involved plugins into contrib. tests/plugins still exist
      for the basic plugins that exercise the API. We restore the old
      pre-meson style Makefile for contrib as it also doubles as a guide for
      out-of-tree plugin builds.
      
      While we are at it add some examples to the documentation and a
      specific plugins build target.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <20200909112742.25730-11-alex.bennee@linaro.org>
      c17a386b
  14. Sep 01, 2020
  15. Aug 27, 2020
  16. Aug 21, 2020
Loading