* [RFC PATCH v8 1/5] linux-headers: Update to v7.4-rc2-userptr-v11 for ROCm capset (!UPSTREAM)
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 ` Honglei Huang
2026-12-03 1:43 ` [RFC PATCH v8 2/5] virtio-gpu: Add ROCm capability support Honglei Huang
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-12-03 1:43 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
Add VIRTIO_GPU_CAPSET_ROCM to the imported virtio_gpu.h so the device
can advertise the ROCm capability set to the guest.
The kernel series adding it is not merged yet:
https://lore.kernel.org/all/20261202101658.1209083-1-honghuan@amd.com/
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
include/standard-headers/linux/virtio_gpu.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index c67f50f56cd..976bd225875 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -321,6 +321,7 @@ struct virtio_gpu_cmd_submit {
#define VIRTIO_GPU_CAPSET_VENUS 4
#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5
#define VIRTIO_GPU_CAPSET_DRM 6
+#define VIRTIO_GPU_CAPSET_ROCM 10
/* VIRTIO_GPU_CMD_GET_CAPSET_INFO */
struct virtio_gpu_get_capset_info {
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH v8 2/5] virtio-gpu: Add ROCm capability support
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 ` Honglei Huang
2026-12-03 1:43 ` [RFC PATCH v8 3/5] virtio-gpu: remove the artificial IOV mapping limit Honglei Huang
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-12-03 1:43 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
Add support for ROCm (Radeon Open Compute) capability in virtio-gpu.
This enables GPU compute workloads using AMD's ROCm platform through the
virtio-gpu interface.
Changes include:
- Add "rocm" property to virtio-gpu-gl device
- Define VIRTIO_GPU_FLAG_ROCM_ENABLED flag
- Enable VIRGL_RENDERER_USE_ROCM flag when ROCm is enabled
- Add virtio_gpu_rocm_enabled() helper macro
This allows guests to detect and utilize ROCm capabilities through the
virtio-gpu device when the feature is enabled.
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu-gl.c | 2 ++
hw/display/virtio-gpu-virgl.c | 17 +++++++++++++++++
include/hw/virtio/virtio-gpu.h | 3 +++
3 files changed, 22 insertions(+)
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 2b7a41c4664..d1f11a5bb92 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -170,6 +170,8 @@ static const Property virtio_gpu_gl_properties[] = {
VIRTIO_GPU_FLAG_VENUS_ENABLED, false),
DEFINE_PROP_BIT("drm_native_context", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_DRM_ENABLED, false),
+ DEFINE_PROP_BIT("rocm", VirtIOGPU, parent_obj.conf.flags,
+ VIRTIO_GPU_FLAG_ROCM_ENABLED, false),
};
static void virtio_gpu_gl_device_unrealize(DeviceState *qdev)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index f71f287d948..f3512337d05 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -1514,6 +1514,14 @@ static int virtio_gpu_virgl_init(VirtIOGPU *g)
return -EINVAL;
}
}
+ if (virtio_gpu_rocm_enabled(g->parent_obj.conf)) {
+#ifdef VIRGL_RENDERER_USE_ROCM
+ flags |= VIRGL_RENDERER_USE_ROCM;
+#else
+ error_report("rocm requires a ROCm-enabled virglrenderer");
+ return -EINVAL;
+#endif
+ }
#endif
ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs);
@@ -1615,5 +1623,14 @@ GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g)
}
}
+ if (virtio_gpu_rocm_enabled(g->parent_obj.conf)) {
+ virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_ROCM,
+ &capset_max_ver,
+ &capset_max_size);
+ if (capset_max_size) {
+ virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_ROCM);
+ }
+ }
+
return capset_ids;
}
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 631dfc63a4d..3c5119ce0e4 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -112,6 +112,7 @@ enum virtio_gpu_base_conf_flags {
VIRTIO_GPU_FLAG_VENUS_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED,
VIRTIO_GPU_FLAG_DRM_ENABLED,
+ VIRTIO_GPU_FLAG_ROCM_ENABLED,
};
#define virtio_gpu_virgl_enabled(_cfg) \
@@ -136,6 +137,8 @@ enum virtio_gpu_base_conf_flags {
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED))
#define virtio_gpu_drm_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_DRM_ENABLED))
+#define virtio_gpu_rocm_enabled(_cfg) \
+ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_ROCM_ENABLED))
struct virtio_gpu_base_conf {
uint32_t max_outputs;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH v8 3/5] virtio-gpu: remove the artificial IOV mapping limit
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 ` 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 ` [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs Honglei Huang
4 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-12-03 1:43 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
Userptr-backed blobs can require a very large number of
virtio_gpu_mem_entry elements when their pages are not contiguous. The
guest virtio-gpu frontend forwards that entry count and does not impose
the 16384-entry cap previously enforced by
virtio_gpu_create_mapping_iov().
Replace that QEMU-only limit with a check that the entry array size
does not overflow size_t, which can happen on 32-bit hosts. Make the
entry loop counter unsigned like nr_entries so it cannot overflow
either. Keep the existing allocation, copy-size, and DMA mapping checks.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index d248e50abcb..79968dcf12f 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -988,16 +988,14 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
{
struct virtio_gpu_mem_entry *ents;
size_t esize, s;
- int e, v;
+ uint32_t e;
+ int v;
- if (nr_entries > 16384) {
- qemu_log_mask(LOG_GUEST_ERROR,
- "%s: nr_entries is too big (%d > 16384)\n",
+ if (__builtin_mul_overflow(sizeof(*ents), nr_entries, &esize)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: entry count is too large (%u)\n",
__func__, nr_entries);
return -1;
}
-
- esize = sizeof(*ents) * nr_entries;
ents = g_try_malloc(esize);
if (!ents && esize) {
return -1;
@@ -1030,7 +1028,7 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
MEMTXATTRS_UNSPECIFIED);
if (!map) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for"
- " element %d\n", __func__, e);
+ " element %u\n", __func__, e);
goto err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH v8 4/5] linux-headers: Update to v7.4-rc2-userptr-v11 for readonly blob (!UPSTREAM)
2026-12-03 1:43 [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Honglei Huang
` (2 preceding siblings ...)
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 ` Honglei Huang
2026-12-03 1:43 ` [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs Honglei Huang
4 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-12-03 1:43 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
Add VIRTIO_GPU_F_BLOB_READONLY and VIRTIO_GPU_BLOB_FLAG_USE_READONLY
to the imported virtio-gpu header.
The kernel series adding them is not merged yet:
https://lore.kernel.org/all/20261202101658.1209083-1-honghuan@amd.com/
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
include/standard-headers/linux/virtio_gpu.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index 976bd225875..95819d4a24c 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -72,6 +72,10 @@
* must be aligned to that value.
*/
#define VIRTIO_GPU_F_BLOB_ALIGNMENT 5
+/*
+ * VIRTIO_GPU_BLOB_FLAG_USE_READONLY
+ */
+#define VIRTIO_GPU_F_BLOB_READONLY 6
enum virtio_gpu_ctrl_type {
VIRTIO_GPU_UNDEFINED = 0,
@@ -415,6 +419,7 @@ struct virtio_gpu_resource_create_blob {
#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
+#define VIRTIO_GPU_BLOB_FLAG_USE_READONLY 0x0008
/* zero is invalid blob mem */
uint32_t blob_mem;
uint32_t blob_flags;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs
2026-12-03 1:43 [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Honglei Huang
` (3 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-12-03 1:43 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
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
^ permalink raw reply related [flat|nested] 6+ messages in thread