From 205fe1a2451d72b7651b2fc7a30f2ab8efd20892 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Tue, 28 Oct 2025 00:15:29 +0300 Subject: [PATCH] virtio/vdrm: Fix varying offsets of struct vdrm_device members Struct virgl_renderer_capset_drm has a varying size depending on whether AMDGPU driver is enabled or not. This breaks offset of struct vdrm_device members for non-AMD drivers when Mesa is built with multiple native context drivers including the AMD driver. Place varying capsets in the end struct vdrm_device to mitigate the issue. Fixes: 57362807307d ("virtio/vdrm: add ENABLE_DRM_AMDGPU for c_args") Signed-off-by: Dmitry Osipenko (cherry picked from commit bd8377bb0416bd30007aa49573579e2711cc2f8e) Part-of: --- .pick_status.json | 2 +- src/virtio/vdrm/vdrm.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2d81f7df7ff..bae91397b89 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -514,7 +514,7 @@ "description": "virtio/vdrm: Fix varying offsets of struct vdrm_device members", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "57362807307d487ea29afb4d7db1f83edcc88707", "notes": null diff --git a/src/virtio/vdrm/vdrm.h b/src/virtio/vdrm/vdrm.h index 4fbde29efc6..76d1c4db83e 100644 --- a/src/virtio/vdrm/vdrm.h +++ b/src/virtio/vdrm/vdrm.h @@ -53,7 +53,6 @@ struct vdrm_device_funcs { struct vdrm_device { const struct vdrm_device_funcs *funcs; - struct virgl_renderer_capset_drm caps; bool supports_cross_device; struct vdrm_shmem *shmem; uint8_t *rsp_mem; @@ -70,6 +69,12 @@ struct vdrm_device { uint32_t reqbuf_len; uint32_t reqbuf_cnt; uint8_t reqbuf[0x4000]; + + /* + * struct virgl_renderer_capset_drm has a varying size and must be placed + * in the end of struct vdrm_device. + */ + struct virgl_renderer_capset_drm caps; }; struct vdrm_device *vdrm_device_connect(int fd, uint32_t context_type);