All of lore.kernel.org
 help / color / mirror / Atom feed
From: Honglei Huang <honghuan@amd.com>
To: <alex.bennee@linaro.org>, <dmitry.osipenko@collabora.com>,
	<odaki@rsg.ci.i.u-tokyo.ac.jp>, <Ray.Huang@amd.com>
Cc: <mst@redhat.com>, <cohuck@redhat.com>, <pbonzini@redhat.com>,
	<qemu-devel@nongnu.org>, <honghuan@amd.com>
Subject: [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs
Date: Thu, 3 Dec 2026 09:43:52 +0800	[thread overview]
Message-ID: <20261203014352.1792475-6-honghuan@amd.com> (raw)
In-Reply-To: <20261203014352.1792475-1-honghuan@amd.com>

Advertise VIRTIO_GPU_F_BLOB_READONLY whenever blob resources are
enabled. The flag is generic: VIRTIO_GPU_BLOB_FLAG_USE_READONLY is
passed to the renderer with the other blob flags, and each context type
decides how to honour it.

Reject a CREATE_BLOB request that sets the flag without negotiating the
feature in the 2D, virgl and rutabaga backends.

Signed-off-by: Honglei Huang <honghuan@amd.com>
---
 hw/display/virtio-gpu-base.c     | 1 +
 hw/display/virtio-gpu-rutabaga.c | 7 +++++++
 hw/display/virtio-gpu-virgl.c    | 7 +++++++
 hw/display/virtio-gpu.c          | 7 +++++++
 4 files changed, 22 insertions(+)

diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 270fbaae102..f699648b9d5 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -269,6 +269,7 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,
     }
     if (virtio_gpu_blob_enabled(g->conf)) {
         features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB);
+        features |= (1 << VIRTIO_GPU_F_BLOB_READONLY);
     }
     if (virtio_gpu_context_init_enabled(g->conf)) {
         features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT);
diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutabaga.c
index 1312a67d701..3cff87e25b8 100644
--- a/hw/display/virtio-gpu-rutabaga.c
+++ b/hw/display/virtio-gpu-rutabaga.c
@@ -633,6 +633,13 @@ rutabaga_cmd_resource_create_blob(VirtIOGPU *g,
     VIRTIO_GPU_FILL_CMD(cblob);
     trace_virtio_gpu_cmd_res_create_blob(cblob.resource_id, cblob.size);
 
+    if ((cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_READONLY) &&
+        !virtio_vdev_has_feature(VIRTIO_DEVICE(g),
+                                VIRTIO_GPU_F_BLOB_READONLY)) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+        return;
+    }
+
     CHECK(cblob.resource_id != 0, cmd);
 
     res = virtio_gpu_simple_resource_new_blob(cblob.resource_id, cblob.size);
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index f3512337d05..be38fc59cf2 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -866,6 +866,13 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *g,
     virtio_gpu_create_blob_bswap(&cblob);
     trace_virtio_gpu_cmd_res_create_blob(cblob.resource_id, cblob.size);
 
+    if ((cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_READONLY) &&
+        !virtio_vdev_has_feature(VIRTIO_DEVICE(g),
+                                VIRTIO_GPU_F_BLOB_READONLY)) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+        return;
+    }
+
     if (cblob.resource_id == 0) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",
                       __func__);
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 79968dcf12f..4e05f1305e5 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -368,6 +368,13 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g,
     virtio_gpu_create_blob_bswap(&cblob);
     trace_virtio_gpu_cmd_res_create_blob(cblob.resource_id, cblob.size);
 
+    if ((cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_READONLY) &&
+        !virtio_vdev_has_feature(VIRTIO_DEVICE(g),
+                                VIRTIO_GPU_F_BLOB_READONLY)) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+        return;
+    }
+
     if (cblob.resource_id == 0) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",
                       __func__);
-- 
2.34.1



      parent reply	other threads:[~2026-12-03  1:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  1:43 [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Honglei Huang
2026-12-03  1:43 ` [RFC PATCH v8 1/5] linux-headers: Update to v7.4-rc2-userptr-v11 for ROCm capset (!UPSTREAM) Honglei Huang
2026-12-03  1:43 ` [RFC PATCH v8 2/5] virtio-gpu: Add ROCm capability support Honglei Huang
2026-12-03  1:43 ` [RFC PATCH v8 3/5] virtio-gpu: remove the artificial IOV mapping limit Honglei Huang
2026-12-03  1:43 ` [RFC PATCH v8 4/5] linux-headers: Update to v7.4-rc2-userptr-v11 for readonly blob (!UPSTREAM) Honglei Huang
2026-12-03  1:43 ` Honglei Huang [this message]

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=20261203014352.1792475-6-honghuan@amd.com \
    --to=honghuan@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=alex.bennee@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=mst@redhat.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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.