From nobody Tue Apr 8 13:56:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1738552564; cv=none; d=zohomail.com; s=zohoarc; b=VD6D4sldgitMdHjkp9YAK/USUMA1E9AUnxSAKqQewR9d30AvU31RYXs5pzmUX8B5ctGzFaTnlRizUNzJb991zcdGo8+EpIQuQrm/xCt1l70xmlbaqZSY4DprhRfKzGt/L6zhKUYHlSBxtDMfxwK2WTowOKgmjKOjj8HuZND2eOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738552564; 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:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=eGsegL9nmdkSK8/jok+tsKCKg3J7UpoE7TRcQKVTZKs=; b=Lp7cqrnoMPEn/zKzpFzuX0RBSEapphVnsD2G2kJiRdBekLgU8ksuCL9ArKb4rwYMN/2wZvnoIlYfEnjQciJYxFRqOX+aXk7bj7+UpqsQsmWaEwIAUP1kqRSlteKAGMi49XmMChB4VPfo2gpLi563Bb8tdhass06/QYeOMS5RBnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738552562973876.9198513957817; Sun, 2 Feb 2025 19:16:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1temvc-00074i-Bx; Sun, 02 Feb 2025 22:15:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1temva-00073I-J1 for qemu-devel@nongnu.org; Sun, 02 Feb 2025 22:15:15 -0500 Received: from web5.hostingcp.eu ([2a09:8b00:252:5::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1temvX-00025C-Tc for qemu-devel@nongnu.org; Sun, 02 Feb 2025 22:15:13 -0500 Received: from 095-096-130-127.static.chello.nl ([95.96.130.127] helo=[192.168.178.10]) by web5.hostingcp.eu with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (Exim 4.98) (envelope-from ) id 1temvW-00000003cwH-0U1j; Mon, 03 Feb 2025 04:15:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=laaksoft.nl ; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:Cc:From:To: MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=eGsegL9nmdkSK8/jok+tsKCKg3J7UpoE7TRcQKVTZKs=; b=hyPMNq7DjSQGZIwhMffMJBdGUK 2+usBaM2lFIR9Ugyd3+TxkdK0lMSo1IWk2Wvh0PhYRyKibkJ4xitD66V5g7YVw92XW3iFgF2VhMNO tLL2zE6JQ6nod/xkbP2N03aV+BuD7HDeSV9fFb73DT5QU5ANe4GzsvKGThwADomC4cUKYPEdIuB1F wJCBORqtxejWZcV1dbNSih60447LkHCuoNYlqMWne4aSRjKIJ2a8YOM/92VpajjNTB526amk6c5bi 76+YZ0nLDH0h6oG7RSMqPithvjShs+DQr4b9Ws+dYe90Eya5fQXDyGn1/hrD/fxgb36NrzqDNajkE 2uTDsIIQ==; Message-ID: Date: Mon, 3 Feb 2025 04:14:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: qemu-devel@nongnu.org Content-Language: en-US Cc: Mark Cave-Ayland , Artyom Tarasenko Subject: Patch: Sparc prevent segfault when dumping uninitialzed cpu state Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-MagicSpam-TUUID: 39480960-a2d1-41e6-8964-b89acd8d2e02 X-MagicSpam-SUUID: 234b6e9d-3dd0-4c7e-bd4d-fdd295376ca6 X-Authenticated-Id: henk@laaksoft.nl 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=lists.gnu.org; Received-SPF: pass client-ip=2a09:8b00:252:5::10; envelope-from=henk@laaksoft.nl; helo=web5.hostingcp.eu 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: "Henk van der Laak (LaakSoft)" From: "Henk van der Laak (LaakSoft)" via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1738552566277019000 Hi all, my first contribution. I checked code style, patch submission=20 rules and did a manual test (details on request) Synopsis: It's a corner case, where a segfault occurs when logging Sparc CPU state=20 in a partially initialized state. No related bug report. Open to harsh criticism ;-) Regards, Henk van der Laak Patch is based off 6fccaa2fba391815308a746d68f7fa197bc93586=20 (origin/master) as of Sun Feb 2 11:09:10 2025 -0500 Signed-off-by: Henk van der Laak --- =C2=A0target/sparc/cpu.c | 7 ++++++- =C2=A01 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index fbd38ec334..83aaa456fc 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -642,7 +642,12 @@ static void sparc_cpu_dump_state(CPUState *cs, FILE=20 *f, int flags) =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=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 x =3D=3D 0 ? 'o' : (x =3D=3D 1 ? 'l' : 'i'), =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=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 i, i + REGS_PER_LINE - 1); =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=C2=A0=C2=A0 qemu_fp= rintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]); +=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=C2=A0=C2=A0 *= regwptr may not be initialized yet when logging +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *= e.g. cpu_reset +=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=C2=A0=C2=A0 qemu_fp= rintf(f, TARGET_FMT_lx " ", +=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 env->regwptr ? env->regwptr[i + x * 8] : 0); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i= f (i % REGS_PER_LINE =3D=3D REGS_PER_LINE - 1) { =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 qemu_fprintf(f, "\n"); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } --=20 2.43.0