Skip to contentSkip to conversation

virtio-gpu: Add user pointer and HSAKMT support enhancements

PATCH Superseded Honglei Huang 2 participants 8 messages Nov 12, 2025 – Dec 8, 2025 virtio core

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#2 lore raw

Re: [PATCH 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag

In reply to Honglei Huang
Quoted 37 lines · Honglei Huang

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

This enables more flexible memory management between guest and host for GPU virtualization scenarios.

---
  hw/display/virtio-gpu-virgl.c               | 21 +++++++++++++++------
  hw/display/virtio-gpu.c                     |  7 -------
  include/standard-headers/linux/virtio_gpu.h |  1 +
  3 files changed, 16 insertions(+), 13 deletions(-)
hw/display/virtio-gpu-virgl.c +2 -6
index 07f6355ad6..9da64bf16f 100644
@@ -702,12 +702,21 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *g,
      res->base.dmabuf_fd = -1;
 
      if (cblob.blob_mem != VIRTIO_GPU_BLOB_MEM_HOST3D) {
-        ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob),
-                                            cmd, &res->base.addrs,
-                                            &res->base.iov, &res->base.iov_cnt);
-        if (!ret) {
-            cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
-            return;
+        if (cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_USERPTR) {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob), cmd, &res->base.addrs,

hw/display/virtio-gpu-virgl.c static void virgl_cmd_resource_create_blob(VirtIOGPU *g, · line 716

Quoted 10 lines
hw/display/virtio-gpu-virgl.c +10 -0
+                                                &res->base.iov, &res->base.iov_cnt);
+            if (ret != 0) {
+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+                return;
+            }
+        } else {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob),
+                                                cmd, &res->base.addrs,
+                                                &res->base.iov, &res->base.iov_cnt);
+            if (!ret) {

Why does this check !ret instead of ret != 0?

Regards,
Akihiko Odaki

Quoted 36 lines
hw/display/virtio-gpu-virgl.c +3 -0
+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+                return;
+            }
          }
      }
 
hw/display/virtio-gpu.c +0 -7
index 43e88a4daf..956dc811fa 100644
@@ -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,
include/standard-headers/linux/virtio_gpu.h +1 -0
index 00cd3f04af..b85e781a2d 100644
@@ -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;
#4 lore raw

PATCH 2/3 virtio-gpu: add configurable HSAKMT capset support

In reply to Honglei Huang

Changes include:
- Add VIRTIO_GPU_FLAG_HSAKMT_ENABLED flag to virtio_gpu_base_conf_flags
- Add virtio_gpu_hsakmt_enabled() macro for configuration checking
- Add "hsakmt" device property to virtio-gpu-gl device
- Modify virtio_gpu_virgl_get_capsets() to conditionally enable HSAKMT capset based on configuration flag and runtime capability check

The HSAKMT capset is now only enabled when:
1. The "hsakmt=on" device property is set (defaults to false)
2. virgl_renderer_get_cap_set() reports capset_max_size > 0

Usage:
-device virtio-gpu-gl,hsakmt=on

This provides better control over HSAKMT functionality and avoids exposing unsupported capabilities to guests.

---
 hw/display/virtio-gpu-gl.c                  | 2 ++
 hw/display/virtio-gpu-virgl.c               | 9 +++++++++
 include/hw/virtio/virtio-gpu.h              | 3 +++
 include/standard-headers/linux/virtio_gpu.h | 1 +
 4 files changed, 15 insertions(+)
hw/display/virtio-gpu-gl.c +2 -0
index c06a078fb3..4ed2f53e4e 100644
@@ -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("hsakmt", VirtIOGPU, parent_obj.conf.flags,
+                    VIRTIO_GPU_FLAG_HSAKMT_ENABLED, false),
 };
 
 static void virtio_gpu_gl_device_unrealize(DeviceState *qdev)
hw/display/virtio-gpu-virgl.c +9 -0
index 9da64bf16f..7162c4bfee 100644
@@ -1227,5 +1227,14 @@ GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g)
         }
     }
 
+    if (virtio_gpu_hsakmt_enabled(g->parent_obj.conf)) {
+        virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_HSAKMT,
+                                   &capset_max_ver,
+                                   &capset_max_size);
+        if (capset_max_size) {
+            virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_HSAKMT);
+        }
+    }
+
     return capset_ids;
 }
include/hw/virtio/virtio-gpu.h +3 -0
index 58e0f91fda..c820247db8 100644
@@ -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_HSAKMT_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_hsakmt_enabled(_cfg) \
+    (_cfg.flags & (1 << VIRTIO_GPU_FLAG_HSAKMT_ENABLED))
 
 struct virtio_gpu_base_conf {
     uint32_t max_outputs;
include/standard-headers/linux/virtio_gpu.h +1 -0
index b85e781a2d..6c54cb745f 100644
@@ -313,6 +313,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_HSAKMT 8
 
 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */
 struct virtio_gpu_get_capset_info {
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag

In reply to Honglei Huang

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

This enables more flexible memory management between guest and host for GPU virtualization scenarios.

---
 hw/display/virtio-gpu-virgl.c               | 21 +++++++++++++++------
 hw/display/virtio-gpu.c                     |  7 -------
 include/standard-headers/linux/virtio_gpu.h |  1 +
 3 files changed, 16 insertions(+), 13 deletions(-)
hw/display/virtio-gpu-virgl.c +15 -6
index 07f6355ad6..9da64bf16f 100644
@@ -702,12 +702,21 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *g,
     res->base.dmabuf_fd = -1;
 
     if (cblob.blob_mem != VIRTIO_GPU_BLOB_MEM_HOST3D) {
-        ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob),
-                                            cmd, &res->base.addrs,
-                                            &res->base.iov, &res->base.iov_cnt);
-        if (!ret) {
-            cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
-            return;
+        if (cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_USERPTR) {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob), cmd, &res->base.addrs,
+                                                &res->base.iov, &res->base.iov_cnt);
+            if (ret != 0) {
+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+                return;
+            }
+        } else {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob),
+                                                cmd, &res->base.addrs,
+                                                &res->base.iov, &res->base.iov_cnt);
+            if (!ret) {
+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+                return;
+            }
         }
     }
 
hw/display/virtio-gpu.c +0 -7
index 43e88a4daf..956dc811fa 100644
@@ -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,
include/standard-headers/linux/virtio_gpu.h +1 -0
index 00cd3f04af..b85e781a2d 100644
@@ -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;
Signature · 1 line
2.34.1
#0 lore raw

cover virtio-gpu: Add user pointer and HSAKMT support enhancements

This patch series introduces three key enhancements to virtio-gpu to improve memory management and GPU virtualization capabilities:

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. Configurable HSAKMT capset support: Provides better control over HSAKMT functionality with a new device property "hsakmt=on" to avoid exposing unsupported capabilities to guests.

3. 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.

These patches work together to provide more flexible and efficient memory management between guest and host in GPU virtualization scenarios. The changes are backward compatible and controlled by new device properties.

Usage examples:
-device virtio-gpu-gl,hsakmt=on,userptr=on

The series has been tested with GPU workloads requiring advanced memory management capabilities.

Honglei Huang (3):
virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
virtio-gpu: add configurable HSAKMT capset support
virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support

 hw/display/virtio-gpu-base.c                |  3 +++
 hw/display/virtio-gpu-gl.c                  |  2 ++
 hw/display/virtio-gpu-virgl.c               | 30 ++++++++++++++++-----
 hw/display/virtio-gpu.c                     |  9 ++-----
 include/hw/virtio/virtio-gpu.h              |  6 +++++
 include/standard-headers/linux/virtio_gpu.h |  4 +++
 6 files changed, 41 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 1/3] virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag

In reply to Akihiko Odaki
Quoted 86 lines · Akihiko Odaki
Quoted 51 lines · Honglei Huang

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

This enables more flexible memory management between guest and host for GPU virtualization scenarios.

---
  hw/display/virtio-gpu-virgl.c               | 21 +++++++++++++++------ hw/display/virtio-gpu.c                     |  7 ------- include/standard-headers/linux/virtio_gpu.h |  1 +

  3 files changed, 16 insertions(+), 13 deletions(-)
hw/display/virtio-gpu-virgl.c +3 -6
index 07f6355ad6..9da64bf16f 100644
@@ -702,12 +702,21 @@ static void 
 virgl_cmd_resource_create_blob(VirtIOGPU *g,
       res->base.dmabuf_fd = -1;
       if (cblob.blob_mem != VIRTIO_GPU_BLOB_MEM_HOST3D) {
-        ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, 
 sizeof(cblob),
-                                            cmd, &res->base.addrs,
-                                            &res->base.iov, &res- 
 >base.iov_cnt);
-        if (!ret) {
-            cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
-            return;
+        if (cblob.blob_flags & VIRTIO_GPU_BLOB_FLAG_USE_USERPTR) {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, 
 sizeof(cblob), cmd, &res->base.addrs,
+                                                &res->base.iov, &res- 
Quoted 1 line

base.iov_cnt);

+            if (ret != 0) {
+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+                return;
+            }
+        } else {
+            ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob),
+                                                cmd, &res->base.addrs, +                                                &res->base.iov, &res-

Quoted 2 lines
Quoted 1 line

base.iov_cnt);

+            if (!ret) {

Why does this check !ret instead of ret != 0?

Regards,
Akihiko Odaki

Quoted 26 lines

+                cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; +                return;
+            }
          }
      }

hw/display/virtio-gpu.c +0 -7
index 43e88a4daf..956dc811fa 100644
@@ -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,
include/standard-headers/linux/virtio_gpu.h +0 -0
index 00cd3f04af..b85e781a2d 100644
Quoted 9 lines

include/standard-headers/linux/virtio_gpu.h struct virtio_gpu_resource_create_blob { · line 411

Quoted 8 lines
include/standard-headers/linux/virtio_gpu.h +1 -0
@@ -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;

Hi Akihiko,

Thank you for the review!
You're absolutely right. I need to maintain a consistent code style. I'll fix this in v2 along with making both check consistent.

Regards,
Honglei

#5 lore raw

PATCH 3/3 virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support

In reply to Honglei Huang

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.

---
 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(+)
hw/display/virtio-gpu-base.c +3 -0
index 7269477a1c..f013a4ece6 100644
@@ -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;
 }
hw/display/virtio-gpu.c +2 -0
index 956dc811fa..5f1dc80060 100644
@@ -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),
 };
include/hw/virtio/virtio-gpu.h +3 -0
index c820247db8..ff68f3c451 100644
@@ -101,6 +101,7 @@ enum virtio_gpu_base_conf_flags {
     VIRTIO_GPU_FLAG_VENUS_ENABLED,
     VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED,
     VIRTIO_GPU_FLAG_HSAKMT_ENABLED,
+    VIRTIO_GPU_FLAG_RESOURCE_USERPTR_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_hsakmt_enabled(_cfg) \
     (_cfg.flags & (1 << VIRTIO_GPU_FLAG_HSAKMT_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;
include/standard-headers/linux/virtio_gpu.h +2 -0
index 6c54cb745f..321477598e 100644
@@ -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,
 
Signature · 1 line
2.34.1
#6 lore raw
In reply to Honglei Huang

Dear all,

I would like to share some progress that has been made in exploring GPU compute capabilities within virtio-gpu. Work has been undertaken to extend virtio-gpu beyond traditional graphics workloads to support compute applications, and I wanted to update the community on the current status and gather feedback on this effort.

Virtio-gpu has the potential to become a unified solution for both graphics and compute, providing efficient GPU access in virtualized environments. This work aims to enable modern GPU compute stacks like ROCm, allowing AI/ML workloads and scientific computing to run in virtual machines with minimal performance penalty.

The current implementation is functional with essential features enabled and operational. The implementation has been validated with production AI workloads. For ComfyUI image/video generation on AMD W7900, the observed overhead ranges from 0.4% to 8.3% across different tasks. For LLM inference using deepseek-r1-distill-qwen-1.5b, the implementation achieved approximately 86% efficiency with 14% virtualization overhead. For OpenCL, most CTS tests have also been validated, and on certain hardware platforms, full CTS can be fully validated.

As someone approaching this work as a learner, I would greatly appreciate feedback from the community. The current functionality and performance are not bad, there are certainly areas that could benefit from improvement. I am fully committed to addressing any feedback received and working with the community to refine the implementation to meet the expected standards.

Full documentation and testing resources are available at: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1475

Thank you for your time and consideration. I welcome all feedback, questions, and suggestions.

Best regards,
Honglei Huang

Quoted 38 lines · Honglei Huang

This patch series introduces three key enhancements to virtio-gpu to improve memory management and GPU virtualization capabilities:

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. Configurable HSAKMT capset support: Provides better control over HSAKMT functionality with a new device property "hsakmt=on" to avoid exposing unsupported capabilities to guests.

3. 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.

These patches work together to provide more flexible and efficient memory management between guest and host in GPU virtualization scenarios. The changes are backward compatible and controlled by new device properties.

Usage examples:
-device virtio-gpu-gl,hsakmt=on,userptr=on

The series has been tested with GPU workloads requiring advanced memory management capabilities.

Honglei Huang (3):
virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
virtio-gpu: add configurable HSAKMT capset support
virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support

  hw/display/virtio-gpu-base.c                |  3 +++
  hw/display/virtio-gpu-gl.c                  |  2 ++
  hw/display/virtio-gpu-virgl.c               | 30 ++++++++++++++++-----
  hw/display/virtio-gpu.c                     |  9 ++-----
  include/hw/virtio/virtio-gpu.h              |  6 +++++
  include/standard-headers/linux/virtio_gpu.h |  4 +++
  6 files changed, 41 insertions(+), 13 deletions(-)
#7 lore raw

Correction: full documentation and testing resources are available at:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1568

Quoted 59 lines · Honglei Huang

Dear all,

I would like to share some progress that has been made in exploring GPU compute capabilities within virtio-gpu. Work has been undertaken to extend virtio-gpu beyond traditional graphics workloads to support compute applications, and I wanted to update the community on the current status and gather feedback on this effort.

Virtio-gpu has the potential to become a unified solution for both graphics and compute, providing efficient GPU access in virtualized environments. This work aims to enable modern GPU compute stacks like ROCm, allowing AI/ML workloads and scientific computing to run in virtual machines with minimal performance penalty.

The current implementation is functional with essential features enabled and operational. The implementation has been validated with production AI workloads. For ComfyUI image/video generation on AMD W7900, the observed overhead ranges from 0.4% to 8.3% across different tasks. For LLM inference using deepseek-r1-distill-qwen-1.5b, the implementation achieved approximately 86% efficiency with 14% virtualization overhead. For OpenCL, most CTS tests have also been validated, and on certain hardware platforms, full CTS can be fully validated.

As someone approaching this work as a learner, I would greatly appreciate feedback from the community. The current functionality and performance are not bad, there are certainly areas that could benefit from improvement. I am fully committed to addressing any feedback received and working with the community to refine the implementation to meet the expected standards.

Full documentation and testing resources are available at: https:// gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1475

Thank you for your time and consideration. I welcome all feedback, questions, and suggestions.

Best regards,
Honglei Huang

Quoted 38 lines · Honglei Huang

This patch series introduces three key enhancements to virtio-gpu to improve memory management and GPU virtualization capabilities:

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. Configurable HSAKMT capset support: Provides better control over HSAKMT functionality with a new device property "hsakmt=on" to avoid exposing unsupported capabilities to guests.

3. 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.

These patches work together to provide more flexible and efficient memory management between guest and host in GPU virtualization scenarios. The changes are backward compatible and controlled by new device properties.

Usage examples:
   -device virtio-gpu-gl,hsakmt=on,userptr=on

The series has been tested with GPU workloads requiring advanced memory management capabilities.

Honglei Huang (3):
   virtio-gpu: Add support for VIRTIO_GPU_BLOB_FLAG_USE_USERPTR flag
   virtio-gpu: add configurable HSAKMT capset support
   virtio-gpu: Add VIRTIO_GPU_F_RESOURCE_USERPTR feature support

  hw/display/virtio-gpu-base.c                |  3 +++ hw/display/virtio-gpu-gl.c                  |  2 ++ hw/display/virtio-gpu-virgl.c               | 30 ++++++++++++++++----- hw/display/virtio-gpu.c                     |  9 ++----- include/hw/virtio/virtio-gpu.h              |  6 +++++ include/standard-headers/linux/virtio_gpu.h |  4 +++

  6 files changed, 41 insertions(+), 13 deletions(-)