From nobody Fri May 3 11:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510320522737357.17982467007687; Fri, 10 Nov 2017 05:28:42 -0800 (PST) Received: from localhost ([::1]:41723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9MC-0005gi-0N for importer@patchew.org; Fri, 10 Nov 2017 08:28:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9Kf-0004j9-Hd for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eD9Kc-0001WA-Pt for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eD9Kc-0001UF-Jv for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD9714ACAC; Fri, 10 Nov 2017 13:26:49 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A7DA6FDD1; Fri, 10 Nov 2017 13:26:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4040027E; Fri, 10 Nov 2017 14:26:44 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 10 Nov 2017 14:26:42 +0100 Message-Id: <20171110132644.8069-2-kraxel@redhat.com> In-Reply-To: <20171110132644.8069-1-kraxel@redhat.com> References: <20171110132644.8069-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 10 Nov 2017 13:26:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] virtio-gpu: fix bug in host memory calculation. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Gerd Hoffmann , Tao Wu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tao Wu The old code treats bits as bytes when calculating host memory usage. Change it to be consistent with allocation logic in pixman library. Signed-off-by: Tao Wu Message-Id: <20171109181741.31318-1-lepton@google.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Gerd Hoffmann --- hw/display/virtio-gpu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 43bbe09ea0..274e365713 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -322,6 +322,18 @@ static pixman_format_code_t get_pixman_format(uint32_t= virtio_gpu_format) } } =20 +static uint32_t calc_image_hostmem(pixman_format_code_t pformat, + uint32_t width, uint32_t height) +{ + /* Copied from pixman/pixman-bits-image.c, skip integer overflow check. + * pixman_image_create_bits will fail in case it overflow. + */ + + int bpp =3D PIXMAN_FORMAT_BPP(pformat); + int stride =3D ((width * bpp + 0x1f) >> 5) * sizeof(uint32_t); + return height * stride; +} + static void virtio_gpu_resource_create_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *= cmd) { @@ -366,7 +378,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, return; } =20 - res->hostmem =3D PIXMAN_FORMAT_BPP(pformat) * c2d.width * c2d.height; + res->hostmem =3D calc_image_hostmem(pformat, c2d.width, c2d.height); if (res->hostmem + g->hostmem < g->conf.max_hostmem) { res->image =3D pixman_image_create_bits(pformat, c2d.width, @@ -1087,7 +1099,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, return -EINVAL; } =20 - res->hostmem =3D PIXMAN_FORMAT_BPP(pformat) * res->width * res->he= ight; + res->hostmem =3D calc_image_hostmem(pformat, res->width, res->heig= ht); =20 res->addrs =3D g_new(uint64_t, res->iov_cnt); res->iov =3D g_new(struct iovec, res->iov_cnt); --=20 2.9.3 From nobody Fri May 3 11:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510320602536741.6154296622561; Fri, 10 Nov 2017 05:30:02 -0800 (PST) Received: from localhost ([::1]:41726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9Nd-0006pf-Qk for importer@patchew.org; Fri, 10 Nov 2017 08:29:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9Kf-0004j8-HJ for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eD9Kc-0001V2-DM for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eD9Kc-0001SU-7i for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA6B9C04BD4E for ; Fri, 10 Nov 2017 13:26:48 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 531B162684; Fri, 10 Nov 2017 13:26:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4762127F; Fri, 10 Nov 2017 14:26:44 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 10 Nov 2017 14:26:43 +0100 Message-Id: <20171110132644.8069-3-kraxel@redhat.com> In-Reply-To: <20171110132644.8069-1-kraxel@redhat.com> References: <20171110132644.8069-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 10 Nov 2017 13:26:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] vga: fix region checks in wraparound case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: "Dr. David Alan Gilbert" Signed-off-by: Gerd Hoffmann Reviewed-by: Dr. David Alan Gilbert Message-id: 20171030102830.4469-1-kraxel@redhat.com --- hw/display/vga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 1d19f6bc48..a64a0942da 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1666,9 +1666,9 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) /* scanline wraps from end of video memory to the start */ assert(force_shadow); update =3D memory_region_snapshot_get_dirty(&s->vram, snap, - page0, 0); + page0, s->vbe_size -= page0); update |=3D memory_region_snapshot_get_dirty(&s->vram, snap, - page1, 0); + 0, page1); } else { update =3D memory_region_snapshot_get_dirty(&s->vram, snap, page0, page1 - page0= ); --=20 2.9.3 From nobody Fri May 3 11:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151032052284191.22313027490964; Fri, 10 Nov 2017 05:28:42 -0800 (PST) Received: from localhost ([::1]:41722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9MB-0005gg-FH for importer@patchew.org; Fri, 10 Nov 2017 08:28:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD9Kf-0004j6-H9 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eD9Kc-0001VO-Hx for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eD9Kc-0001Sq-AY for qemu-devel@nongnu.org; Fri, 10 Nov 2017 08:26:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D286C4ACAD; Fri, 10 Nov 2017 13:26:48 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E3F262682; Fri, 10 Nov 2017 13:26:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4E421409C2; Fri, 10 Nov 2017 14:26:44 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 10 Nov 2017 14:26:44 +0100 Message-Id: <20171110132644.8069-4-kraxel@redhat.com> In-Reply-To: <20171110132644.8069-1-kraxel@redhat.com> References: <20171110132644.8069-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 10 Nov 2017 13:26:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] vmsvga: use ARRAY_SIZE macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.co= cci Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20170718061005.29518-23-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann --- hw/display/vmware_vga.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index cdc3fed6ca..0e6673a911 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -679,10 +679,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) if (cursor.width > 256 || cursor.height > 256 || cursor.bpp > 32 - || SVGA_BITMAP_SIZE(x, y) - > sizeof(cursor.mask) / sizeof(cursor.mask[0]) + || SVGA_BITMAP_SIZE(x, y) > ARRAY_SIZE(cursor.mask) || SVGA_PIXMAP_SIZE(x, y, cursor.bpp) - > sizeof(cursor.image) / sizeof(cursor.image[0])) { + > ARRAY_SIZE(cursor.image)) { goto badcmd; } =20 --=20 2.9.3