From patchwork Mon Oct 15 12:54:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 191557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1A3622C00A6 for ; Mon, 15 Oct 2012 23:54:33 +1100 (EST) Received: from localhost ([::1]:40193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNkBj-0005jN-Br for incoming@patchwork.ozlabs.org; Mon, 15 Oct 2012 08:54:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNkBY-0005VK-5F for qemu-devel@nongnu.org; Mon, 15 Oct 2012 08:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNkBO-0006ij-CD for qemu-devel@nongnu.org; Mon, 15 Oct 2012 08:54:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNkBO-0006iF-3e for qemu-devel@nongnu.org; Mon, 15 Oct 2012 08:54:10 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9FCs8hN027997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Oct 2012 08:54:08 -0400 Received: from garlic.redhat.com (vpn1-4-204.ams2.redhat.com [10.36.4.204]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FCs4fc005144; Mon, 15 Oct 2012 08:54:05 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Mon, 15 Oct 2012 14:54:03 +0200 Message-Id: <1350305643-31096-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: yhalperi@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH] hw/qxl: guest bug on primary create with stride %4 != 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Due to usage of pixman for rendering on all spice surfaces we have pixman's requirement that the stride be word aligned. A guest not honoring that can crash spice and qemu with it due to failure to create a surface (in spice-server). Avoid this early on in primary surface creation and offscreen surface creation. Recently windows guests got odd width support which triggers a non word aligned primary surface in 16bit color depth. Off screen surfaces have always been word aligned, but doesn't hurt to check them here too. Signed-off-by: Alon Levy --- hw/qxl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/qxl.c b/hw/qxl.c index bd37a83..eaeee76 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -459,6 +459,12 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) qxl->ssd.num_surfaces); return 1; } + if (cmd->type == QXL_SURFACE_CMD_CREATE && + (cmd->u.surface_create.stride & 0x03) != 0) { + qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE stride = %d %% 4 != 0\n", + cmd->u.surface_create.stride); + return 1; + } qemu_mutex_lock(&qxl->track_lock); if (cmd->type == QXL_SURFACE_CMD_CREATE) { qxl->guest_surfaces.cmds[id] = ext->cmd.data; @@ -1382,6 +1388,12 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, trace_qxl_create_guest_primary_rest(qxl->id, sc->stride, sc->type, sc->flags); + if ((surface.stride & 0x3) != 0) { + qxl_set_guest_bug(qxl, "primary surface stride = %d %% 4 != 0", + surface.stride); + return; + } + surface.mouse_mode = true; surface.group_id = MEMSLOT_GROUP_GUEST; if (loadvm) {