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 2/3] virtio-gpu: introduce BLOB_CTX_ID_FIX feature
Date: Tue, 24 Nov 2026 18:19:28 -0300 [thread overview]
Message-ID: <20261124211931.809982-3-val@invisiblethingslab.com> (raw)
In-Reply-To: <20261124211931.809982-1-val@invisiblethingslab.com>
virtio-gpu device backends typically use ctx_id to route commands to
different modules that implement distinct context types, e.g.
virglrenderer vs. cross-domain. Each module may require the blob
resources intented to use with it to be allocated through it as well.
Currently, this happens for host-only and default blobs which are
allocated from a context-specific local blob_id (e.g. an image
requirements blob in cross-domain). For guest-only resources however,
existing software (both the Linux kernel and the rutabaga-gfx library
used by device backends to implement virtio-gpu) allocates those with
ctx_id == 0, which might be a different "default" context type from the
one the resource is intended to be used with, e.g. when both
virglrenderer and cross-domain are present, the socket buffers used by
cross-domain were processed by virglrenderer which happens to work
but does not actually make sense.
Additionally we would like to support PRIME imported resources (udmabufs
or dGPU passthrough dma-bufs) being passed over cross-domain with the
CREATE_GUEST_HANDLE feature which, due to kernel constraints, must also
perform the creation of a guest-only blob resource with ctx_id but
without blob_id.
Unfortunately changing this without breaking backwards compatibility
requires a flag to negotiate the use of the "fixed" convention. Otherwise
new guest kernel + old rutabaga would result in the command failing due
to old rutabaga not expecting guest resources to be allocated w/ ctx_id.
Signed-off-by: Val Packett <val@invisiblethingslab.com>
---
device-types/gpu/description.tex | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/device-types/gpu/description.tex b/device-types/gpu/description.tex
index ea6fae4667e1..63e600bd04e8 100644
--- a/device-types/gpu/description.tex
+++ b/device-types/gpu/description.tex
@@ -39,6 +39,9 @@ \subsection{Feature bits}\label{sec:Device Types / GPU Device / Feature bits}
synchronization timelines supported. Requires VIRTIO_GPU_F_VIRGL.
\item[VIRTIO_GPU_F_BLOB_ALIGNMENT (5)] configuration field
\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.
\end{description}
\subsection{Device configuration layout}\label{sec:Device Types / GPU Device / Device configuration layout}
@@ -669,6 +672,12 @@ \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_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
+be filled when the \field{blob_id} has been filled to create a resource
+from a context local object.
+
The driver MUST inform the device if the blob resource is used for
memory access, sharing between driver instances and/or sharing with
other devices. This is done via the \field{blob_flags} field:
--
2.56.0
next prev 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 ` Val Packett [this message]
2026-11-24 21:19 ` [PATCH v3 3/3] virtio-gpu: introduce BLOB_GUEST_SHAREABLE feature Val Packett
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-3-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