Define VIRTIO_GPU_F_BLOB_ALIGNMENT (feature bit 5) per the OASIS
virtio specification. This allows the host to communicate its
memory alignment requirement to the guest via the blob_alignment
field in virtio_gpu_config.
Set blob_alignment 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).
Guest-side kernel support (drm_mm alignment) is pending upstream
Linux merge.
Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
---
hw/display/virtio-gpu.c | 8 ++++++++
include/standard-headers/linux/virtio_gpu.h | 6 ++++++
2 files changed, 14 insertions(+)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index de7a86a7..44ae5034 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1532,6 +1532,14 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
#endif
}
+ /*
+ * TODO: guest-side F_BLOB_ALIGNMENT support pending upstream Linux merge
+ * (Sergio Lopez's patches, Nov 2025). Until merged, the guest won't
+ * negotiate this feature. The host advertises it per OASIS virtio spec.
+ */
+ 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,
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index 00cd3f04..252704e7 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -64,6 +64,11 @@
* context_init and multiple timelines
*/
#define VIRTIO_GPU_F_CONTEXT_INIT 4
+/*
+ * VIRTIO_GPU_F_BLOB_ALIGNMENT: device advertises blob_alignment
+ * in virtio_gpu_config (OASIS virtio-spec feature bit 5)
+ */
+#define VIRTIO_GPU_F_BLOB_ALIGNMENT 5
enum virtio_gpu_ctrl_type {
VIRTIO_GPU_UNDEFINED = 0,
@@ -365,6 +370,7 @@ struct virtio_gpu_config {
uint32_t events_clear;
uint32_t num_scanouts;
uint32_t num_capsets;
+ uint32_t blob_alignment;
};
/* simple formats for fbcon/X use */
--
2.52.0