This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1da2b4d5a70eff51e56a16367f531123786f8222
Author: anjiahao <[email protected]>
AuthorDate: Tue Jul 1 16:17:10 2025 +0800

    drivers/virtio-gpu: allocate fbmem from kumm in protected build
    
    In a protected build the frame buffer is mapped into user space, but
    virtio_zalloc_buf() allocates it from the kernel side, which user mode
    cannot access.  Allocate it with kumm_calloc() there instead.
    
    Signed-off-by: anjiahao <[email protected]>
---
 drivers/virtio/virtio-gpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/virtio/virtio-gpu.c b/drivers/virtio/virtio-gpu.c
index df301736e95..408cb388694 100644
--- a/drivers/virtio/virtio-gpu.c
+++ b/drivers/virtio/virtio-gpu.c
@@ -610,7 +610,11 @@ static int virtio_gpu_init_fbmem(FAR struct virtio_device 
*vdev,
   priv->stride = priv->xres * VIRTIO_GPU_BPP >> 3;
   fblen = priv->stride * priv->yres;
 
+#ifdef CONFIG_BUILD_PROTECTED
+  priv->fbmem = (FAR uint8_t *)kumm_calloc(fblen * fb_count, 16);
+#else
   priv->fbmem = (FAR uint8_t *)virtio_zalloc_buf(vdev, fblen * fb_count, 16);
+#endif
   if (priv->fbmem == NULL)
     {
       vrterr("ERROR: Failed to allocate frame buffer memory");
@@ -649,7 +653,11 @@ static int virtio_gpu_init_fbmem(FAR struct virtio_device 
*vdev,
   return ret;
 
 error:
+#ifdef CONFIG_BUILD_PROTECTED
+  kumm_free(priv->fbmem);
+#else
   virtio_free_buf(vdev, priv->fbmem);
+#endif
   return ret;
 }
 

Reply via email to