qxl: don't create too large primary surface
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Thu, 16 Oct 2014 09:39:44 +0000 (11:39 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 22 Oct 2014 01:11:50 +0000 (11:11 +1000)
Limit primary to qemu vgamem size, to avoid reaching
qemu guest bug "requested primary larger than framebuffer"
on resizing screen too large to fit.

Remove unneeded and misleading variables.

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1127552

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/qxl/qxl_display.c

index af9e785466883ae52a9812620421221af0630894..0d13962668578748af69ab19827c6f90598a36bf 100644 (file)
@@ -572,7 +572,6 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
        struct qxl_framebuffer *qfb;
        struct qxl_bo *bo, *old_bo = NULL;
        struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
-       uint32_t width, height, base_offset;
        bool recreate_primary = false;
        int ret;
        int surf_id;
@@ -602,9 +601,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
        if (qcrtc->index == 0)
                recreate_primary = true;
 
-       width = mode->hdisplay;
-       height = mode->vdisplay;
-       base_offset = 0;
+       if (bo->surf.stride * bo->surf.height > qdev->vram_size) {
+               DRM_ERROR("Mode doesn't fit in vram size (vgamem)");
+               return -EINVAL;
+        }
 
        ret = qxl_bo_reserve(bo, false);
        if (ret != 0)
@@ -618,10 +618,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
        if (recreate_primary) {
                qxl_io_destroy_primary(qdev);
                qxl_io_log(qdev,
-                          "recreate primary: %dx%d (was %dx%d,%d,%d)\n",
-                          width, height, bo->surf.width,
-                          bo->surf.height, bo->surf.stride, bo->surf.format);
-               qxl_io_create_primary(qdev, base_offset, bo);
+                          "recreate primary: %dx%d,%d,%d\n",
+                          bo->surf.width, bo->surf.height,
+                          bo->surf.stride, bo->surf.format);
+               qxl_io_create_primary(qdev, 0, bo);
                bo->is_primary = true;
        }