[PATCH 3/3] virtio-gpu: advertise and populate blob alignment

Lucas Amaral posted 3 patches 1 month ago
Maintainers: "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>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
There is a newer version of this series
[PATCH 3/3] virtio-gpu: advertise and populate blob alignment
Posted by Lucas Amaral 1 month ago
Set blob_alignment in the device configuration to the host page size
so the guest kernel can align blob BAR offsets accordingly, avoiding
alignment mismatches with the VMM's memory mapping API (e.g.,
hv_vm_map on macOS).

Uses VIRTIO_GPU_F_BLOB_ALIGNMENT defined in the preceding header
patch, and advertised via the feature bit in get_features.

Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
---
 hw/display/virtio-gpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 643e91c..15e8be0 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1517,6 +1517,13 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
 #endif
     }
 
+    /*
+     * Advertise blob alignment so the guest kernel can align BAR offsets.
+     * Guest-side F_BLOB_ALIGNMENT support pending upstream Linux merge.
+     */
+    g->parent_obj.virtio_config.blob_alignment =
+        cpu_to_le32(qemu_real_host_page_size());
+
     if (!virtio_gpu_base_device_realize(qdev,
                                         virtio_gpu_handle_ctrl_cb,
                                         virtio_gpu_handle_cursor_cb,
-- 
2.52.0