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: 5736280730 ("virtio/vdrm: add ENABLE_DRM_AMDGPU for c_args")
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
(cherry picked from commit bd8377bb04)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
This commit is contained in:
Dmitry Osipenko 2025-10-28 00:15:29 +03:00 committed by Dylan Baker
parent 093c7d9d8e
commit 205fe1a245
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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);