All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert Esteve <aesteve@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Xu" <peterx@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	mst@redhat.com, dbassey@redhat.com,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	stefanha@redhat.com, manos.pitsidianakis@linaro.org,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	jasowang@redhat.com, "Laurent Vivier" <lvivier@redhat.com>,
	slp@redhat.com, hi@alyssa.is, stevensd@chromium.org
Subject: [PATCH v13 3/7] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec
Date: Thu, 19 Feb 2026 14:03:30 +0100	[thread overview]
Message-ID: <20260219130334.787858-4-aesteve@redhat.com> (raw)
In-Reply-To: <20260219130334.787858-1-aesteve@redhat.com>

Add SHMEM_MAP/_UNMAP request to the vhost-user
spec documentation.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
 docs/interop/vhost-user.rst | 61 +++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
index 17a68a62eb..ae4ad6f441 100644
--- a/docs/interop/vhost-user.rst
+++ b/docs/interop/vhost-user.rst
@@ -350,6 +350,27 @@ Device state transfer parameters
   In the future, additional phases might be added e.g. to allow
   iterative migration while the device is running.
 
+MMAP request
+^^^^^^^^^^^^
+
++-------+---------+-----------+------------+-----+-------+
+| shmid | padding | fd_offset | shm_offset | len | flags |
++-------+---------+-----------+------------+-----+-------+
+
+:shmid: a 8-bit shared memory region identifier
+
+:fd_offset: a 64-bit offset of this area from the start
+            of the supplied file descriptor
+
+:shm_offset: a 64-bit offset from the start of the
+             pointed shared memory region
+
+:len: a 64-bit size of the memory to map
+
+:flags: a 64-bit value:
+  - 0: Pages are mapped read-only
+  - 1: Pages are mapped read-write
+
 C structure
 -----------
 
@@ -375,6 +396,7 @@ In QEMU the vhost-user message is implemented with the following struct:
           VhostUserInflight inflight;
           VhostUserShared object;
           VhostUserTransferDeviceState transfer_state;
+          VhostUserMMap mmap;
       };
   } QEMU_PACKED VhostUserMsg;
 
@@ -1064,6 +1086,7 @@ Protocol features
   #define VHOST_USER_PROTOCOL_F_XEN_MMAP             17
   #define VHOST_USER_PROTOCOL_F_SHARED_OBJECT        18
   #define VHOST_USER_PROTOCOL_F_DEVICE_STATE         19
+  #define VHOST_USER_PROTOCOL_F_SHMEM                20
 
 Front-end message types
 -----------------------
@@ -1872,6 +1895,44 @@ is sent by the front-end.
   when the operation is successful, or non-zero otherwise. Note that if the
   operation fails, no fd is sent to the backend.
 
+``VHOST_USER_BACKEND_SHMEM_MAP``
+  :id: 9
+  :equivalent ioctl: N/A
+  :request payload: fd and ``struct VhostUserMMap``
+  :reply payload: N/A
+
+  When the ``VHOST_USER_PROTOCOL_F_SHMEM`` protocol feature has been
+  successfully negotiated, this message can be submitted by the backends to
+  advertise a new mapping to be made in a given VIRTIO Shared Memory Region.
+  Upon receiving the message, the front-end will mmap the given fd into the
+  VIRTIO Shared Memory Region with the requested ``shmid``.
+  If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and
+  back-end set the ``VHOST_USER_NEED_REPLY`` flag, the front-end
+  must respond with zero when operation is successfully completed,
+  or non-zero otherwise.
+
+  Mapping over an already existing map is not allowed and requests shall fail.
+  Therefore, the memory range in the request must correspond with a valid,
+  free region of the VIRTIO Shared Memory Region. Also, note that mappings
+  consume resources and that the request can fail when there are no resources
+  available. Lastly, mappings are automatically unmapped by the front-end
+  across device reset operation.
+
+``VHOST_USER_BACKEND_SHMEM_UNMAP``
+  :id: 10
+  :equivalent ioctl: N/A
+  :request payload: ``struct VhostUserMMap``
+  :reply payload: N/A
+
+  When the ``VHOST_USER_PROTOCOL_F_SHMEM`` protocol feature has been
+  successfully negotiated, this message can be submitted by the backends so
+  that the front-end un-mmaps a given range (``shm_offset``, ``len``) in the
+  VIRTIO Shared Memory Region with the requested ``shmid``. Note that the
+  given range shall correspond to the entirety of a valid mapped region.
+  If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and the back-end
+  sets the ``VHOST_USER_NEED_REPLY`` flag, the front-end must respond with
+  zero when operation is successfully completed, or non-zero otherwise.
+
 .. _reply_ack:
 
 VHOST_USER_PROTOCOL_F_REPLY_ACK
-- 
2.52.0



  parent reply	other threads:[~2026-02-19 13:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 13:03 [PATCH v13 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests Albert Esteve
2026-02-19 13:03 ` [PATCH v13 1/7] vhost-user: Add VirtIO Shared Memory map request Albert Esteve
2026-03-04 13:08   ` Stefano Garzarella
2026-03-04 13:31     ` Albert Esteve
2026-02-19 13:03 ` [PATCH v13 2/7] vhost_user.rst: Align VhostUserMsg excerpt members Albert Esteve
2026-03-04 13:10   ` Stefano Garzarella
2026-02-19 13:03 ` Albert Esteve [this message]
2026-02-21 13:54   ` [PATCH v13 3/7] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec Alyssa Ross
2026-03-04  9:46   ` Albert Esteve
2026-03-04 10:23     ` Albert Esteve
2026-03-04 13:11       ` Stefano Garzarella
2026-02-19 13:03 ` [PATCH v13 4/7] vhost_user: Add frontend get_shmem_config command Albert Esteve
2026-03-04 13:12   ` Stefano Garzarella
2026-02-19 13:03 ` [PATCH v13 5/7] vhost_user.rst: Add GET_SHMEM_CONFIG message Albert Esteve
2026-03-04 13:12   ` Stefano Garzarella
2026-02-19 13:03 ` [PATCH v13 6/7] qmp: add shmem feature map Albert Esteve
2026-03-04 13:13   ` Stefano Garzarella
2026-02-19 13:03 ` [PATCH v13 7/7] vhost-user-device: Add shared memory BAR Albert Esteve
2026-03-04 13:26   ` Stefano Garzarella
2026-03-04 14:10     ` Albert Esteve
2026-03-04 13:28 ` [PATCH v13 0/7] vhost-user: Add SHMEM_MAP/UNMAP requests Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260219130334.787858-4-aesteve@redhat.com \
    --to=aesteve@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=dbassey@redhat.com \
    --cc=farosas@suse.de \
    --cc=hi@alyssa.is \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=stevensd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.