From nobody Thu Mar 28 17:34:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659670739823976.859682473734; Thu, 4 Aug 2022 20:38:59 -0700 (PDT) Received: from localhost ([::1]:38736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJoAr-0006fF-Rs for importer@patchew.org; Thu, 04 Aug 2022 23:38:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJo7Z-0000GN-P6 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:33 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49396 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJo7W-00027a-QI for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:33 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSs37j+xiQD4HAA--.15649S3; Fri, 05 Aug 2022 11:35:24 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, gaosong@loongson.cn, f4bug@amsat.org, alex.bennee@linaro.org, yangxiaojuan@loongson.cn Subject: [PATCH for-7.1 v2 1/5] target/loongarch: Fix GDB get the wrong pc Date: Fri, 5 Aug 2022 11:35:19 +0800 Message-Id: <20220805033523.1416837-2-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220805033523.1416837-1-gaosong@loongson.cn> References: <20220805033523.1416837-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9AxSs37j+xiQD4HAA--.15649S3 X-Coremail-Antispam: 1UD129KBjvJXoWxGw17tr48Ww4ktr43GF48JFb_yoW5GF48p3 s3uw1qkFW0g39Fy3srXa4FqFn8Zr17uF4avF1Iy34xCr48XFy5ZF4Fq39FqF4UG3yFvry2 qF4rZ3W5ua13XrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ 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=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1659670740282100001 Content-Type: text/plain; charset="utf-8" GDB LoongArch add a register orig_a0, see the base64.xml [1]. We should add the orig_a0 to match the upstream GDB. [1]: https://github.com/bminor/binutils-gdb/blob/master/gdb/features/loonga= rch/base64.xml Signed-off-by: Song Gao Acked-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- gdb-xml/loongarch-base64.xml | 1 + target/loongarch/cpu.c | 2 +- target/loongarch/gdbstub.c | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb-xml/loongarch-base64.xml b/gdb-xml/loongarch-base64.xml index 4962bdbd28..a1dd4f2208 100644 --- a/gdb-xml/loongarch-base64.xml +++ b/gdb-xml/loongarch-base64.xml @@ -39,6 +39,7 @@ + diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 1c69a76f2b..d84ec38cf7 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -683,7 +683,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, vo= id *data) cc->gdb_read_register =3D loongarch_cpu_gdb_read_register; cc->gdb_write_register =3D loongarch_cpu_gdb_write_register; cc->disas_set_info =3D loongarch_cpu_disas_set_info; - cc->gdb_num_core_regs =3D 34; + cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "loongarch-base64.xml"; cc->gdb_stop_before_watchpoint =3D true; =20 diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 24e126fb2d..5feb43445f 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -19,8 +19,11 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteA= rray *mem_buf, int n) if (0 <=3D n && n < 32) { return gdb_get_regl(mem_buf, env->gpr[n]); } else if (n =3D=3D 32) { - return gdb_get_regl(mem_buf, env->pc); + /* orig_a0 */ + return gdb_get_regl(mem_buf, 0); } else if (n =3D=3D 33) { + return gdb_get_regl(mem_buf, env->pc); + } else if (n =3D=3D 34) { return gdb_get_regl(mem_buf, env->CSR_BADV); } return 0; @@ -36,7 +39,7 @@ int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_= t *mem_buf, int n) if (0 <=3D n && n < 32) { env->gpr[n] =3D tmp; length =3D sizeof(target_ulong); - } else if (n =3D=3D 32) { + } else if (n =3D=3D 33) { env->pc =3D tmp; length =3D sizeof(target_ulong); } --=20 2.31.1 From nobody Thu Mar 28 17:34:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659670741103323.9418655050587; Thu, 4 Aug 2022 20:39:01 -0700 (PDT) Received: from localhost ([::1]:38894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJoAu-0006ll-2B for importer@patchew.org; Thu, 04 Aug 2022 23:39:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJo7e-0000Ky-5x for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:38 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49502 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJo7c-0002AM-63 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:37 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSs37j+xiQD4HAA--.15649S4; Fri, 05 Aug 2022 11:35:28 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, gaosong@loongson.cn, f4bug@amsat.org, alex.bennee@linaro.org, yangxiaojuan@loongson.cn Subject: [PATCH for-7.1 v2 2/5] target/loongarch: add gdb_arch_name() Date: Fri, 5 Aug 2022 11:35:20 +0800 Message-Id: <20220805033523.1416837-3-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220805033523.1416837-1-gaosong@loongson.cn> References: <20220805033523.1416837-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9AxSs37j+xiQD4HAA--.15649S4 X-Coremail-Antispam: 1UD129KBjvdXoWrtr4fXryxCr1UCFy7Ary3XFb_yoWDKFg_Xa yfAwn7ur48ua4qgw4qvr98J34fGF4fGFn0kF1DJF4xK34fZr15ArsFqwn3Ary0gr48AFsx ArW2yr90kF1YyjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ 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=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1659670742261100003 Content-Type: text/plain; charset="utf-8" Matches bfd/cpu-loongarch.c, bfd_loongarch_arch. Reviewed-by: Richard Henderson Signed-off-by: Song Gao Acked-by: Alex Benn=C3=A9e --- target/loongarch/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index d84ec38cf7..941e2772bc 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -661,6 +661,11 @@ static const struct SysemuCPUOps loongarch_sysemu_ops = =3D { }; #endif =20 +static gchar *loongarch_gdb_arch_name(CPUState *cs) +{ + return g_strdup("loongarch64"); +} + static void loongarch_cpu_class_init(ObjectClass *c, void *data) { LoongArchCPUClass *lacc =3D LOONGARCH_CPU_CLASS(c); @@ -686,6 +691,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, vo= id *data) cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "loongarch-base64.xml"; cc->gdb_stop_before_watchpoint =3D true; + cc->gdb_arch_name =3D loongarch_gdb_arch_name; =20 #ifdef CONFIG_TCG cc->tcg_ops =3D &loongarch_tcg_ops; --=20 2.31.1 From nobody Thu Mar 28 17:34:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659670741243240.96377447868736; Thu, 4 Aug 2022 20:39:01 -0700 (PDT) Received: from localhost ([::1]:39002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJoAu-0006pu-9q for importer@patchew.org; Thu, 04 Aug 2022 23:39:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJo7d-0000JA-9r for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49500 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJo7b-0002AI-6Z for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:37 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSs37j+xiQD4HAA--.15649S5; Fri, 05 Aug 2022 11:35:30 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, gaosong@loongson.cn, f4bug@amsat.org, alex.bennee@linaro.org, yangxiaojuan@loongson.cn Subject: [PATCH for-7.1 v2 3/5] target/loongarch: update loongarch-base64.xml Date: Fri, 5 Aug 2022 11:35:21 +0800 Message-Id: <20220805033523.1416837-4-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220805033523.1416837-1-gaosong@loongson.cn> References: <20220805033523.1416837-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9AxSs37j+xiQD4HAA--.15649S5 X-Coremail-Antispam: 1UD129KBjvJXoWxZr1xKF4kZr47Kw4xur18uFg_yoW5Gw1DpF 9Y9a4DCr4Ig3y0yrWUZ3yj9Fn5Jw4UCFWFyF1rX34xC3y0qFWDJrs5J39xZr47Ga1fXrWj qFsaka1rGFsxKrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ 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=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1659670742270100004 Content-Type: text/plain; charset="utf-8" Update loongarch-base64.xml to match the upstream GDB [1]. [1]:https://github.com/bminor/binutils-gdb/blob/master/gdb/features/loongar= ch/base64.xml Reviewed-by: Richard Henderson Signed-off-by: Song Gao Acked-by: Alex Benn=C3=A9e --- gdb-xml/loongarch-base64.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb-xml/loongarch-base64.xml b/gdb-xml/loongarch-base64.xml index a1dd4f2208..2d8a1f6b73 100644 --- a/gdb-xml/loongarch-base64.xml +++ b/gdb-xml/loongarch-base64.xml @@ -1,5 +1,5 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb-xml/loongarch-fpu64.xml b/gdb-xml/loongarch-fpu64.xml deleted file mode 100644 index e52cf89fbc..0000000000 --- a/gdb-xml/loongarch-fpu64.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 5feb43445f..d3a5e404b0 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -80,5 +80,5 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env, void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs) { gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_= fpu, - 41, "loongarch-fpu64.xml", 0); + 41, "loongarch-fpu.xml", 0); } --=20 2.31.1 From nobody Thu Mar 28 17:34:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659670612402512.8651622759579; Thu, 4 Aug 2022 20:36:52 -0700 (PDT) Received: from localhost ([::1]:60762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJo8o-0002St-Uq for importer@patchew.org; Thu, 04 Aug 2022 23:36:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJo7b-0000H1-QM for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49490 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJo7Z-00029y-Lz for qemu-devel@nongnu.org; Thu, 04 Aug 2022 23:35:35 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxSs37j+xiQD4HAA--.15649S7; Fri, 05 Aug 2022 11:35:31 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, gaosong@loongson.cn, f4bug@amsat.org, alex.bennee@linaro.org, yangxiaojuan@loongson.cn Subject: [PATCH for-7.1 v2 5/5] target/loongarch: Update gdb_set_fpu() and gdb_get_fpu() Date: Fri, 5 Aug 2022 11:35:23 +0800 Message-Id: <20220805033523.1416837-6-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220805033523.1416837-1-gaosong@loongson.cn> References: <20220805033523.1416837-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9AxSs37j+xiQD4HAA--.15649S7 X-Coremail-Antispam: 1UD129KBjvJXoWxAFyDtr4UZF1fuw47tF17GFg_yoWrAr4kpr yfCr43AF10gFZrZas3J3s8WFn8Cr1xGrWa9F1fG34FkF4UXFn8Za4vg392qF48A3yvgF4f ZF4Fy3W5uFyxXrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ 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=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1659670613820100003 Content-Type: text/plain; charset="utf-8" GDB LoongArch fpu use fcc register, update gdb_set_fpu() and gdb_get_fpu()= to match it. Signed-off-by: Song Gao Acked-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- linux-user/loongarch64/signal.c | 24 ++--------------------- target/loongarch/gdbstub.c | 34 ++++++++++++++++++++++++++------- target/loongarch/internals.h | 3 +++ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signa= l.c index 65fd5f3857..7c7afb652e 100644 --- a/linux-user/loongarch64/signal.c +++ b/linux-user/loongarch64/signal.c @@ -71,26 +71,6 @@ struct extctx_layout { struct ctx_layout end; }; =20 -/* The kernel's sc_save_fcc macro is a sequence of MOVCF2GR+BSTRINS. */ -static uint64_t read_all_fcc(CPULoongArchState *env) -{ - uint64_t ret =3D 0; - - for (int i =3D 0; i < 8; ++i) { - ret |=3D (uint64_t)env->cf[i] << (i * 8); - } - - return ret; -} - -/* The kernel's sc_restore_fcc macro is a sequence of BSTRPICK+MOVGR2CF. */ -static void write_all_fcc(CPULoongArchState *env, uint64_t val) -{ - for (int i =3D 0; i < 8; ++i) { - env->cf[i] =3D (val >> (i * 8)) & 1; - } -} - static abi_ptr extframe_alloc(struct extctx_layout *extctx, struct ctx_layout *sctx, unsigned size, unsigned align, abi_ptr orig_sp) @@ -150,7 +130,7 @@ static void setup_sigframe(CPULoongArchState *env, for (i =3D 0; i < 32; ++i) { __put_user(env->fpr[i], &fpu_ctx->regs[i]); } - __put_user(read_all_fcc(env), &fpu_ctx->fcc); + __put_user(read_fcc(env), &fpu_ctx->fcc); __put_user(env->fcsr0, &fpu_ctx->fcsr); =20 /* @@ -216,7 +196,7 @@ static void restore_sigframe(CPULoongArchState *env, __get_user(env->fpr[i], &fpu_ctx->regs[i]); } __get_user(fcc, &fpu_ctx->fcc); - write_all_fcc(env, fcc); + write_fcc(env, fcc); __get_user(env->fcsr0, &fpu_ctx->fcsr); restore_fp_status(env); } diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index d3a5e404b0..a4d1e28e36 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -11,6 +11,24 @@ #include "internals.h" #include "exec/gdbstub.h" =20 +uint64_t read_fcc(CPULoongArchState *env) +{ + uint64_t ret =3D 0; + + for (int i =3D 0; i < 8; ++i) { + ret |=3D (uint64_t)env->cf[i] << (i * 8); + } + + return ret; +} + +void write_fcc(CPULoongArchState *env, uint64_t val) +{ + for (int i =3D 0; i < 8; ++i) { + env->cf[i] =3D (val >> (i * 8)) & 1; + } +} + int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n) { LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); @@ -51,9 +69,10 @@ static int loongarch_gdb_get_fpu(CPULoongArchState *env, { if (0 <=3D n && n < 32) { return gdb_get_reg64(mem_buf, env->fpr[n]); - } else if (32 <=3D n && n < 40) { - return gdb_get_reg8(mem_buf, env->cf[n - 32]); - } else if (n =3D=3D 40) { + } else if (n =3D=3D 32) { + uint64_t val =3D read_fcc(env); + return gdb_get_reg64(mem_buf, val); + } else if (n =3D=3D 33) { return gdb_get_reg32(mem_buf, env->fcsr0); } return 0; @@ -67,10 +86,11 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env, if (0 <=3D n && n < 32) { env->fpr[n] =3D ldq_p(mem_buf); length =3D 8; - } else if (32 <=3D n && n < 40) { - env->cf[n - 32] =3D ldub_p(mem_buf); - length =3D 1; - } else if (n =3D=3D 40) { + } else if (n =3D=3D 32) { + uint64_t val =3D ldq_p(mem_buf); + write_fcc(env, val); + length =3D 8; + } else if (n =3D=3D 33) { env->fcsr0 =3D ldl_p(mem_buf); length =3D 4; } diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index ea227362b6..f01635aed6 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -51,6 +51,9 @@ bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); #endif /* !CONFIG_USER_ONLY */ =20 +uint64_t read_fcc(CPULoongArchState *env); +void write_fcc(CPULoongArchState *env, uint64_t val); + int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n); int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n= ); void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs); --=20 2.31.1