> On 3. Dec 2025, at 05:07, Joelle van Dyne <[email protected]> wrote:
>
> 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 <[email protected]>
> ---
> 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
>
>
Hello,
There’s a better way to handle this without guest breakage.
Please use hv_vm_config_set_ipa_granule, it’ll allow to have 4KB granule
allocations as the IPA.
Note: This might have some impact on performance so we might to want to enable
it only when virtio-gpu is used.
Thank you,