From: Joelle van Dyne <j@getutm.app>
To: qemu-devel@nongnu.org
Cc: "Joelle van Dyne" <j@getutm.app>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH RFC 2/7] virtio-gpu-virgl: check page alignment of blob mapping
Date: Tue, 2 Dec 2025 20:07:49 -0800 [thread overview]
Message-ID: <20251203040754.94487-3-j@getutm.app> (raw)
In-Reply-To: <20251203040754.94487-1-j@getutm.app>
Currently if a mapping is not page aligned, it will sliently fail and the
guest, assuming it is mapped, will attempt to access the memory and fail.
This is particularly an issue on macOS when the host page size is 16KiB and
the guest page size is 4KiB.
Signed-off-by: Joelle van Dyne <j@getutm.app>
---
hw/display/virtio-gpu-virgl.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 20c856c04e..adf02ac22b 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -116,6 +116,20 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g,
return ret;
}
+ if (!QEMU_IS_ALIGNED((uintptr_t)data, qemu_real_host_page_size())) {
+ virgl_renderer_resource_unmap(res->base.resource_id);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: address %p is not aligned to page size\n",
+ __func__, data);
+ return -ENOMEM;
+ }
+
+ if (!QEMU_IS_ALIGNED(size, qemu_real_host_page_size())) {
+ virgl_renderer_resource_unmap(res->base.resource_id);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: size 0x%llx is not aligned to page size\n",
+ __func__, size);
+ return -ENOMEM;
+ }
+
vmr = g_new0(struct virtio_gpu_virgl_hostmem_region, 1);
vmr->g = g;
--
2.41.0
next prev parent reply other threads:[~2025-12-03 4:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 4:07 [PATCH RFC 0/7] virtio-gpu-virgl: introduce Venus support for macOS Joelle van Dyne
2025-12-03 4:07 ` [PATCH RFC 1/7] egl-helpers: store handle to native device Joelle van Dyne
2025-12-04 6:29 ` Akihiko Odaki
2025-12-03 4:07 ` Joelle van Dyne [this message]
2025-12-04 2:55 ` [PATCH RFC 2/7] virtio-gpu-virgl: check page alignment of blob mapping Akihiko Odaki
2025-12-04 4:01 ` Joelle van Dyne
2025-12-04 5:31 ` Akihiko Odaki
2025-12-11 4:09 ` Mohamed Mediouni
2025-12-03 4:07 ` [PATCH RFC 3/7] console: rename `d3d_tex2d` to `native` Joelle van Dyne
2025-12-04 6:40 ` Akihiko Odaki
2025-12-04 10:53 ` Marc-André Lureau
2025-12-03 4:07 ` [PATCH RFC 4/7] virtio-gpu-virgl: update virglrenderer defines Joelle van Dyne
2025-12-04 7:13 ` Akihiko Odaki
2025-12-04 10:57 ` Marc-André Lureau
2025-12-03 4:07 ` [PATCH RFC 5/7] virtio-gpu-virgl: support scanout of Metal textures Joelle van Dyne
2025-12-04 3:06 ` Akihiko Odaki
2025-12-03 4:07 ` [PATCH RFC 6/7] console: add cleanup callback for ScanoutTexture Joelle van Dyne
2025-12-04 6:23 ` Akihiko Odaki
2025-12-03 4:07 ` [PATCH RFC 7/7] virtio-gpu-virgl: add support for native blob scanout Joelle van Dyne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251203040754.94487-3-j@getutm.app \
--to=j@getutm.app \
--cc=alex.bennee@linaro.org \
--cc=dmitry.osipenko@collabora.com \
--cc=mst@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).