* [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
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ 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] 10+ 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
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ 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] 10+ 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-04 12:51 ` Alex Bennée
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
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ 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] 10+ messages in thread* Re: [RFC PATCH v8 3/5] virtio-gpu: remove the artificial IOV mapping limit
2026-12-03 1:43 ` [RFC PATCH v8 3/5] virtio-gpu: remove the artificial IOV mapping limit Honglei Huang
@ 2026-12-04 12:51 ` Alex Bennée
0 siblings, 0 replies; 10+ messages in thread
From: Alex Bennée @ 2026-12-04 12:51 UTC (permalink / raw)
To: Honglei Huang
Cc: dmitry.osipenko, odaki, Ray.Huang, mst, cohuck, pbonzini,
qemu-devel
Honglei Huang <honghuan@amd.com> writes:
> 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);
I guess we don't have a size_t equivalent of the [su]mul[32|64]_overflow
in host_utils?
I wonder if it's worth adding? The only other place that uses the
__builtin directly is the pixman code but usually __builtin use is
hidden in compiler.h to deal with potential differences amongst the
compilers we support.
> 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);
If e is uint32_t we should use "%"PRIu32"\n" instead for cleanliness
even though we don't have to deal with 32 bit hosts anymore.
> goto err;
> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 10+ 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-04 12:51 ` Alex Bennée
2026-12-03 1:43 ` [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs Honglei Huang
2026-12-04 6:50 ` [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Huang, Honglei1
5 siblings, 1 reply; 10+ 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] 10+ messages in thread* Re: [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 4/5] linux-headers: Update to v7.4-rc2-userptr-v11 for readonly blob (!UPSTREAM) Honglei Huang
@ 2026-12-04 12:51 ` Alex Bennée
0 siblings, 0 replies; 10+ messages in thread
From: Alex Bennée @ 2026-12-04 12:51 UTC (permalink / raw)
To: Honglei Huang
Cc: dmitry.osipenko, odaki, Ray.Huang, mst, cohuck, pbonzini,
qemu-devel
Honglei Huang <honghuan@amd.com> writes:
> 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/
This should be merged with 1/5 I think.
>
> 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;
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 10+ 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
2026-12-04 6:50 ` [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Huang, Honglei1
5 siblings, 0 replies; 10+ 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] 10+ messages in thread* RE: [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability
2026-12-03 1:43 [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Honglei Huang
` (4 preceding siblings ...)
2026-12-03 1:43 ` [RFC PATCH v8 5/5] virtio-gpu: advertise readonly blobs Honglei Huang
@ 2026-12-04 6:50 ` Huang, Honglei1
2026-12-04 12:56 ` Alex Bennée
5 siblings, 1 reply; 10+ messages in thread
From: Huang, Honglei1 @ 2026-12-04 6:50 UTC (permalink / raw)
To: odaki@rsg.ci.i.u-tokyo.ac.jp, alex.bennee@linaro.org,
dmitry.osipenko@collabora.com
Cc: mst@redhat.com, cohuck@redhat.com, pbonzini@redhat.com,
qemu-devel@nongnu.org, Huang, Ray
AMD General
Hi all,
Please let me know if you have any review comments.
Welcome to any comments.
Regards,
Honglei
-----Original Message-----
From: Huang, Honglei1 <Honglei1.Huang@amd.com>
Sent: Thursday, December 3, 2026 9:44 AM
To: alex.bennee@linaro.org; dmitry.osipenko@collabora.com; odaki@rsg.ci.i.u-tokyo.ac.jp; Huang, Ray <Ray.Huang@amd.com>
Cc: mst@redhat.com; cohuck@redhat.com; pbonzini@redhat.com; qemu-devel@nongnu.org; Huang, Honglei1 <Honglei1.Huang@amd.com>
Subject: [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability
This patch series introduces enhancements to virtio-gpu to improve memory management and GPU virtualization capabilities for ROCm (Radeon Open Compute) workloads.
Usage example:
-device virtio-gpu-gl,rocm=on
The series includes:
1. Add ROCm capset ID 10 to the imported Linux headers.
2. Enable ROCm native contexts through the "rocm=on" device property.
3. Replace the qemu side 16384 entry limit with an overflow check.
4. Add VIRTIO_GPU_F_BLOB_READONLY and VIRTIO_GPU_BLOB_FLAG_USE_READONLY
to the imported Linux headers.
5. Advertise readonly blob support whenever blobs are enabled.
See overall detail in virglrenderer pr [1].
kernel header change patch: [2].
Virtio spec change request: [3].
Changes in v8:
- Rebase onto current master.
- Patches 1, 4: generate with update-linux-headers.sh from [2] (Alex).
- Patch 2: add Dmitry's Reviewed-by.
- Patch 3: check entry array size overflow, not a fixed limit (Dmitry).
- Patch 5: advertise readonly blobs generically (Dmitry).
Changes in v7:
- Replace the obsolete USE_USERPTR=0x8 / USERPTR_RDONLY=0x10 header
definitions with negotiated BLOB_READONLY feature bit 6 and
USE_READONLY=0x8.
- Use ROCm capset ID 10 rather than 8.
- Add readonly advertisement for the paired ROCm blob backend.
Changes in v6:
- Changed to RFC status
- Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature flag from patch 1
- Added VIRTIO_GPU_BLOB_FLAG_USERPTR_RDONLY flag to patch 1
Changes in v5:
- Split userptr header updates into dedicated patch (patch 1/4)
- Extracted nr_entries limit removal into standalone commit (patch 2/4)
- Split ROCm header updates into dedicated patch (patch 3/4)
- Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature detection
- Keep ROCm capability support with "rocm=on" device property (patch 4/4)
- Change corresponding commit messages, change corresponding cover letter content
- Remove RFC label
Changes in v4:
- Change this series to RFC
- Renamed HSAKMT-related functionality to ROCm for better clarity and
alignment with the ROCm ecosystem terminology
- Changed device property from "hsakmt=on" to "rocm=on"
- Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
VIRTIO_GPU_FLAG_ROCM_ENABLED
- Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
VIRGL_RENDERER_USE_ROCM
- Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
VIRTIO_GPU_CAPSET_HSAKMT (8)
- Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
another thread
Changes in v3:
- Renamed HSAKMT-related functionality to ROCm for better clarity and
alignment with the ROCm ecosystem terminology
- Changed device property from "hsakmt=on" to "rocm=on"
- Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
VIRTIO_GPU_FLAG_ROCM_ENABLED
- Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
VIRGL_RENDERER_USE_ROCM
- Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
VIRTIO_GPU_CAPSET_HSAKMT (8)
- Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
another thread
Changes in v2:
- Fixed error handling bug in virtio-gpu-virgl.c where the return
value check was inverted (changed from "if (!ret)" to "if (ret != 0)")
- Added VIRGL_RENDER_USE_HSAKMT flag initialization in virtio_gpu_virgl_init()
when HSAKMT support is enabled
- Simplified blob resource creation logic by removing complex conditional
branching for userptr vs regular blob handling
- Updated commit messages to reflect bug fixes and improvements
- Added references to related patches in Linux kernel, virglrenderer, and
ROCm Runtime components for complete feature implementation tracking
[1]: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1708
[2]: https://lore.kernel.org/all/20261202101658.1209083-1-honghuan@amd.com/
[3]: https://lore.kernel.org/virtio-comment/20261202095728.1127178-1-honghuan@amd.com/
Honglei Huang (5):
linux-headers: Update to v7.4-rc2-userptr-v11 for ROCm capset
(!UPSTREAM)
virtio-gpu: Add ROCm capability support
virtio-gpu: remove the artificial IOV mapping limit
linux-headers: Update to v7.4-rc2-userptr-v11 for readonly blob
(!UPSTREAM)
virtio-gpu: advertise readonly blobs
hw/display/virtio-gpu-base.c | 1 +
hw/display/virtio-gpu-gl.c | 2 ++
hw/display/virtio-gpu-rutabaga.c | 7 ++++++
hw/display/virtio-gpu-virgl.c | 24 +++++++++++++++++++++
hw/display/virtio-gpu.c | 19 ++++++++++------
include/hw/virtio/virtio-gpu.h | 3 +++
include/standard-headers/linux/virtio_gpu.h | 6 ++++++
7 files changed, 55 insertions(+), 7 deletions(-)
base-commit: 9cda597a1a3903d090e8e55e23f5b8a859da88ab
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability
2026-12-04 6:50 ` [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability Huang, Honglei1
@ 2026-12-04 12:56 ` Alex Bennée
0 siblings, 0 replies; 10+ messages in thread
From: Alex Bennée @ 2026-12-04 12:56 UTC (permalink / raw)
To: Huang, Honglei1
Cc: odaki@rsg.ci.i.u-tokyo.ac.jp, dmitry.osipenko@collabora.com,
mst@redhat.com, cohuck@redhat.com, pbonzini@redhat.com,
qemu-devel@nongnu.org, Huang, Ray
"Huang, Honglei1" <Honglei1.Huang@amd.com> writes:
> AMD General
>
> Hi all,
>
> Please let me know if you have any review comments.
> Welcome to any comments.
I'm trying to work out the best way to defend this with tests. I guess
we need a fairly new virglrenderer? Is there any support for ROCm for
the vhost-user-gpu backends?
What would be useful is some sort of functional test with a (small)
workload so we can at least exercise the interface when the libraries
align.
We should also document the host and guest requirements in
virtio-gpu.rst.
>
> Regards,
> Honglei
>
> -----Original Message-----
> From: Huang, Honglei1 <Honglei1.Huang@amd.com>
> Sent: Thursday, December 3, 2026 9:44 AM
> To: alex.bennee@linaro.org; dmitry.osipenko@collabora.com; odaki@rsg.ci.i.u-tokyo.ac.jp; Huang, Ray <Ray.Huang@amd.com>
> Cc: mst@redhat.com; cohuck@redhat.com; pbonzini@redhat.com; qemu-devel@nongnu.org; Huang, Honglei1 <Honglei1.Huang@amd.com>
> Subject: [RFC PATCH v8 0/5] virtio-gpu: Add userptr support and ROCm capability
>
> This patch series introduces enhancements to virtio-gpu to improve memory management and GPU virtualization capabilities for ROCm (Radeon Open Compute) workloads.
>
> Usage example:
> -device virtio-gpu-gl,rocm=on
>
> The series includes:
>
> 1. Add ROCm capset ID 10 to the imported Linux headers.
> 2. Enable ROCm native contexts through the "rocm=on" device property.
> 3. Replace the qemu side 16384 entry limit with an overflow check.
> 4. Add VIRTIO_GPU_F_BLOB_READONLY and VIRTIO_GPU_BLOB_FLAG_USE_READONLY
> to the imported Linux headers.
> 5. Advertise readonly blob support whenever blobs are enabled.
>
> See overall detail in virglrenderer pr [1].
> kernel header change patch: [2].
> Virtio spec change request: [3].
>
> Changes in v8:
> - Rebase onto current master.
> - Patches 1, 4: generate with update-linux-headers.sh from [2] (Alex).
> - Patch 2: add Dmitry's Reviewed-by.
> - Patch 3: check entry array size overflow, not a fixed limit (Dmitry).
> - Patch 5: advertise readonly blobs generically (Dmitry).
>
> Changes in v7:
> - Replace the obsolete USE_USERPTR=0x8 / USERPTR_RDONLY=0x10 header
> definitions with negotiated BLOB_READONLY feature bit 6 and
> USE_READONLY=0x8.
> - Use ROCm capset ID 10 rather than 8.
> - Add readonly advertisement for the paired ROCm blob backend.
>
> Changes in v6:
> - Changed to RFC status
> - Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature flag from patch 1
> - Added VIRTIO_GPU_BLOB_FLAG_USERPTR_RDONLY flag to patch 1
>
> Changes in v5:
> - Split userptr header updates into dedicated patch (patch 1/4)
> - Extracted nr_entries limit removal into standalone commit (patch 2/4)
> - Split ROCm header updates into dedicated patch (patch 3/4)
> - Removed VIRTIO_GPU_F_RESOURCE_USERPTR feature detection
> - Keep ROCm capability support with "rocm=on" device property (patch 4/4)
> - Change corresponding commit messages, change corresponding cover letter content
> - Remove RFC label
>
> Changes in v4:
> - Change this series to RFC
> - Renamed HSAKMT-related functionality to ROCm for better clarity and
> alignment with the ROCm ecosystem terminology
> - Changed device property from "hsakmt=on" to "rocm=on"
> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
> VIRTIO_GPU_FLAG_ROCM_ENABLED
> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
> VIRGL_RENDERER_USE_ROCM
> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
> VIRTIO_GPU_CAPSET_HSAKMT (8)
> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
> another thread
>
> Changes in v3:
> - Renamed HSAKMT-related functionality to ROCm for better clarity and
> alignment with the ROCm ecosystem terminology
> - Changed device property from "hsakmt=on" to "rocm=on"
> - Changed flag from VIRTIO_GPU_FLAG_HSAKMT_ENABLED to
> VIRTIO_GPU_FLAG_ROCM_ENABLED
> - Changed renderer flag from VIRGL_RENDER_USE_HSAKMT to
> VIRGL_RENDERER_USE_ROCM
> - Updated capset handling to use VIRTIO_GPU_CAPSET_ROCM (8) instead of
> VIRTIO_GPU_CAPSET_HSAKMT (8)
> - Removed the error handling fix from patch 1 (virtio-gpu-virgl.c) into
> another thread
>
> Changes in v2:
> - Fixed error handling bug in virtio-gpu-virgl.c where the return
> value check was inverted (changed from "if (!ret)" to "if (ret != 0)")
> - Added VIRGL_RENDER_USE_HSAKMT flag initialization in virtio_gpu_virgl_init()
> when HSAKMT support is enabled
> - Simplified blob resource creation logic by removing complex conditional
> branching for userptr vs regular blob handling
> - Updated commit messages to reflect bug fixes and improvements
> - Added references to related patches in Linux kernel, virglrenderer, and
> ROCm Runtime components for complete feature implementation tracking
>
> [1]: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1708
> [2]: https://lore.kernel.org/all/20261202101658.1209083-1-honghuan@amd.com/
> [3]: https://lore.kernel.org/virtio-comment/20261202095728.1127178-1-honghuan@amd.com/
>
> Honglei Huang (5):
> linux-headers: Update to v7.4-rc2-userptr-v11 for ROCm capset
> (!UPSTREAM)
> virtio-gpu: Add ROCm capability support
> virtio-gpu: remove the artificial IOV mapping limit
> linux-headers: Update to v7.4-rc2-userptr-v11 for readonly blob
> (!UPSTREAM)
> virtio-gpu: advertise readonly blobs
>
> hw/display/virtio-gpu-base.c | 1 +
> hw/display/virtio-gpu-gl.c | 2 ++
> hw/display/virtio-gpu-rutabaga.c | 7 ++++++
> hw/display/virtio-gpu-virgl.c | 24 +++++++++++++++++++++
> hw/display/virtio-gpu.c | 19 ++++++++++------
> include/hw/virtio/virtio-gpu.h | 3 +++
> include/standard-headers/linux/virtio_gpu.h | 6 ++++++
> 7 files changed, 55 insertions(+), 7 deletions(-)
>
>
> base-commit: 9cda597a1a3903d090e8e55e23f5b8a859da88ab
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 10+ messages in thread