From nobody Tue Apr 8 12:57:07 2025 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=reject dis=none) header.from=miszr.win ARC-Seal: i=1; a=rsa-sha256; t=1739516719; cv=none; d=zohomail.com; s=zohoarc; b=ikbdd73FUxfOExDuhLd4JmVMy051z631qaoox5zzzUVdrgcorG1IJyjl7nOk3XPUSMc8YScOuGk1dtwVQSZtl/3QOmR9fldl3J0gfQMBBl/qhS3lEVcBo+Sf6FqNpt6xUNYZ68cH5rw5ZNksZG8+Xg7xLPNRHHft9Rm33M0M6tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739516719; 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=zT8diQUURgdIJgjQnriXhC653AD7d39Of5taPLgOoro=; b=FIYrXO3ggEoUF5/gi5A1QLu3Oc6KJQmD/BPm9tI7TUlL9pxNmUfSGnXl2tOvsFhPFXHXbG3aNvtJxZCvF979Wr0TjZm0tWQ55LFUN4H1WFbHfCVfmfQNsPC/89Ck1WVTcZ+Sp5ypuZy9zgchgQIbZIFlCxDXS7I2DzkBb9oEttg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739516719935570.9809143341853; Thu, 13 Feb 2025 23:05:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tipkM-0006mC-VD; Fri, 14 Feb 2025 02:04:22 -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 1tipkL-0006lK-7m for qemu-devel@nongnu.org; Fri, 14 Feb 2025 02:04:21 -0500 Received: from smtp.forwardemail.net ([149.28.215.223]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tipkJ-0001AE-8x for qemu-devel@nongnu.org; Fri, 14 Feb 2025 02:04:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miszr.win; h=Content-Transfer-Encoding: MIME-Version: Message-ID: Date: Subject: Cc: To: From; q=dns/txt; s=fe-257304d8b2; t=1739516658; bh=zT8diQUURgdIJgjQnriXhC653AD7d39Of5taPLgOoro=; b=Flz2Li8i0KUCmxkRzq3W7OJG+HmPUwSiAXX5w+mq9TvRy1fpoixpiNwVsW9FGE43ut7PvcMr9 tHYNJmBLwuxatB+iPRQ9+ivCtxs8t794+sw7oYCwyjR4vYRXwkwsEb5K/NkBkT12eXpygeltSB0 T5lzAajwlnjuqpq1/EFyJ2E= X-Forward-Email-ID: 67aeeaedb8354098fb49d511 X-Forward-Email-Sender: rfc822; git@miszr.win, smtp.forwardemail.net, 149.28.215.223 X-Forward-Email-Version: 0.4.40 X-Forward-Email-Website: https://forwardemail.net X-Complaints-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Report-Abuse-To: abuse@forwardemail.net From: Mikael Szreder To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Mark Cave-Ayland , Richard Henderson , Mikael Szreder Subject: [PATCH v2] target/sparc: Fix gdbstub incorrectly handling registers f32-f62 Date: Fri, 14 Feb 2025 08:03:43 +0100 Message-ID: <20250214070343.11501-1-git@miszr.win> X-Mailer: git-send-email 2.48.1 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=lists.gnu.org; Received-SPF: pass client-ip=149.28.215.223; envelope-from=SRS0=724e=VF=miszr.win=git@fe-bounces.miszr.win; helo=smtp.forwardemail.net 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, FROM_FMBLA_NEWDOM14=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 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 @miszr.win) X-ZM-MESSAGEID: 1739516720514019000 Content-Type: text/plain; charset="utf-8" The gdbstub implementation for the Sparc architecture would incorrectly calculate the the floating point register offset. This resulted in, for example, registers f32 and f34 to point to the same value. The issue was caused by the confusion between even register numbers and even register indexes. For example, the register index of f32 is 64 and f34 is 65. Fixes: 30038fd81808 ("target-sparc: Change fpr representation to doubles.") Signed-off-by: Mikael Szreder Reviewed-by: Richard Henderson --- target/sparc/gdbstub.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index ec0036e9ef..134617fb23 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -79,8 +79,13 @@ int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray= *mem_buf, int n) } } if (n < 80) { - /* f32-f62 (double width, even numbers only) */ - return gdb_get_reg64(mem_buf, env->fpr[(n - 32) / 2].ll); + /* f32-f62 (16 double width registers, even register numbers only) + * n =3D=3D 64: f32 : env->fpr[16] + * n =3D=3D 65: f34 : env->fpr[17] + * etc... + * n =3D=3D 79: f62 : env->fpr[31] + */ + return gdb_get_reg64(mem_buf, env->fpr[(n - 64) + 16].ll); } switch (n) { case 80: @@ -173,8 +178,13 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t= *mem_buf, int n) } return 4; } else if (n < 80) { - /* f32-f62 (double width, even numbers only) */ - env->fpr[(n - 32) / 2].ll =3D tmp; + /* f32-f62 (16 double width registers, even register numbers only) + * n =3D=3D 64: f32 : env->fpr[16] + * n =3D=3D 65: f34 : env->fpr[17] + * etc... + * n =3D=3D 79: f62 : env->fpr[31] + */ + env->fpr[(n - 64) + 16].ll =3D tmp; } else { switch (n) { case 80: --=20 2.48.1