From nobody Sat Sep 26 23:03:01 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=quarantine dis=none) header.from=swemel.ru ARC-Seal: i=1; a=rsa-sha256; t=1789489268; cv=none; d=zohomail.com; s=zohoarc; b=PVc/XR4Hq9OHbGpF1n4lcKCulpHbeill/IFFsI7dUe8aLM47a4CQOBjSu3mS5cjBvoyFVshgiu0rhzsWXUTMtcqzbsrZV1ZHJOvgK4L7JmPhhg04ZxrXanuBRPPvE9ZorVrhiSh9mtOruxBkacqasKQWPs5Jk2xpusmiM5Xb64U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789489268; h=Content-Type: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=INxU0D4tvlYktP1JSHtIL+7zhfvZn36WtZGmwiYzHUA=; b=KPUUc+5drAM9vAZGM3dcUlPVOarOi6/Goes+Gboo8cFc8OvN+IEtAVREfHpHAUgwigkUtL6mZRso8kRUAa1fh6gE0gW6zbm0UOpHNKbpVv5NexankHg0MlkCStPMsi8wiy4G99VlcYefPQ/yDNruImCZI03TCHMZ+LRb1fgHKQA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789489267840404.917344352923; Tue, 15 Sep 2026 09:21:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x6Vtr-0003yf-40; Tue, 15 Sep 2026 12:20:51 -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 1x6Vtq-0003yX-21 for qemu-devel@nongnu.org; Tue, 15 Sep 2026 12:20:50 -0400 Received: from mx.swemel.ru ([95.143.211.150]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x6Vto-0000g0-IY for qemu-devel@nongnu.org; Tue, 15 Sep 2026 12:20:49 -0400 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1789489246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=INxU0D4tvlYktP1JSHtIL+7zhfvZn36WtZGmwiYzHUA=; b=N/8TuB/eIC8qaYtJbgrkSFU7MImravnYXcRCdFAeaQtkEKRiZaRet4mC7CvbQgQutzcORZ iVoNwYvXSNPHtazaZp5Vef/PJbA9f8EPIwUjQsgkdbUB8qYB3+ZGj1KSXmMhPcmGZyKAry RO/bZMsP6JA2VK7i22AF+g9NR8al+ks= Date: Tue, 15 Sep 2026 19:20:46 +0300 MIME-Version: 1.0 Content-Language: en-US, ru-RU To: qemu-devel@nongnu.org Cc: thuth@redhat.com, mst@redhat.com, stefanha@redhat.com, kwolf@redhat.com, marcandre.lureau@redhat.com, mark.cave-ayland@ilande.co.uk From: =?UTF-8?B?0J3QuNC60L7Qu9Cw0Lkg0JfQvtGA0LjQvQ==?= Subject: [PATCH] hw/display/tcx: use memmove instead of memcpy for overlapping blit memory regions Content-Type: text/plain; charset="utf-8"; format="flowed" 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=95.143.211.150; envelope-from=zorin@swemel.ru; helo=mx.swemel.ru 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_NONE=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 @swemel.ru) X-ZM-MESSAGEID: 1789489274257158500 SWSA#34e3af79-c6c2-4ad2-986f-313c1ce28e5a In `tcx_blit_writel()`, memory copying occurs within the same video RAM buffers (`vram` and `vram24`) using source and destination offsets that can potentially overlap during blit operations. Using `memcpy()` on overlapping memory regions triggers undefined behavior according to the C standard. Depending on compiler optimizations, this can lead to graphical artifacts, memory corruption, or unexpected behavior in the guest system. Fix this by replacing `memcpy()` with `memmove()`, which explicitly guarantees safe and correct behavior when memory regions overlap. Signed-off-by: Nikolay N Zorin --- =C2=A0hw/display/tcx.c | 4 ++-- =C2=A01 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 2cfc1e8f..fb48a199 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -587,9 +587,9 @@ static void tcx_blit_writel(void *opaque, hwaddr addr, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else { -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memcpy(&s->vram[addr], &s->vram[= adsr], len); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memmove(&s->vram[addr], &s->vram= [adsr], len); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (s->depth =3D=3D 24) { -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memcpy(&s->vram24[= addr], &s->vram24[adsr], len * 4); +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memmove(&s->vram24= [addr], &s->vram24[adsr], len * 4); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tcx_set_dirty(s, addr, len); --=20 2.43.0