From nobody Mon Nov 23 04:44:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792300119; cv=none; d=zohomail.com; s=zohoarc; b=h1Kei0kzLmMyT58QPqz2WukKi9oYH8b1+WlH0LxNbbWR2ZzC0Mr7/B2r4rfrqB7nXdZZK8x4Tb/7ZQUmjMgZP2O3fCN9BnmUOvZpOWm2F8698zVXia5+14Fj5KewhHK3cfSqjVQg3QvwZO0BRJWllWrOXtqrLWJhWRrf3P65sTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792300119; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sLumoPCNx3w4msV4H1DVAECrtEfpjsklvCNNXbL76Ss=; b=T4Fei+PzOwfZbpBMH8JWDLhjg5zeYK3bk6E+7ekVcw9uKWZkNMqPandq4cQYmUM+xeRrpQPIzCbKWWTEyxjTZe1HI1aIzXu2uLgZAhs/loc+Mq0YpICxy78J9WMoL6F+IzZfdDM3fuhh2ytotUUgZaJBGnBYfFR5U8XJ8knhrY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792300118740236.4107061682546; Sat, 17 Oct 2026 22:08:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIJ7T-0005H0-Ep; Sun, 18 Oct 2026 01:07:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7M-0005Fy-F8 for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:34 -0400 Received: from nx101.node01.secure-mailgate.com ([89.22.108.101]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7J-0000R1-1o for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:32 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xIJ7D-007SYI-0r; Sun, 18 Oct 2026 07:07:24 +0200 Received: from Zeuss.fritz.box (p57b2fda0.dip0.t-ipconnect.de [87.178.253.160]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id DE73F28249E; Sun, 18 Oct 2026 07:07:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792300042; bh=sLumoPCNx3w4msV4H1DVAECrtEfpjsklvCNNXbL76Ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lbfr2YAZuP0rjiFQR3mFUSk8DS3U6Wqn5aFx3p+gaJTRMkNc7kqxJUgu5qLVjrTLO 4gWIa1WvIp7kgeTZvOfLCMd0PCIHe2Ugg+7vmAZm45Y1HZ7xBokY0vd2XR0umpnxRh PWvnT2w+DeByek+a97Pr62PZQKobuZ8gWQDq8Kao= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Subject: [PATCH 1/5] hw/display/cirrus_vga: keep the first pattern line of pattern copies Date: Sun, 18 Oct 2026 07:06:36 +0200 Message-ID: <20261018050643.9288-2-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261018050643.9288-1-christian@quante.one> References: <20261018050643.9288-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179230004254.350301.13491900774536336594@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (0.00847495000297) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuUYf7D5RrFHKCCGOd9eAuRo4npbykwg+Hw5 lsIpQih3biu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4YUvRt+4fVzO4T3YJSqWrgRS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+u/6qIuBtLkUxxV/USyR/jsPP/MCh2vuy1qkC9R2Zq1 OIxftLFiIG/X4GfHDaa3wC7khuxzFU2bz86WcStZ9QDBWBV+VvfCWXzOFA86fiNrdzMm0SdkvtPi +Iq6MyMtFurwZq5jIWjWaWrcrm6J715pRUFUU5/JtLKKEUu4esXRIHI76+ca/5h6FPCn2NRyv+0S joXDm2V1p5BMPuhfQhsmM/DC/DhXrp3X/X+gfREw6g1HPUZN+/YDk1iDa8+ZxxSD72O80aZymZQ6 saaeLqKzk+1FWQ+vJ8qzoMDtBircbQfpeuvl6KSFHsYhSuAb84SayjpolrWTGg0Av+kj2J3N97Xf AMjOQomVJmutBSifOApbHKd03ZB+qAOqT4n/dInV2uoHT6Dm0GQ6r7K5ojRWwyPW8g9J7yY4N5Ts aRvkTyUSJMk9tcqbKhjVPIwqdohMEvROmHCsrGB54/25AlYqt40VpHjmmImp9HqkmCpM13LYM3A6 BXfvel8OEFDbU51jSannrGt99/u9tTmLLSzXBBVweHe0r89stuxGFeu80GpAnro7wkLz+qqKVK/b 25koCP9WDMcj98RpkTKo8yhtOAzTa0Q8K7yJ5sEoHdAShzei2jS295YZuTF+Fa0pfd5S1IJp6mFV PAC/2g1mDXLy2Elbx0EUnn3hiOC609jGD36MJUDkyKfV9QiUGsZMVVj2OKHH5lr9xXvSM4nM3avg X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.101; envelope-from=christian@quante.one; helo=nx101.node01.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792300121985158500 Content-Type: text/plain; charset="utf-8" For a pattern copy BitBLT, the pattern starts at a multiple of its size in video memory, and the three low bits of the source address (GR2C) select the first line of the 8x8 pattern. CL-GD5446 Technical Reference Manual (November 1996), page 9-28: "The patterns must be stored beginning on a boundary equal to the size of the pattern itself. The vertical offset into the pattern is then programmed into the three low-order bits of the Source Address (register GR2C)." A monochrome (color expanded) pattern has 8 bytes, a color pattern 64, 128 or 256 bytes (GR30 bit 6, page 5-11). The table there asks only for dword alignment of a monochrome pattern, but as the three low bits select the line, the pattern itself starts at a multiple of 8. Since commit 95280c31cda7 ("cirrus: fix patterncopy checks"), cirrus_bitblt_common_patterncopy() rounds cirrus_blt_srcaddr down to the pattern size in place. This has two effects: - The raster operations take the first pattern line from cirrus_blt_srcaddr & 7 (cirrus_vga_rop2.h). After the rounding this is always 0. - For a monochrome pattern the rounding uses the size of a color pattern, so the BitBLT can read the wrong 8 bytes. For example, in 8 bpp the source address 0x4b073 (pattern at 0x4b070, first line 3) becomes 0x4b040 (first line 0). Keep cirrus_blt_srcaddr unchanged and give the rounded address to the raster operation. Use 8 bytes as the size of a monochrome pattern, also in the range check. Seen on OS/2 2.1 with IBM's CL-GD5436/46 display driver (version 1.14) on cirrus-vga: the gray background of selected icon titles has a dotted edge, and so have some window frames. With this patch they are solid. Fixes: 95280c31cda7 ("cirrus: fix patterncopy checks") Signed-off-by: Christian Quante --- hw/display/cirrus_vga.c | 44 +++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 0a8c74e137..67f08b84b1 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -659,25 +659,36 @@ static void cirrus_invalidate_region(CirrusVGAState *= s, int off_begin, static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s) { uint32_t patternsize; + uint32_t patternaddr =3D 0; bool videosrc =3D !s->cirrus_srccounter; =20 if (videosrc) { - switch (s->vga.get_bpp(&s->vga)) { - case 8: - patternsize =3D 64; - break; - case 15: - case 16: - patternsize =3D 128; - break; - case 24: - case 32: - default: - patternsize =3D 256; - break; + if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { + patternsize =3D 8; + } else { + switch (s->vga.get_bpp(&s->vga)) { + case 8: + patternsize =3D 64; + break; + case 15: + case 16: + patternsize =3D 128; + break; + case 24: + case 32: + default: + patternsize =3D 256; + break; + } } - s->cirrus_blt_srcaddr &=3D ~(patternsize - 1); - if (s->cirrus_blt_srcaddr + patternsize > s->vga.vram_size) { + /* + * The pattern starts at a multiple of its size. The three low + * bits of the source address select the first pattern line; the + * raster operations take them from cirrus_blt_srcaddr, so the + * aligned address goes into patternaddr. + */ + patternaddr =3D s->cirrus_blt_srcaddr & ~(patternsize - 1); + if (patternaddr + patternsize > s->vga.vram_size) { return 0; } } @@ -686,8 +697,7 @@ static int cirrus_bitblt_common_patterncopy(CirrusVGASt= ate *s) return 0; } =20 - (*s->cirrus_rop) (s, s->cirrus_blt_dstaddr, - videosrc ? s->cirrus_blt_srcaddr : 0, + (*s->cirrus_rop) (s, s->cirrus_blt_dstaddr, patternaddr, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, --=20 2.53.0 From nobody Mon Nov 23 04:44:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792300155; cv=none; d=zohomail.com; s=zohoarc; b=norkeCLNVE5/ntSQoxdwkepryi11Kzr4CAllLJ9fgS6dtsQDj/hSEZy3nW4NyXva70WvVhZulzYsQgKDT4EFn5JXqWWuLOPP0u6fALFl4j0c5Xyo06p6NcxIrxHP3mzQCRCchfBuhoujOIL6fMc3FNmIZTHkGl0vvAzlCK6bpZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792300155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Iklw7fQWXSq1SHfnE4m+poSqGQhdEwTVPZ/WQgeULnY=; b=eRamtbMWVoU4XYSnpItAzaRRpVhH2hB9jkGb3Y9Et4+hJ4eVLSXu7tRQotMUcEjnVxG3HWV6es2NKkzQKUx+Sl7+n0TnXGYoATgs8HGPPe/VjV4VeJmxnNmEU8y5kxwA19LAaKbtjhFf8Q+GXBUIVJdmQ7TNK3S/5BDcm1/JP8E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792300155311783.7054669504688; Sat, 17 Oct 2026 22:09:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIJ7R-0005GX-5o; Sun, 18 Oct 2026 01:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7K-0005FW-Qe for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:30 -0400 Received: from nx38.node02.secure-mailgate.com ([192.162.87.38]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7I-0000R3-Uy for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:30 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node02.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xIJ7D-00HSX1-Lq; Sun, 18 Oct 2026 07:07:24 +0200 Received: from Zeuss.fritz.box (p57b2fda0.dip0.t-ipconnect.de [87.178.253.160]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id BBDF2282AB1; Sun, 18 Oct 2026 07:07:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792300043; bh=Iklw7fQWXSq1SHfnE4m+poSqGQhdEwTVPZ/WQgeULnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NvbYSApe96zbWwmz07TLZ9OZ1pa+f/WBRYgyZOLai3BnWxlXv2bSOUdPJK2rKnwVk DnRRL8FVT7otzGVvTmss8rYrBcjU3xlvfk5mYdyNjtk6nRYhIulLq94oY3qMpBMjXc uVijA+Ex9PtxqX+PSA34H9bzEQ5Or8eVjS/zn+UU= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Subject: [PATCH 2/5] hw/display/cirrus_vga: fix the source pitch for DWORD granularity Date: Sun, 18 Oct 2026 07:06:37 +0200 Message-ID: <20261018050643.9288-3-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261018050643.9288-1-christian@quante.one> References: <20261018050643.9288-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179230004336.350365.3153587032284518109@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: Combined (0.08) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuVtKatNhWyh+qJMixbyr+NDLqG6eKxYMh8g 5kZtVcIjPyu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4YiOKwe4OkQcF8o/vp/2pjmS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6A6B6pTstltS07kaQJ8I9sYal0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgnsj5xBssn0tIIHA3aH QzCq60l8YRpcxCjc2gcMa3Btw+OTpzU5Yy8oe2B0dJEHaEkiihVil/4PKs38NtnG3PEGvDsoH6Px tvFZEJq1ao2KNy9dwVQOvQDAu0j1lWbRUnFLa86GAO38LUYomBaWJiGeaRPFPlsNwIEW3NK+ERUy VlEF1GGlhZVmIXQ9yRY52/AOUNajOgnyG49cHXrfXNCdkxagxqTy3Eelsrf2AHilqGAJUsGkiX9p nLLp9ipqVxozPuHcArodRAPA4GpBiyiifOlKRGVSbUqHNBE5RvuLCfvg7iEFLP+SSY+Av5+AiC4O kD+PiVGEaS3l/oNDuDtw2R0VB+Wa1Hi5lu/dimywHIDoo4KS2zV8wXW4Nyy5moRk24FpRrr227/4 WdvfheWFj9/jJzejnm6DfFR5Y2NqPZ5SKztf/xEq+WccjXvWLPu81n1xxtsUl7n6yEc2zbQZ8at/ mpOirO4Aj7K7pCc7It7M0BeNcjKlgO6G3s/AZZZkg1ObUHtEfHVEAI/Q+wksCpzwZQOg2V2O/Kq5 tEtQFjmrlTIeC9/t50fQ6GKDIe6Uoh6OGJZG7AGpT0SbVAiZIbtf63VNbf0lrvssY+k7ACm5OdrJ neDw5nGUT85QJA56jvJsmaZpbKRZNsABnVcYYo7nDw+/+Xvf0phT65CN5MWcxP6fTfjYjs4lNimJ +IXhHybVHWnukQ5J3NZf3Sto4BAah0N3qPEwUyYM+XoU0gPKPpjFSmnirfv07lDyNv3Z9gjPYs8T OOI1p+50WdIyJ84MPqAerJyLyS8xGYvhuzEvuGslKTrRIXcXpFg5ivY= X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=192.162.87.38; envelope-from=christian@quante.one; helo=nx38.node02.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792300156776158500 Content-Type: text/plain; charset="utf-8" With GR33 bit 0 set, each line of source data for a color expanded system-to-screen BitBLT starts at a new dword. CL-GD5446 Technical Reference Manual (November 1996), GR33 (page 5-17): "At the end of each scanline, unused source data is discarded to the end of the current dword. The next scanline begins with the next dword." For this case cirrus_bitblt_cputovideo() sets cirrus_blt_srcpitch to ((w + 31) >> 5). This is the number of dwords per line, but cirrus_blt_srcpitch counts bytes. QEMU takes only a quarter of the data for each line and ends the BitBLT too early. The rest of the data goes to video memory as pixels. XFree86 3.3.6 (XF86_SVGA) uses this mode on the CL-GD5436/46 for all text drawn with the BitBLT engine. In the installer of SuSE Linux 7.0 with -vga cirrus and TCG, most of the text is only a few dots, and garbage appears in the top lines of the screen. With this patch, the text is correct. With KVM, the installer also needs "hw/display/cirrus_vga: do not coalesce the writes that start a BitBLT". Resolves: https://gitlab.com/qemu-project/qemu/-/issues/988 Signed-off-by: Christian Quante --- Notes: The CL-GD5436/46 display driver for Windows 3.1 uses this mode for wide characters; without this patch they are garbled. Windows for Workgroups 3.11 with this driver also needs "hw/display/cirrus_vga: add the byte swapping PCI apertures 1 and 2", which I will send after this series, to show any text. hw/display/cirrus_vga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 67f08b84b1..dc216cde56 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -901,7 +901,7 @@ static int cirrus_bitblt_cputovideo(CirrusVGAState * s) if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { w =3D s->cirrus_blt_width / s->cirrus_blt_pixelwidth; if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_DWORDGRANULARITY) - s->cirrus_blt_srcpitch =3D ((w + 31) >> 5); + s->cirrus_blt_srcpitch =3D ((w + 31) >> 5) * 4; else s->cirrus_blt_srcpitch =3D ((w + 7) >> 3); } else { --=20 2.53.0 From nobody Mon Nov 23 04:44:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792300101; cv=none; d=zohomail.com; s=zohoarc; b=QbgjdVrcMZzrCuaEqoBADCmX5z5j3oaB2oSRXybkhSfNQNroS1KfaNQx3wQAKKpirnXcvJ4WtKEFqi3qtb/EZ0hHfN/BwiAagiUsEJlT9upkbUq12Ht5Kq2QdL2f4ba1HVyt8mDu5uEAASBGU4mpdBY3LViXsBPMBZIXR4uEFQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792300101; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DYyNvL8tDbIAMxbH/3iWlej8cQTmukMMzPn0ya0G24o=; b=ITCsOZVolkvxvTsZKELwryFESuKWHAb3/CnMFLixhB2OglZSRudzXO4vf4Vm5UqI+k2Z+Yp4k+OaiC2NBflOG/HhwLe8Yhb06owUH28sgbpHa8UdVeq7FhPEfQvOx2bFkfpkNgb9U8amAgAU6H7L2J6rA9aUbl5p3ltsg8B4qco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792300101554712.434384349026; Sat, 17 Oct 2026 22:08:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIJ7R-0005Gp-Jd; Sun, 18 Oct 2026 01:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7M-0005Fx-CE for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:33 -0400 Received: from nx244.node01.secure-mailgate.com ([89.22.108.244]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7J-0000R8-1A for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:32 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xIJ7E-007Sez-DK; Sun, 18 Oct 2026 07:07:25 +0200 Received: from Zeuss.fritz.box (p57b2fda0.dip0.t-ipconnect.de [87.178.253.160]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id 996F1282B48; Sun, 18 Oct 2026 07:07:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792300044; bh=DYyNvL8tDbIAMxbH/3iWlej8cQTmukMMzPn0ya0G24o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=4mkXKox6nXNIdjTOF7l2as+TG68JIwgEWIBwkcblwpWklnN/Gtiv60OZnYyQNBH/e WfxgYg/+W2V4agPDtSBLqpPceGaFw/SPcEGHNuj8eo2y8f4xu9gFWS6+BUKGjeGdV+ zsPTHOWGn/ucxu1YnoCrRLoZ0E2SZFWTPPwfhpH0= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Subject: [PATCH 3/5] hw/display/cirrus_vga: do not coalesce the writes that start a BitBLT Date: Sun, 18 Oct 2026 07:06:38 +0200 Message-ID: <20261018050643.9288-4-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261018050643.9288-1-christian@quante.one> References: <20261018050643.9288-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179230004415.350423.13866190684134073730@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (0.00139839614542) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuVUEmWtDgz/yHns/gkOHaf8e0ZHIn1ei4lP kS6jdlHKYiu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4Zlp2ux2uZbaMww04XuzFflS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+u/6qIuBtLkUxxV/USyR/jsPP/MCh2vuy1qkC9R2Zq1 OIxftLFiIG/X4GfHDaa3wC7khuxzFU2bz86WcStZ9QDBWBV+VvfCWXzOFA86fiNrdzMm0SdkvtPi +Iq6MyMtFurwZq5jIWjWaWrcrm6J715pRUFUU5/JtLKKEUu4esXRIHI76+ca/5h6FPCn2NRyv+0S joXDm2V1p5BMPuhfQhsmM/DC/DhXrp3X/X+gfREw6g1HPUZN+/YDk1iDa8+ZxxTIPlCVU2If9Fs6 7e67qB3xk+1FWQ+vJ8qzoMDtBircbQfpeuvl6KSFHsYhSuAb84SayjpolrWTGg0Av+kj2J3N97Xf AMjOQomVJmutBSifOApbHKd03ZB+qAOqT4n/dInV2uoHT6Dm0GQ6r7K5ojRWwyPW8g9J7yY4N5Ts aRvkTyUSJMk9tcqbKhjVPIwqdohMEvROmHCsrGB54/25AlYqbIOk1hoT+kVGe8ZrzHhI63LYM3A6 BXfvel8OEFDbU51jSannrGt99/u9tTmLLSzXBBVweHe0r89stuxGFeu80GpAnro7wkLz+qqKVK/b 25koCP9WDMcj98RpkTKo8yhtOAzTa0Q8K7yJ5sEoHdAShzei2jS295YZuTF+Fa0pfd5S1IJp6mFV PAC/2g1mDXLy2Elbx0EUnn3hiOC609jGD36MJUDkyKfV9QiUGsZMVVj2OKHH5lr9xXvSM4nM3avg X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.244; envelope-from=christian@quante.one; helo=nx244.node01.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792300106740158500 Content-Type: text/plain; charset="utf-8" cirrus_init_common() marks the whole legacy window 0xa0000-0xbffff for coalesced MMIO. This includes the memory-mapped BitBLT registers at 0xb8000-0xb80ff (SR17 bit 2 set, bit 6 clear). With KVM, writes to these registers wait in the coalesced MMIO ring until QEMU flushes the ring, for example before the next access to a region with flush_coalesced_mmio set. Most of these writes only set parameters, but two of them start a BitBLT: the write of GR2A (destination address) with autostart (GR31 bit 7), and the write of GR31. For a system-to-screen BitBLT, the guest then writes the source data. If it writes them to the linear frame buffer or to the bank window at 0xa0000, they go straight to video memory: both are plain RAM until cirrus_bitblt_start() has run and unmapped them. The source data are lost. When the guest reads GR31 to wait for the end of the BitBLT, the ring is flushed, the BitBLT starts and waits for data that do not come. GR31 stays busy until the driver gives up. XFree86 3.3.6 (XF86_SVGA) on the CL-GD5436/46 programs the BitBLT through these registers with autostart, and writes the source data for text to the linear frame buffer. In the installer of SuSE Linux 7.0 with KVM, the X server runs into the time-out of its wait loop for each piece of text, and most text is missing. Commit f65ed4c1529f ("KVM: Coalesced MMIO support") added the coalescing for writes "if those writes do not have side effects". Keep it for the rest of the window and for the parameter registers, but not for the bytes of GR2A and GR31. A write to one of these bytes leaves the guest at once; KVM coalesces only writes that lie completely inside one zone (virt/kvm/coalesced_mmio.c), so this is also true for a dword write to offset 0x10. The region has flush_coalesced_mmio set, so QEMU first processes the parameter writes from the ring and then starts the BitBLT. The two bytes are excluded from coalescing also while the BitBLT registers are not mapped at 0xb8000. In a text mode, 0xb8012 and 0xb8040 are then part of the text buffer, and a write to one of them leaves the guest at once. With KVM, a screen-to-screen BitBLT that the guest programs with nine writes to these registers takes 12.8 us with this patch, and 8.1 us with the coalescing for all registers. If none of the 256 bytes of the registers is coalesced, it takes 26.0 us. Signed-off-by: Christian Quante --- Notes: Two more guests show this with KVM, but they need other Cirrus patches of mine to get this far, which I will send after this series: - Windows for Workgroups 3.11 with the CL-GD5436/46 display driver for Windows 3.1 (needs "hw/display/cirrus_vga: add the byte swapping PCI apertures 1 and 2"): single characters and the STOP icon are missing, and the hourglass stays. - OS/2 Warp 3 with its Cirrus driver on isa-cirrus-vga (needs "hw/display/cirrus_vga: read back the cursor position bits of SR10/SR11"): the driver hangs while it draws the desktop. hw/display/cirrus_vga.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index dc216cde56..6f1f9ac82f 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2847,6 +2847,21 @@ static const MemoryRegionOps cirrus_vga_io_ops =3D { }, }; =20 +/* + * Coalesce the writes to the legacy window 0xa0000-0xbffff, but not to the + * two bytes of the memory-mapped BitBLT registers whose write can start a + * BitBLT: GR2A (with autostart) and GR31. + */ +static void cirrus_coalesce_low_mem(CirrusVGAState *s) +{ + hwaddr gr2a =3D 0x18000 + CIRRUS_MMIO_BLTDESTADDR + 2; + hwaddr gr31 =3D 0x18000 + CIRRUS_MMIO_BLTSTATUS; + + memory_region_add_coalescing(&s->low_mem, 0, gr2a); + memory_region_add_coalescing(&s->low_mem, gr2a + 1, gr31 - gr2a - 1); + memory_region_add_coalescing(&s->low_mem, gr31 + 1, 0x20000 - gr31 - 1= ); +} + void cirrus_init_common(CirrusVGAState *s, Object *owner, int device_id, int is_pci, MemoryRegion *system_memory, MemoryRegion *system_= io) @@ -2907,7 +2922,7 @@ void cirrus_init_common(CirrusVGAState *s, Object *ow= ner, 0x000a0000, &s->low_mem_container, 1); - memory_region_set_coalescing(&s->low_mem); + cirrus_coalesce_low_mem(s); =20 /* I/O handler for LFB */ memory_region_init_io(&s->cirrus_linear_io, owner, &cirrus_linear_io_o= ps, s, --=20 2.53.0 From nobody Mon Nov 23 04:44:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792300139; cv=none; d=zohomail.com; s=zohoarc; b=kBftg2L6G+AW7ko2+XjDmZAbTWW/LLdrP8kFORRSxS2xE5JA7YwL0Q3zDj67cDqJiZcz81G5XhhXIIugGoSy4sHMwehSicjfPiJbfhpi8DSAtbwvnUbrV/2PFYkJDooknf7Cl+gr8Mnv+6n4Y1T38PCedSKPR8Qu8fUdaY9R8Yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792300139; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y7aKdl6bcJ65SzFuNLTMYbUr5fWCRCMM+QujLhMKn4I=; b=KbORYSYykxxJ8QpaRtpZrT+5WIscBa+exKU+g4pL/Rm0UeEKVHakCHKmfdtfO1Bem+s9aief7lAy7pz45zEMpmU9UUGqe3zH2h1oFTR3uJe0GjJI8ogs7mAWnyXp8xgFz6fvzHiaSRgZ/GjhomYW3Whph/Qv6VcymCc80q97aGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792300139072498.98512413791525; Sat, 17 Oct 2026 22:08:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIJ7R-0005Gn-EM; Sun, 18 Oct 2026 01:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7K-0005FX-US for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:31 -0400 Received: from nx244.node01.secure-mailgate.com ([89.22.108.244]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7I-0000RE-V2 for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:30 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xIJ7F-007Sg0-5a; Sun, 18 Oct 2026 07:07:26 +0200 Received: from Zeuss.fritz.box (p57b2fda0.dip0.t-ipconnect.de [87.178.253.160]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id 5C30A28249E; Sun, 18 Oct 2026 07:07:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792300045; bh=y7aKdl6bcJ65SzFuNLTMYbUr5fWCRCMM+QujLhMKn4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbGSAKa0NYtu1xkwP9a1+qHnyfCcqWKLP57tt1DDn54rKqyLiCc8Rq3FKpOEf8oeq wreLXhVJ3uznumgMTLnRnN8s7R/N8jwtuV6oK58yOtzSEjUyppipKT9rgY1fyVeAOl ii5uxG4tKPOxMmj3VuAJ7ouGOYl5kxYsSRXPJ4c0= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/display/cirrus_vga: allow a zero source pitch for color expansion Date: Sun, 18 Oct 2026 07:06:39 +0200 Message-ID: <20261018050643.9288-5-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261018050643.9288-1-christian@quante.one> References: <20261018050643.9288-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179230004489.350469.4318212911775297300@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: Combined (0.05) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuWGtT23HaGabxKUFDNb9gVc5cXphpG3q+Io QC8RsdtJ2yu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4a+4+3tKfzkMI5eEXc895tcS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgnsj5xBssn0tIIHA3aH QzCq60l8YRpcxCjc2gcMa3Btw+OTpzU5Yy8oe2B0dJEHaEkiihVil/4PKs38NtnG3PEGvDsoH6Px tvFZEJq1ao2KNy9dwVQOvQDAu0j1lWbRUnFLa86GAO38LUYomBaWJiGeaRPFPlsNwIEW3NK+ERUy VlEF1GGlhZVmIXQ9yRY52/AOUNajOgnyG49cHXrfXNCdkxagxqTy3Eelsrf2AHilqGAJUsGkiX9p nLLp9ipqVxozPuHcArodRAPA4GpBiyiifOlKRGVSbUqHNBE5RvuLCfvg7iEFLP+SSY+Av5+AiC4O kD+PiVGEaS3l/oNDuDtwZmwWPuALIZF8Yr837xKlqbHn/8HJ4gJhwHkEiz+DPkNk24FpRrr227/4 WdvfheWFj9/jJzejnm6DfFR5Y2NqPZ5SKztf/xEq+WccjXvWLPu81n1xxtsUl7n6yEc2zbQZ8at/ mpOirO4Aj7K7pCc7It7M0BeNcjKlgO6G3s/AZZZkg1ObUHtEfHVEAI/Q+wksCpzwZQOg2V2O/Kq5 tEtQFl9fEZU8CSQ0vuHcjO6LZzjzwKJtK7Oq7d/qp+/cxt5UIbtf63VNbf0lrvssY+k7ACm5OdrJ neDw5nGUT85QJA56jvJsmaZpbKRZNsABnVcYYo7nDw+/+Xvf0phT65CN5MWcxP6fTfjYjs4lNimJ +IXhHybVHWnukQ5J3NZf3Sto4BAah0N3qPEwUyYM+XoU0gPKPpjFSmnirfv07lDyNv3Z9gjPYs8T OOI1p+50WdIyJ84MPqAerJyLyS8xGYvhuzEvuGslKTrRIXcXpFg5ivY= X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.244; envelope-from=christian@quante.one; helo=nx244.node01.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792300140565158500 Content-Type: text/plain; charset="utf-8" For a color expansion BitBLT from video memory, the source pitch has no meaning. CL-GD5446 Technical Reference Manual (November 1996), GR30 bit 7 (page 5-11): "When the source of color-expand data is display memory, the source pitch is ignored." Page 9-20: "When the BitBLT uses color expansion or pattern copy, the source is considered a linear string of bytes, and the source pitch is a don't care." The raster operations for color expansion in cirrus_vga_rop2.h do not use it either. Since commit 4299b90e9ba9 ("display: cirrus: check vga bits per pixel(bpp) value"), blit_region_is_unsafe() rejects a pitch of 0. blit_is_unsafe() uses it for the source of each screen-to-screen BitBLT that is not a pattern copy, so a color expansion with a source pitch of 0 is dropped and draws nothing. For pattern copies, commit 95280c31cda7 ("cirrus: fix patterncopy checks") moved the source check to cirrus_bitblt_common_patterncopy(). For a color expansion, check the source in the way the raster operations read it: a linear string of bytes, one bit per pixel, each line starting with a new byte. A plain copy with a source pitch of 0 is still rejected, because cirrus_do_copy() divides by the source pitch. Fixes: 4299b90e9ba9 ("display: cirrus: check vga bits per pixel(bpp) value") Signed-off-by: Christian Quante --- Notes: Seen with the Cirrus driver of OS/2 Warp 3 (isa-cirrus-vga, 1024x768, 16 bpp, TCG). It keeps the glyphs of a font in off-screen video memory and draws the characters with color expansions from there (transparent ones for the text of the LaunchPad). It does not write the source pitch for these BitBLTs. Until its first BitBLT that needs a source pitch, the source pitch is 0, and the text that the driver draws in this time is missing. In the test VM, these are the 45 characters on the buttons of the LaunchPad (the OS/2 toolbar) after boot; only the underlines of the keyboard shortcuts are there. With this patch, the text is correct. This guest needs "hw/display/cirrus_vga: read back the cursor position bits of SR10/SR11" to start, which I will send after this series. hw/display/cirrus_vga.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 6f1f9ac82f..4ed624bd84 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -248,6 +248,17 @@ static bool blit_is_unsafe(struct CirrusVGAState *s, b= ool dst_only) if (dst_only) { return false; } + if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { + /* + * The raster operations read the source of a color expansion as + * a linear string of bytes, one bit per pixel, each line starting + * with a new byte. The source pitch is not used. + */ + int64_t len =3D (int64_t)s->cirrus_blt_height * + DIV_ROUND_UP(DIV_ROUND_UP(s->cirrus_blt_width, + s->cirrus_blt_pixelwidth), 8); + return s->cirrus_blt_srcaddr + len > s->vga.vram_size; + } if (blit_region_is_unsafe(s, s->cirrus_blt_srcpitch, s->cirrus_blt_srcaddr)) { return true; --=20 2.53.0 From nobody Mon Nov 23 04:44:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792300102; cv=none; d=zohomail.com; s=zohoarc; b=MHnDdnWZ+0meLgmoEz37lqSFsQU0rkIPeFP6pMQILCW+SQFV/BTprj/k15yevEehHF9ASFylSNpsw+xFrov3X9SpDYyviOfzofYMKnnxNGWOZTmJSagZtL10Iz7U2C5SCrsfGRr8R5UFnccBUtofJyVMfR2o2rOq+klfJXWhpuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792300102; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ho22ubS8OSaULynIJkCJOF+Am/Qd/t6JqmPHlBLYuHs=; b=ApC74RN3Vdt9tUDojMuD9COuvjerEeP846kVNQ3n8rOVGiqUKdQAZ8z0Nz7WXbfq1jBH07snoJ8j4K+QeAfSajcMKI7TFXfMU6BfZyetOv007+8CYBsz+cKcIZ1ZKseh3s0uX0pDbIBER3WMNkQqSWbYG6xpyUhXH8D1JImzvbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792300102619108.39328822757216; Sat, 17 Oct 2026 22:08:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIJ7V-0005HB-IR; Sun, 18 Oct 2026 01:07:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7N-0005Fz-8L for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:34 -0400 Received: from nx104.node02.secure-mailgate.com ([192.162.87.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xIJ7J-0000RK-HA for qemu-devel@nongnu.org; Sun, 18 Oct 2026 01:07:32 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node02.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xIJ7G-00HSah-05; Sun, 18 Oct 2026 07:07:27 +0200 Received: from Zeuss.fritz.box (p57b2fda0.dip0.t-ipconnect.de [87.178.253.160]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id 22052282AB1; Sun, 18 Oct 2026 07:07:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792300045; bh=ho22ubS8OSaULynIJkCJOF+Am/Qd/t6JqmPHlBLYuHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GbZWBMY2kvLXUaZk9ULMsKIwkXuDz5RMhGsjVyPtzwdRbhNLPINbx83mzIknrX/be 4BtuDWljTgbMexiXiRNzekxnOMv31tkENWPM2dVDkGN+/zQpiIS+nYkhy9T5p/IyIk 7vmK4au+ViuGSGSPdVYIRDTIXJaMHdIixtYhh/A4= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PATCH 5/5] tests/qtest: add tests for the Cirrus BitBLT engine Date: Sun, 18 Oct 2026 07:06:40 +0200 Message-ID: <20261018050643.9288-6-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261018050643.9288-1-christian@quante.one> References: <20261018050643.9288-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179230004573.350520.15919160623917232914@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (8.43192183297e-07) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuV7RwrPKr7u81fjG5H8ZCDAaQIW1v7YYoZp UgG+EGbr7Cu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4ZT9g0xXHoQFcoBjLaj1yDrS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6A6B6pTstltS07kaQJ8I9sYal0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+u/6qIuBtLkUxxV/USyR/jsy3xQl12nwobNyEeX2iOu PBl1nTKzT0QzJq+XCCX+bItbKfrvYBbAljkt7Epzm3J555HUEfecDXLZTChT+dXw9cANBiw5IFvS J1+AiFojfzPxvTAOUZAymq64nP6eBCAXlLotyYa3jHxAO+eLLGkexw5uvJef8mVqbzbGrd9kfjMz JtEnZL7T4viKujMjLRbqYSzwjr1vpRkAvfd1aGp6GuUr7e3rKguV1/75QC4uRp/Egi+5tFGx/YER vDQsXWFPEo6Fw5tldaeQTD7oX0IbJmI/EcTe67+lFg16JEjoKkgfyFzdptj5x2Xs0Np8JC6g4s+x VWXt18LWSglFmXcG20WdUaEnAzrKtj2q24UDob0ub7T76xshSOuiuvUbo76cZzhh7v2iYWfi4Fnw z1DC9Pe13wDIzkKJlSZrrQUonzgKWxyndN2QfqgDqk+J/3SJfvGPO7To2xFpzad+qFkyH+EOwtjK uuff4Uza3eRtXeHZ2pJLJEsFo7eeWHjv6VlKvaJ4DkGgPykBDCm+SdtsjAaM6KVr7cAerFJU/J5e Z6py2DNwOgV373pfDhBQ21Od8Px2uW0YBguFiyOt4UgMCMOJnQd2h4zl0/7hwkh8dMyNKfvbwnpS 9+19ePGD0GXiVkNMntLVqQTTb3SbSKh8/E6OUoXc2DfYzVpSUI2bAjk3oto0tveWGbkxfhWtKX3e xevHXeZU/cwVa7IDYbjreqeQ5gH55RCPMx3qa0pINniPSODOILBgTMuvbqOngFhz9jihx+Za/cV7 0jOJzN2r4A== X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=192.162.87.104; envelope-from=christian@quante.one; helo=nx104.node02.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792300106781158500 Content-Type: text/plain; charset="utf-8" No test checks the result of a Cirrus BitBLT so far; display-vga-test only starts the device. Add cirrus-test, which programs BitBLTs through the graphics controller registers (ports 0x3ce/0x3cf) and checks video memory through the linear frame buffer of cirrus-vga: - pattern copies whose first pattern line is not line 0, with a monochrome and with an 8 bpp color pattern, - a color expansion from the CPU with DWORD granularity (GR33 bit 0), - color expansions from video memory with a source pitch of 0x40 and of 0, opaque and transparent, in 8 and 16 bpp, - a color expansion from video memory whose source would run past the end of video memory; QEMU drops it. Without "keep the first pattern line of pattern copies", the two pattern tests fail; without "fix the source pitch for DWORD granularity", the DWORD test fails; without "allow a zero source pitch for color expansion", the source pitch test fails. The last test checks that the bounds check of that patch stays in place. The coalescing of the BitBLT registers only matters with KVM, so qtest cannot check it. Signed-off-by: Christian Quante --- MAINTAINERS | 1 + tests/qtest/cirrus-test.c | 317 ++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 3 files changed, 319 insertions(+) create mode 100644 tests/qtest/cirrus-test.c diff --git a/MAINTAINERS b/MAINTAINERS index 22caaee967..834610ecef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3011,6 +3011,7 @@ M: Gerd Hoffmann S: Odd Fixes W: https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmfu= l/ F: hw/display/cirrus* +F: tests/qtest/cirrus-test.c =20 EDID Generator M: Gerd Hoffmann diff --git a/tests/qtest/cirrus-test.c b/tests/qtest/cirrus-test.c new file mode 100644 index 0000000000..ae693a888d --- /dev/null +++ b/tests/qtest/cirrus-test.c @@ -0,0 +1,317 @@ +/* + * QTest testcase for the BitBLT engine of the Cirrus VGA emulation + * + * The tests program the BitBLT registers through the ports 0x3ce/0x3cf + * and check video memory through the linear frame buffer (BAR 0). + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "libqtest.h" +#include "libqos/pci.h" +#include "libqos/pci-pc.h" + +#define VRAM_SIZE (4 * MiB) /* default vgamem_mb=3D4 */ + +#define FILL 0x11 /* video memory before a BitBL= T */ +#define FG 0xee /* foreground: GR1, GR11 */ +#define BG 0x22 /* background: GR0, GR10 */ + +/* GR30, BLT mode */ +#define MODE_SYSSRC 0x04 +#define MODE_TRANSP 0x08 +#define MODE_16BPP 0x10 +#define MODE_PATTERN 0x40 +#define MODE_COLOREXP 0x80 + +/* GR33, BLT mode extensions */ +#define MODEEXT_DWORD 0x01 + +typedef struct { + QTestState *qts; + QPCIBus *bus; + QPCIDevice *dev; + QPCIBar fb; +} Cirrus; + +typedef struct { + uint8_t mode, modeext; + int width, height; /* width in bytes */ + int dstpitch, srcpitch; + uint32_t dst, src; +} Blt; + +static void sr(Cirrus *c, uint8_t index, uint8_t val) +{ + qtest_outb(c->qts, 0x3c4, index); + qtest_outb(c->qts, 0x3c5, val); +} + +static void gr(Cirrus *c, uint8_t index, uint8_t val) +{ + qtest_outb(c->qts, 0x3ce, index); + qtest_outb(c->qts, 0x3cf, val); +} + +static void cirrus_start(Cirrus *c) +{ + c->qts =3D qtest_init("-vga none -device cirrus-vga,addr=3D04.0"); + c->bus =3D qpci_new_pc(c->qts, NULL); + c->dev =3D qpci_device_find(c->bus, QPCI_DEVFN(0x4, 0x0)); + g_assert(c->dev); + qpci_device_enable(c->dev); + c->fb =3D qpci_iomap(c->dev, 0, NULL); + + sr(c, 0x06, 0x12); /* unlock the extension registers */ + sr(c, 0x07, 0x01); /* extended mode, 8 bpp */ + gr(c, 0x00, BG); + gr(c, 0x01, FG); + gr(c, 0x10, BG); + gr(c, 0x11, FG); +} + +static void cirrus_stop(Cirrus *c) +{ + g_free(c->dev); + qpci_free_pc(c->bus); + qtest_quit(c->qts); +} + +static void vram_write(Cirrus *c, uint32_t addr, const void *buf, size_t l= en) +{ + qpci_memwrite(c->dev, c->fb, addr, buf, len); +} + +static void vram_read(Cirrus *c, uint32_t addr, void *buf, size_t len) +{ + qpci_memread(c->dev, c->fb, addr, buf, len); +} + +/* Fill the destination rectangle of @b with FILL */ +static void clear_dst(Cirrus *c, const Blt *b) +{ + g_autofree uint8_t *line =3D g_malloc(b->width); + + memset(line, FILL, b->width); + for (int y =3D 0; y < b->height; y++) { + vram_write(c, b->dst + y * b->dstpitch, line, b->width); + } +} + +static void blt_start(Cirrus *c, const Blt *b) +{ + gr(c, 0x20, (b->width - 1) & 0xff); + gr(c, 0x21, (b->width - 1) >> 8); + gr(c, 0x22, (b->height - 1) & 0xff); + gr(c, 0x23, (b->height - 1) >> 8); + gr(c, 0x24, b->dstpitch & 0xff); + gr(c, 0x25, b->dstpitch >> 8); + gr(c, 0x26, b->srcpitch & 0xff); + gr(c, 0x27, b->srcpitch >> 8); + gr(c, 0x28, b->dst & 0xff); + gr(c, 0x29, (b->dst >> 8) & 0xff); + gr(c, 0x2a, b->dst >> 16); + gr(c, 0x2c, b->src & 0xff); + gr(c, 0x2d, (b->src >> 8) & 0xff); + gr(c, 0x2e, b->src >> 16); + gr(c, 0x2f, 0x00); + gr(c, 0x30, b->mode); + gr(c, 0x32, 0x0d); /* ROP: copy the source */ + gr(c, 0x33, b->modeext); + gr(c, 0x31, 0x02); /* start */ +} + +/* + * Check the destination of a color expansion: line y of the destination + * shows the bits of bits[y], most significant bit first. Without + * transparency, 0 bits are drawn in the background color; with + * transparency, they leave FILL in place. + */ +static void check_expansion(Cirrus *c, const Blt *b, const uint8_t *bits) +{ + int bpp =3D b->mode & MODE_16BPP ? 2 : 1; + g_autofree uint8_t *line =3D g_malloc(b->width); + + for (int y =3D 0; y < b->height; y++) { + vram_read(c, b->dst + y * b->dstpitch, line, b->width); + for (int x =3D 0; x < b->width; x++) { + bool set =3D bits[y] & (0x80 >> (x / bpp)); + uint8_t expect =3D set ? FG : (b->mode & MODE_TRANSP) ? FILL := BG; + + g_assert_cmphex(line[x], =3D=3D, expect); + } + } +} + +/* + * A monochrome pattern starts on an 8-byte boundary, and the three low + * bits of the source address select its first line. + */ +static void test_mono_pattern_first_line(void) +{ + static const uint8_t pattern[8] =3D { + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 + }; + Blt b =3D { + .mode =3D MODE_COLOREXP | MODE_PATTERN, + .width =3D 8, .height =3D 8, .dstpitch =3D 64, + .dst =3D 0, .src =3D 0x10008 + 3, + }; + uint8_t bits[8]; + Cirrus c; + + cirrus_start(&c); + vram_write(&c, 0x10008, pattern, sizeof(pattern)); + clear_dst(&c, &b); + blt_start(&c, &b); + for (int y =3D 0; y < 8; y++) { + bits[y] =3D pattern[(3 + y) & 7]; + } + check_expansion(&c, &b, bits); + cirrus_stop(&c); +} + +/* + * An 8 bpp color pattern has 64 bytes, and the three low bits of the + * source address select its first line. + */ +static void test_color_pattern_first_line(void) +{ + Blt b =3D { + .mode =3D MODE_PATTERN, + .width =3D 8, .height =3D 8, .dstpitch =3D 64, + .dst =3D 0, .src =3D 0x10040 + 5, + }; + uint8_t pattern[64], line[8]; + Cirrus c; + + for (int i =3D 0; i < 64; i++) { + pattern[i] =3D 0x40 + i; + } + cirrus_start(&c); + vram_write(&c, 0x10040, pattern, sizeof(pattern)); + clear_dst(&c, &b); + blt_start(&c, &b); + for (int y =3D 0; y < 8; y++) { + vram_read(&c, b.dst + y * b.dstpitch, line, sizeof(line)); + g_assert_cmpmem(line, sizeof(line), &pattern[((5 + y) & 7) * 8], 8= ); + } + cirrus_stop(&c); +} + +/* + * With DWORD granularity (GR33 bit 0), each line of color expansion data + * from the CPU starts with a new dword. + */ +static void test_sysmem_expansion_dword(void) +{ + static const uint8_t bits[4] =3D { 0xf0, 0x81, 0x3c, 0x55 }; + Blt b =3D { + .mode =3D MODE_COLOREXP | MODE_SYSSRC, .modeext =3D MODEEXT_DWORD, + .width =3D 8, .height =3D 4, .dstpitch =3D 64, + .dst =3D 0, + }; + uint8_t data[16]; + Cirrus c; + + /* one byte of pixels per line, then 3 bytes of padding */ + for (int y =3D 0; y < 4; y++) { + data[y * 4] =3D bits[y]; + data[y * 4 + 1] =3D data[y * 4 + 2] =3D data[y * 4 + 3] =3D 0xff; + } + cirrus_start(&c); + clear_dst(&c, &b); + blt_start(&c, &b); + vram_write(&c, 0, data, sizeof(data)); + check_expansion(&c, &b, bits); + cirrus_stop(&c); +} + +/* + * The source pitch has no meaning for a color expansion from video + * memory: the source is a linear string of bytes. Check it with a source + * pitch of 0x40 and of 0, opaque and transparent, in 8 and 16 bpp. + */ +static void test_vram_expansion_pitch(void) +{ + static const uint8_t glyph[8] =3D { + 0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xbd, 0x81, 0xff + }; + static const uint8_t modes[] =3D { + MODE_COLOREXP, + MODE_COLOREXP | MODE_TRANSP, + MODE_COLOREXP | MODE_16BPP, + MODE_COLOREXP | MODE_16BPP | MODE_TRANSP, + }; + static const int srcpitches[] =3D { 0x40, 0 }; + Cirrus c; + + cirrus_start(&c); + vram_write(&c, 0x4000, glyph, sizeof(glyph)); + for (int i =3D 0; i < ARRAY_SIZE(modes); i++) { + for (int j =3D 0; j < ARRAY_SIZE(srcpitches); j++) { + Blt b =3D { + .mode =3D modes[i], + .width =3D modes[i] & MODE_16BPP ? 16 : 8, .height =3D 8, + .dstpitch =3D 64, .srcpitch =3D srcpitches[j], + .dst =3D 0, .src =3D 0x4000, + }; + + clear_dst(&c, &b); + blt_start(&c, &b); + check_expansion(&c, &b, glyph); + } + } + cirrus_stop(&c); +} + +/* + * QEMU drops a color expansion whose source would run past the end of + * video memory. + */ +static void test_vram_expansion_beyond_end(void) +{ + static const uint8_t bits[4] =3D { 0xff, 0xff, 0xff, 0xff }; + Blt b =3D { + .mode =3D MODE_COLOREXP, + .width =3D 8, .height =3D 8, .dstpitch =3D 64, + .dst =3D 0, .src =3D VRAM_SIZE - 4, + }; + uint8_t line[8], fill[8]; + Cirrus c; + + memset(fill, FILL, sizeof(fill)); + cirrus_start(&c); + vram_write(&c, VRAM_SIZE - 4, bits, sizeof(bits)); + clear_dst(&c, &b); + blt_start(&c, &b); + for (int y =3D 0; y < b.height; y++) { + vram_read(&c, b.dst + y * b.dstpitch, line, sizeof(line)); + g_assert_cmpmem(line, sizeof(line), fill, sizeof(fill)); + } + cirrus_stop(&c); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + if (!qtest_has_device("cirrus-vga")) { + return g_test_run(); + } + + qtest_add_func("/cirrus/blt/mono-pattern-first-line", + test_mono_pattern_first_line); + qtest_add_func("/cirrus/blt/color-pattern-first-line", + test_color_pattern_first_line); + qtest_add_func("/cirrus/blt/sysmem-expansion-dword", + test_sysmem_expansion_dword); + qtest_add_func("/cirrus/blt/vram-expansion-pitch", + test_vram_expansion_pitch); + qtest_add_func("/cirrus/blt/vram-expansion-beyond-end", + test_vram_expansion_beyond_end); + + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 019c63ca60..055642e211 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -70,6 +70,7 @@ qtests_i386 =3D \ (igvm.found() and config_all_devices.has_key('CONFIG_FW_CFG_DMA') ? ['launchupdate-test']= : []) + \ (config_all_devices.has_key('CONFIG_I440FX') ? ['i440fx-test'] : []) + = \ + (config_all_devices.has_key('CONFIG_VGA_CIRRUS') ? ['cirrus-test'] : [])= + \ (config_all_devices.has_key('CONFIG_I440FX') ? ['ide-test'] : []) + = \ (config_all_devices.has_key('CONFIG_I440FX') ? ['numa-test'] : []) + = \ (config_all_devices.has_key('CONFIG_I440FX') ? ['test-x86-cpuid-compat']= : []) + \ --=20 2.53.0