Commit 555c5af38c for qemu.org

commit 555c5af38c76cae5b68d648095367ddb9afc65a4
Author: Peter Maydell <peter.maydell@linaro.org>
Date:   Tue Nov 24 09:57:18 2026 +0000

    hw/display/vmware_vga: Reject attempts to set resolution outside VRAM size

    The vmware_vga device limits the maximum width and height of the
    screen, but the maximum total resolution those limits allow (2368 x
    1770) can be too large for the configured VRAM size, if the user has
    set that to something smaller than the 16MB default.  We don't check
    that, so we will set up a display surface bigger than the backing
    VRAM and QEMU will crash when we try to draw it.

    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4898
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Message-ID: <20261124095719.4126146-4-peter.maydell@linaro.org>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 353cef408d..d4fff46198 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1136,6 +1136,11 @@ static inline void vmsvga_check_size(struct vmsvga_state_s *s)
         pixman_format_code_t format =
             qemu_default_pixman_format(s->new_depth, true);
         trace_vmware_setmode(s->new_width, s->new_height, s->new_depth);
+
+        /* Ignore attempts to set a resolution too large for the VRAM */
+        if ((uint64_t)s->new_height * stride > s->vga.vram_size) {
+            return;
+        }
         surface = qemu_create_displaysurface_from(s->new_width, s->new_height,
                                                   format, stride,
                                                   s->vga.vram_ptr);