Discussion of the VIRTIO specification
 help / color / mirror / Atom feed
From: Val Packett <val@invisiblethingslab.com>
To: virtio-comment@lists.linux.dev
Cc: "Val Packett" <val@invisiblethingslab.com>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Sergio Lopez" <slp@redhat.com>,
	"Parav Pandit" <parav@nvidia.com>,
	dmitry.osipenko@collabora.com, mst@redhat.com,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Alyssa Ross" <hi@alyssa.is>,
	"Demi Marie Obenour" <demiobenour@gmail.com>
Subject: [PATCH v3 3/3] virtio-gpu: introduce BLOB_GUEST_SHAREABLE feature
Date: Tue, 24 Nov 2026 18:19:29 -0300	[thread overview]
Message-ID: <20261124211931.809982-4-val@invisiblethingslab.com> (raw)
In-Reply-To: <20261124211931.809982-1-val@invisiblethingslab.com>

So far, desktop integration over VIRTIO_GPU_CAPSET_CROSS_DOMAIN has
relied on host-only blob resources, which are always backed by a
shareable object on the host side (such as a memfd or a DMA-BUF).

However, to access such resources the guest needs to use the
VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB command which is currently only
available when a VIRTIO_GPU_SHM_ID_HOST_VISIBLE shared memory region
exists, which is not possible in all environments (e.g. under Xen).

Also, this necessarily introduces copying for software-rendered client
buffers. The Wayland protocol makes clients responsible for allocating
their SHM buffer pools, which are ordinary guest kernel shared temporary
file objects (memfds). The only way to bridge those and host-only buffers
is a copy on every content update.

Host-only resources with the HOST_VISIBLE region were picked as the
default solution because it's easy to implement with KVM. However with
the introduction of the udmabuf driver, it also became possible to create
shareable handles (namely DMA-BUFs) for specific subranges of various
memfd objects (which can be the backing objects for a KVM guest's RAM).
And on the Xen side, gntdev-dmabuf provides a similar operation for
Xen grant references. With these capabilities, it should be possible
to use guest-only blob resources as well.

The udmabuf driver can also be used in the guest to complete the Wayland
SHM zero-copy fast path. A memfd allocated by an ordinary client,
completely unaware of virtualization, can be turned into a DMA-BUF (as
long as some conditions hold) which can be imported into the virtio-gpu
device. With the new feature VIRTIO_GPU_F_BLOB_GUEST_SHAREABLE, it is
possible to use the VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE flag (previously
only available for host-only resources) to indicate to the host that the
resource should be shareable between contexts (therefore, importable
into the cross-domain context). In practice that would imply that the
provided memory range entries would be used to construct a corresponding
DMA-BUF on the host side, which the cross-domain context would send over
to the host Wayland compositor.

Such resources can also be used for scanout, e.g. when a guest
compositor wants to directly scan out a full-screen
software-rendered application.

Signed-off-by: Val Packett <val@invisiblethingslab.com>
---
 device-types/gpu/description.tex | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/device-types/gpu/description.tex b/device-types/gpu/description.tex
index 63e600bd04e8..9c1ccd854f6a 100644
--- a/device-types/gpu/description.tex
+++ b/device-types/gpu/description.tex
@@ -41,7 +41,10 @@ \subsection{Feature bits}\label{sec:Device Types / GPU Device / Feature bits}
   \field{blob_alignment} is valid. Requires VIRTIO_GPU_F_RESOURCE_BLOB.
 \item[VIRTIO_GPU_F_BLOB_CTX_ID_FIX (6)] it is always safe to pass the
   current context ID to VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB,
-  including for guest-only blobs.
+  including for guest-only blobs. Requires VIRTIO_GPU_F_RESOURCE_BLOB.
+\item[VIRTIO_GPU_F_BLOB_GUEST_SHAREABLE (7)] guest-only blob resources
+  may be created with the VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE flag.
+  Requires VIRTIO_GPU_F_BLOB_CTX_ID_FIX.
 \end{description}
 
 \subsection{Device configuration layout}\label{sec:Device Types / GPU Device / Device configuration layout}
@@ -672,6 +675,10 @@ \subsubsection{Device Operation: controlq}\label{sec:Device Types / GPU Device /
 identified by the \field{blob_id}. The actual allocation is done via
 VIRTIO_GPU_CMD_SUBMIT_3D.
 
+If VIRTIO_GPU_F_BLOB_GUEST_SHAREABLE has been negotiated, guest-only
+(VIRTIO_GPU_BLOB_MEM_GUEST) resources MAY also be created from the
+context local object identified by the \field{blob_id}.
+
 If VIRTIO_GPU_F_BLOB_CTX_ID_FIX has been negotiated, the \field{ctx_id} of
 the \field{hdr} MUST always be filled in with the ID of the default context
 associated with the current handle, if one exists. Otherwise, it MUST only
@@ -690,7 +697,8 @@ \subsubsection{Device Operation: controlq}\label{sec:Device Types / GPU Device /
   \item VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE indicates that the resource may be
   shared between multiple virtio-gpu contexts. The device MAY only support this
   flag with certain values of \field{blob_mem}; historically, this has only
-  worked with host-only blobs.
+  worked with host-only blobs. If VIRTIO_GPU_F_BLOB_GUEST_SHAREABLE has been
+  negotiated, this flag MUST be supported with guest-only blobs as well.
   \item VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE indicates that the resource may
   be shared with other virtio devices via VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID.
   The device MAY only support this flag with certain values of \field{blob_mem}.
-- 
2.56.0


  parent reply	other threads:[~2026-11-24 21:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 21:19 [PATCH v3 0/3] virtio-gpu: add F_BLOB_GUEST_SHAREABLE (ex CREATE_GUEST_HANDLE) and F_BLOB_CTX_ID_FIX Val Packett
2026-11-24 21:19 ` [PATCH v3 1/3] virtio-gpu: document individual blob_flags Val Packett
2026-11-24 21:19 ` [PATCH v3 2/3] virtio-gpu: introduce BLOB_CTX_ID_FIX feature Val Packett
2026-11-24 21:19 ` Val Packett [this message]
2026-11-24 22:44 ` [PATCH v3 0/3] virtio-gpu: add F_BLOB_GUEST_SHAREABLE (ex CREATE_GUEST_HANDLE) and F_BLOB_CTX_ID_FIX Demi Marie Obenour

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=20261124211931.809982-4-val@invisiblethingslab.com \
    --to=val@invisiblethingslab.com \
    --cc=demiobenour@gmail.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=gurchetansingh@chromium.org \
    --cc=hi@alyssa.is \
    --cc=marmarek@invisiblethingslab.com \
    --cc=mst@redhat.com \
    --cc=parav@nvidia.com \
    --cc=slp@redhat.com \
    --cc=virtio-comment@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox