From nobody Sat May 30 19:23:38 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; dmarc=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1777485330; cv=none; d=zohomail.com; s=zohoarc; b=lX//7J4NVmqeg7jHcUIqT71tp5K8Yy4fH0XmXssyHWtGM8oI/Fwkqs5JrY6fRgwWgxPhuXo/GTC+W1GnLtGnSVHrB9isYdbW02D+q/iNIB5qCoz2AdNI+7q/ca52hzm84f74PVs3BjPr6jRLaYgxqvkPZNKXaxD44y2Qb4CjEBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777485330; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From: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=DSx2jEGCym9AXEhGI+vByw+KQISlBYyUyne3gZ0gINA=; b=Oh2FC378G1sqWJFFhT9tHutsKBQ/60mDeVlkZjHPb5GWHQgzn2/r4XZ+CDOxy2VpbG+ClimRiA2QK5d+vwfTXpyafaPP0EfzoPclK0jDKy2Ybd2wsv96KE8Cahmtvn3ciAZKzp+sedn7RhPuOuxmjinX5KrqoJhUvuGKWIjV9qQ= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777485330743490.4536604976306; Wed, 29 Apr 2026 10:55:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI97l-00043p-4n; Wed, 29 Apr 2026 13:55:01 -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 1wI97j-00043c-5r for qemu-devel@nongnu.org; Wed, 29 Apr 2026 13:54:59 -0400 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wI97h-0004b1-9z for qemu-devel@nongnu.org; Wed, 29 Apr 2026 13:54:58 -0400 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 41F47EC00DD; Wed, 29 Apr 2026 13:54:56 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 29 Apr 2026 13:54:56 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 13:54:55 -0400 (EDT) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id bbd843ad; Wed, 29 Apr 2026 17:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1777485296; x=1777571696; bh=DSx2jEGCym 9AXEhGI+vByw+KQISlBYyUyne3gZ0gINA=; b=IeSPa0xsj+pWyu84POnir6yCdm 2cwLTZ+soln5+LqzNx+4grKhlD09JHECvtiYyMVKeY+Cmpa6RwQ8v6rRtRk5Tusa fHrmybeeIpGqvak0SOj+Su40y5clD58XlcQfMdBweoXIRIS3Ryr1cLn9v+l9/MSn W8xbwfKO/UzaJz4i3EZwwDAuw9pahtSWfcadEtJ0i7eotw0bkJcBGoNPnjuEVh2a 886styxD5dh/DqzBTr7NjMvtpBRakllSgeRSWuLxNO1KQjrWytWoflTdQSTkFvub 8mPixUOVjcrUfQDN8RFTtuj0CSIwtVd4+/KBbWxycmZ4ssyCCwZBPAzUYlMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1777485296; x=1777571696; bh=DSx2jEGCym9AXEhGI+vByw+KQISlBYyUyne 3gZ0gINA=; b=q7p+m/8g3/12PCaYC5Z3CDXs8f6Uy03Rv56MVhshsiO5DKBYvxT blVuM3waTw0CMt7rotIyF1ylqfvqA0ifKEm3WVOutTdSIDx2HWOOPWLbQlRtK3t4 dSUgS1/FoByA7ose1FYsD/WDaT1m6GsP+kyhjXOkqe/S6SA2oAx9aFKBUjIjKTVw 9kU6VqNwTSHl1iKa6ZMddCKTQNvja+xe99Xs2KkrVMVq5mqeExhPIYlLNTF+a0jr FwxbW8J8wCOCQ5yviw0o9fHjNMb7gOrEPhYIbz+U0J3a006P8Ixue+QcDmfzaEIX lq1yGCB0R0SyzMcPHolZYxYCTO9QZad5AAQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekhedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhephffvvefufffkofgggfestdekredtredttdenucfh rhhomhepvehhrgguucflrggslhhonhhskhhiuceotghhrggusehjrggslhhonhhskhhird ighiiiqeenucggtffrrghtthgvrhhnpefhteeugfeujeelteeggfeigeevjeelgeegudfg uedvheeghfffudffledukeeiveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegthhgrugesjhgrsghlohhnshhkihdrgiihiidpnhgspghrtghp thhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepkhhrrgigvghlsehrvg guhhgrthdrtghomhdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdho rhhgpdhrtghpthhtohepmhgrrhgtrghnughrvgdrlhhurhgvrghusehrvgguhhgrthdrtg homhdprhgtphhtthhopegthhgrugesjhgrsghlohhnshhkihdrgiihiidprhgtphhtthho pegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuh X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Chad Jablonski Subject: [PATCH v2] ati-vga: fix ati_set_dirty address calculation Date: Wed, 29 Apr 2026 13:54:34 -0400 Message-ID: <20260429175434.474429-1-chad@jablonski.xyz> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=103.168.172.145; envelope-from=chad@jablonski.xyz; helo=fout-a2-smtp.messagingengine.com X-Spam_score_int: 17 X-Spam_score: 1.7 X-Spam_bar: + X-Spam_report: (1.7 / 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, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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 @jablonski.xyz) X-ZM-MESSAGEID: 1777485333339154100 Content-Type: text/plain; charset="utf-8" This fixes three bugs with the ati_set_dirty address calculation. First, vbe_start_addr is a word offset. All other values in the calculation are byte offsets. It must be converted to bytes. Second, when setting the dirty region with memory_region_set_dirty the vbe_start_addr is used to calculate the start of the dirty region. This is a problem because the vbe_start_addr is the offset at which scan out begins. This puts it in the visible screen coordinate system. The dirty region however is in the virtual screen coordinate system. This can cause b= oth overmarking and missed updates. This is removed from the calculation. Third, when the start address of a blit is outside of the bounds check the entire blit is missed and not set to dirty. This happens even if the blit does partially overlap with the visible screen. The fix here is to find the intersection of the visible screen and the blit and mark only that region as dirty. This does not attempt to apply clipping to the blit. So there will be overmarking in some cases. Signed-off-by: Chad Jablonski --- hw/display/ati_2d.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 504d1c5708..3192b864fd 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -69,19 +69,31 @@ typedef struct { static void ati_set_dirty(VGACommonState *vga, const ATI2DCtx *ctx) { DisplaySurface *ds =3D qemu_console_surface(vga->con); + unsigned int bypp =3D ctx->bpp / 8; + unsigned long dirty_size =3D ((ctx->dst.height - 1) * ctx->dst_stride)= + + (ctx->dst.width * bypp); + uint8_t *dirty_start =3D ctx->dst_bits + (ctx->dst.y * ctx->dst_stride= ) + + (ctx->dst.x * bypp); + uint8_t *dirty_end =3D dirty_start + dirty_size; + /* + * The blit may be outside of the visible screen (e.g. virtual desktop= s.) + * Dirty only the intersection of the visible screen and the blit. + */ + uint8_t *vis_start =3D vga->vram_ptr + (vga->vbe_start_addr * 4); + uint8_t *vis_end =3D vis_start + vga->vbe_regs[VBE_DISPI_INDEX_YRES] * + vga->vbe_line_offset; + uint8_t *start =3D MAX(vis_start, dirty_start); + uint8_t *end =3D MIN(vis_end, dirty_end); =20 (void)ds; DPRINTF("%p %u ds: %p %d %d rop: %x\n", vga->vram_ptr, vga->vbe_start_= addr, surface_data(ds), surface_stride(ds), surface_bits_per_pixel(d= s), ctx->rop3 >> 16); - if (ctx->dst_bits >=3D vga->vram_ptr + vga->vbe_start_addr && - ctx->dst_bits < vga->vram_ptr + vga->vbe_start_addr + - vga->vbe_regs[VBE_DISPI_INDEX_YRES] * vga->vbe_line_offset) { - memory_region_set_dirty(&vga->vram, - vga->vbe_start_addr + ctx->dst_offset + - ctx->dst.y * ctx->dst_stride, - ctx->dst.height * ctx->dst_stride); + + if (start >=3D end) { + return; } + memory_region_set_dirty(&vga->vram, start - vga->vram_ptr, end - start= ); } =20 static void setup_2d_blt_ctx(const ATIVGAState *s, ATI2DCtx *ctx) --=20 2.53.0