* [PATCH RFC v4 0/3] virtio-gpu: Add user pointer and ROCm support enhancements
@ 2026-01-07 7:50 Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Honglei Huang @ 2026-01-07 7:50 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
This patch series introduces enhancements to virtio-gpu to improve
memory management and GPU virtualization capabilities for ROCm workloads.
The series includes:
1. VIRTIO_GPU_BLOB_FLAG_USE_USERPTR support: Enables user pointer mapping
for blob resources, allowing guest applications to use user-allocated
memory for GPU resources more efficiently.
2. VIRTIO_GPU_F_RESOURCE_USERPTR feature support: Introduces a new virtio-gpu
feature flag with configurable "userptr=on" device property to enable
user pointer resources for enhanced memory management.
3. ROCm capability support: Adds native support for AMD's ROCm (Radeon Open
Compute) platform through a new "rocm=on" device property and
VIRTIO_GPU_CAPSET_ROCM capability. This enables GPU compute
workloads using the ROCm stack through virtio-gpu.
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
These patches work together to provide more flexible and efficient memory
management between guest and host in GPU virtualization scenarios, with
enhanced support for AMD ROCm compute workloads. The changes are backward
compatible and controlled by new device properties.
Usage examples:
-device virtio-gpu-gl,rocm=on,userptr=on
The series has been tested with ROCm GPU compute workloads requiring
advanced memory management capabilities.
TODO:
- Unify and simplify the handling path for userptr resources.
This improvement requires coordinated changes across multiple components
(virglrenderer and virtio-gpu driver), and will be implemented once the
approach is finalized with other component maintainers.
Related patches in other components:
- Linux kernel virtio-gpu support:
https://lore.kernel.org/lkml/20251112072910.3716944-1-honglei1.huang@amd.com/
- Virglrenderer support:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1568
- ROCm Runtime support (merged):
https://github.com/ROCm/ROCR-Runtime/commit/48d3719dba6ca91f597a8179d8b341387ce155e8
Honglei Huang (3):
virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support
virtio-gpu: Add ROCm capability support
hw/display/virtio-gpu-base.c | 3 +++
hw/display/virtio-gpu-gl.c | 2 ++
hw/display/virtio-gpu-virgl.c | 12 ++++++++++++
hw/display/virtio-gpu.c | 9 ++-------
include/hw/virtio/virtio-gpu.h | 6 ++++++
include/standard-headers/linux/virtio_gpu.h | 4 ++++
6 files changed, 29 insertions(+), 7 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
2026-01-07 7:50 [PATCH RFC v4 0/3] virtio-gpu: Add user pointer and ROCm support enhancements Honglei Huang
@ 2026-01-07 7:50 ` Honglei Huang
2026-01-07 9:42 ` Cornelia Huck
2026-01-07 7:50 ` [PATCH RFC v4 2/3] virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 3/3] virtio-gpu: Add ROCm capability support Honglei Huang
2 siblings, 1 reply; 6+ messages in thread
From: Honglei Huang @ 2026-01-07 7:50 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
Add support for the USE_USERPTR blob flag in virtio-gpu to enable
user pointer mapping for blob resources. This allows guest applications
to use user-allocated memory for GPU resources more efficiently.
Changes include:
- Add VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag definition
- Enhance blob resource creation to handle userptr flag properly
- Remove arbitrary nr_entries limit (16384) in mapping creation
- Add conditional handling for userptr vs regular blob mapping
- Support guest_blob_mapped parameter for virgl renderer
- Fix value check issue in virtio-gpu
This enables more flexible memory management between guest and host
for GPU virtualization scenarios.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu.c | 7 -------
include/standard-headers/linux/virtio_gpu.h | 1 +
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 643e91ca2a..17df148920 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -808,13 +808,6 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
size_t esize, s;
int e, v;
- if (nr_entries > 16384) {
- qemu_log_mask(LOG_GUEST_ERROR,
- "%s: nr_entries is too big (%d > 16384)\n",
- __func__, nr_entries);
- return -1;
- }
-
esize = sizeof(*ents) * nr_entries;
ents = g_malloc(esize);
s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index 00cd3f04af..b85e781a2d 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -405,6 +405,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_USERPTR 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
* [PATCH RFC v4 2/3] virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support
2026-01-07 7:50 [PATCH RFC v4 0/3] virtio-gpu: Add user pointer and ROCm support enhancements Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
@ 2026-01-07 7:50 ` Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 3/3] virtio-gpu: Add ROCm capability support Honglei Huang
2 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-01-07 7:50 UTC (permalink / raw)
To: alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, cohuck, pbonzini, qemu-devel, honghuan
This patch introduces support for the VIRTIO_GPU_F_RESOURCE_USERPTR feature
in virtio-gpu implementation:
- Add VIRTIO_GPU_F_RESOURCE_USERPTR feature flag definition
- Implement resource_userptr property as a configurable option
- Add VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED configuration flag
- Enable feature negotiation when resource_userptr is enabled
Usage:
-device virtio-gpu-gl,userptr=on
This feature allows virtio-gpu to support user pointer resources,
enhancing memory management capabilities for GPU virtualization
scenarios.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu-base.c | 3 +++
hw/display/virtio-gpu.c | 2 ++
include/hw/virtio/virtio-gpu.h | 3 +++
include/standard-headers/linux/virtio_gpu.h | 2 ++
4 files changed, 10 insertions(+)
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 7269477a1c..f013a4ece6 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -264,6 +264,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,
if (virtio_gpu_resource_uuid_enabled(g->conf)) {
features |= (1 << VIRTIO_GPU_F_RESOURCE_UUID);
}
+ if (virtio_gpu_resource_userptr_enabled(g->conf)) {
+ features |= (1 << VIRTIO_GPU_F_RESOURCE_USERPTR);
+ }
return features;
}
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 17df148920..0241b44cc8 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1685,6 +1685,8 @@ static const Property virtio_gpu_properties[] = {
256 * MiB),
DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_BLOB_ENABLED, false),
+ DEFINE_PROP_BIT("userptr", VirtIOGPU, parent_obj.conf.flags,
+ VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED, false),
DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0),
DEFINE_PROP_UINT8("x-scanout-vmstate-version", VirtIOGPU, scanout_vmstate_version, 2),
};
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 58e0f91fda..fe98ea0019 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -100,6 +100,7 @@ enum virtio_gpu_base_conf_flags {
VIRTIO_GPU_FLAG_RUTABAGA_ENABLED,
VIRTIO_GPU_FLAG_VENUS_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED,
+ VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED,
};
#define virtio_gpu_virgl_enabled(_cfg) \
@@ -122,6 +123,8 @@ enum virtio_gpu_base_conf_flags {
(_cfg.hostmem > 0)
#define virtio_gpu_venus_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED))
+#define virtio_gpu_resource_userptr_enabled(_cfg) \
+ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED))
struct virtio_gpu_base_conf {
uint32_t max_outputs;
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index b85e781a2d..fe36288fe5 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -65,6 +65,8 @@
*/
#define VIRTIO_GPU_F_CONTEXT_INIT 4
+#define VIRTIO_GPU_F_RESOURCE_USERPTR 5
+
enum virtio_gpu_ctrl_type {
VIRTIO_GPU_UNDEFINED = 0,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 3/3] virtio-gpu: Add ROCm capability support
2026-01-07 7:50 [PATCH RFC v4 0/3] virtio-gpu: Add user pointer and ROCm support enhancements Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 2/3] virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support Honglei Huang
@ 2026-01-07 7:50 ` Honglei Huang
2 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-01-07 7:50 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
- Register VIRTIO_GPU_CAPSET_ROCM (capset 8) capability
- 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.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
hw/display/virtio-gpu-gl.c | 2 ++
hw/display/virtio-gpu-virgl.c | 12 ++++++++++++
include/hw/virtio/virtio-gpu.h | 3 +++
include/standard-headers/linux/virtio_gpu.h | 1 +
4 files changed, 18 insertions(+)
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index b98ef2ef98..f059bcb177 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -159,6 +159,8 @@ static const Property virtio_gpu_gl_properties[] = {
VIRTIO_GPU_FLAG_STATS_ENABLED, false),
DEFINE_PROP_BIT("venus", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_VENUS_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 cbfb8aca3f..5e0f465c37 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -1160,6 +1160,9 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
if (virtio_gpu_venus_enabled(g->parent_obj.conf)) {
flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER;
}
+ if (virtio_gpu_rocm_enabled(g->parent_obj.conf)) {
+ flags |= (VIRGL_RENDERER_USE_ROCM);
+ }
#endif
ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs);
@@ -1218,5 +1221,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 fe98ea0019..a099c30377 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -101,6 +101,7 @@ enum virtio_gpu_base_conf_flags {
VIRTIO_GPU_FLAG_VENUS_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED,
VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED,
+ VIRTIO_GPU_FLAG_ROCM_ENABLED,
};
#define virtio_gpu_virgl_enabled(_cfg) \
@@ -125,6 +126,8 @@ enum virtio_gpu_base_conf_flags {
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED))
#define virtio_gpu_resource_userptr_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RESOURCE_USERPTR_ENABLED))
+#define virtio_gpu_rocm_enabled(_cfg) \
+ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_ROCM_ENABLED))
struct virtio_gpu_base_conf {
uint32_t max_outputs;
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index fe36288fe5..fe6c0f5cc4 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -315,6 +315,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 8
/* 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
* Re: [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
2026-01-07 7:50 ` [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
@ 2026-01-07 9:42 ` Cornelia Huck
2026-01-08 13:00 ` Honglei Huang
0 siblings, 1 reply; 6+ messages in thread
From: Cornelia Huck @ 2026-01-07 9:42 UTC (permalink / raw)
To: Honglei Huang, alex.bennee, dmitry.osipenko, odaki, Ray.Huang
Cc: mst, pbonzini, qemu-devel, honghuan
On Wed, Jan 07 2026, Honglei Huang <honghuan@amd.com> wrote:
> Add support for the USE_USERPTR blob flag in virtio-gpu to enable
> user pointer mapping for blob resources. This allows guest applications
> to use user-allocated memory for GPU resources more efficiently.
>
> Changes include:
> - Add VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag definition
> - Enhance blob resource creation to handle userptr flag properly
> - Remove arbitrary nr_entries limit (16384) in mapping creation
> - Add conditional handling for userptr vs regular blob mapping
> - Support guest_blob_mapped parameter for virgl renderer
> - Fix value check issue in virtio-gpu
>
> This enables more flexible memory management between guest and host
> for GPU virtualization scenarios.
>
> Signed-off-by: Honglei Huang <honghuan@amd.com>
> ---
> hw/display/virtio-gpu.c | 7 -------
> include/standard-headers/linux/virtio_gpu.h | 1 +
> 2 files changed, 1 insertion(+), 7 deletions(-)
Please split out any updates to the imported Linux headers into a
separate patch to be replaced by a headers sync (I thought checkpatch
would warn about that?)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
2026-01-07 9:42 ` Cornelia Huck
@ 2026-01-08 13:00 ` Honglei Huang
0 siblings, 0 replies; 6+ messages in thread
From: Honglei Huang @ 2026-01-08 13:00 UTC (permalink / raw)
To: Cornelia Huck
Cc: dmitry.osipenko, alex.bennee, odaki, Ray.Huang, mst, pbonzini,
qemu-devel
On 2026/1/7 17:42, Cornelia Huck wrote:
> On Wed, Jan 07 2026, Honglei Huang <honghuan@amd.com> wrote:
>
>> Add support for the USE_USERPTR blob flag in virtio-gpu to enable
>> user pointer mapping for blob resources. This allows guest applications
>> to use user-allocated memory for GPU resources more efficiently.
>>
>> Changes include:
>> - Add VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag definition
>> - Enhance blob resource creation to handle userptr flag properly
>> - Remove arbitrary nr_entries limit (16384) in mapping creation
>> - Add conditional handling for userptr vs regular blob mapping
>> - Support guest_blob_mapped parameter for virgl renderer
>> - Fix value check issue in virtio-gpu
>>
>> This enables more flexible memory management between guest and host
>> for GPU virtualization scenarios.
>>
>> Signed-off-by: Honglei Huang <honghuan@amd.com>
>> ---
>> hw/display/virtio-gpu.c | 7 -------
>> include/standard-headers/linux/virtio_gpu.h | 1 +
>> 2 files changed, 1 insertion(+), 7 deletions(-)
>
> Please split out any updates to the imported Linux headers into a
> separate patch to be replaced by a headers sync (I thought checkpatch
> would warn about that?)
>
Understood, will split the Linux headrs changes into a separate commit
in next version.
Really thanks for the reminding.
Regards,
Honglei
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-08 13:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 7:50 [PATCH RFC v4 0/3] virtio-gpu: Add user pointer and ROCm support enhancements Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag Honglei Huang
2026-01-07 9:42 ` Cornelia Huck
2026-01-08 13:00 ` Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 2/3] virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support Honglei Huang
2026-01-07 7:50 ` [PATCH RFC v4 3/3] virtio-gpu: Add ROCm capability support Honglei Huang
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.