From patchwork Tue May 23 11:44:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommy Wu X-Patchwork-Id: 13252125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 922A2C7EE2E for ; Tue, 23 May 2023 11:45:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1QRw-0003qc-Gb; Tue, 23 May 2023 07:45:08 -0400 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 1q1QRt-0003qG-Mb for qemu-devel@nongnu.org; Tue, 23 May 2023 07:45:05 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1QRr-0001nC-4Z for qemu-devel@nongnu.org; Tue, 23 May 2023 07:45:05 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6af8b25fc72so379545a34.3 for ; Tue, 23 May 2023 04:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1684842301; x=1687434301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y8tC9xHsp7YitbY3D29NZKggJ0khrtm4YaHoMYnX/PA=; b=aSb3zFNJwj/dZX83KePPa3UvuFmSozUeSTD9tWtMpX5vSAdiciGhzdAKznV9saAJHp Z9rtwzVHv7pgZC8pNidFqvEAWd7dtjwpMSyQEvaEm2aXQ9Uh3Bsrb6ersZC21RJbt3xt Kmk41fA5jMvzviD7vuSF/moLqgDVMaQ6i0dQtheYNLkFC9oV0nfSFzahTbr+jcCiI9eS ni5hzgO4oc76l/deznyG1o25h5cGDAWq651RigLYfFqDfGppCgd4Wlf32Y+GK6r4sfec GHLEnGGzjKRkynlE0vhdZqmpBvtySpkvoDrvBlHGDcl8/AM1vK+4Xar7LoDt8EIYZC0c t00g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684842301; x=1687434301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y8tC9xHsp7YitbY3D29NZKggJ0khrtm4YaHoMYnX/PA=; b=S52gT3H6taVoQiJHdfLBnHfwejWymswA42yWx2F164RORriu2mCzOsS3JQoAGIf62/ HpBmzqXEbBeJatUvFIl5YipWweC4L5LgpMHdd5UAHQ6Ql9IymBX2ix6pzbXQKEywYTAI cAAlIxdFeJw+UzIV5/3Pm+iie1zBtfMB2P0t6KZ7H7/cGlZEHAvyavYZIT0ca5Chy55h bNPd7aIYoxruWPPpfNHyWOiMz0pNnbSk1p8/GK8ur3OHX92Yb2mk1ym/LCIPcNkzVpnt WntTScwi8BdyusW7kpxcJBeec7oaeZ77j98HRAqFrLQ6VQl2fbq4LYHg4aLmt/4hU2/h DdWQ== X-Gm-Message-State: AC+VfDwJi1GeJdsw2R7xJAThTicUmBcy5ZIa00HrnIMtMOAshmzfS9eF v+fTVosLRVMtN/t8spedNaVLqhl9QtQKPCCAXi/SpcKAPajhEsMZ+eDR6JVAhENTygXGjk7Dm3r 6zLCvATNa7z6I6DiK3nuTDComnZiGPH2xSTM73Orl5KttGJhsHpgAra2uI4eDzNm4wvsG96ADWn T2 X-Google-Smtp-Source: ACHHUZ6826BhCXA4vNOE8Xuwwg9Gh5yj0TlzvOpDCK1599c30smyt2l1mHK59CfjkxWYtA8qm66rtw== X-Received: by 2002:a05:6808:b0b:b0:398:1849:ea55 with SMTP id s11-20020a0568080b0b00b003981849ea55mr2182645oij.50.1684842300743; Tue, 23 May 2023 04:45:00 -0700 (PDT) Received: from sw05.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id e3-20020acab503000000b003924c15cf58sm3799772oif.20.2023.05.23.04.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 04:45:00 -0700 (PDT) From: Tommy Wu To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: frank.chang@sifive.com, alistair.francis@wdc.com, apatel@ventanamicro.com, palmer@rivosinc.com, dbarboza@ventanamicro.com, bin.meng@windriver.com, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Tommy Wu Subject: [PATCH 1/2] target/riscv: Add a function to refresh the dynamic CSRs xml. Date: Tue, 23 May 2023 04:44:53 -0700 Message-Id: <20230523114454.717708-2-tommy.wu@sifive.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230523114454.717708-1-tommy.wu@sifive.com> References: <20230523114454.717708-1-tommy.wu@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=tommy.wu@sifive.com; helo=mail-ot1-x329.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org When we change the cpu extension state after the cpu is realized, we cannot print the value of some CSRs in the remote gdb debugger. The root cause is that the dynamic CSR xml is generated when the cpu is realized. This patch add a function to refresh the dynamic CSR xml after the cpu is realized. Signed-off-by: Tommy Wu Reviewed-by: Frank Chang Reviewed-by: Weiwei Li --- target/riscv/cpu.h | 2 ++ target/riscv/gdbstub.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index de7e43126a..dc8e592275 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -494,6 +494,7 @@ struct ArchCPU { CPUNegativeOffsetState neg; CPURISCVState env; + int dyn_csr_base_reg; char *dyn_csr_xml; char *dyn_vreg_xml; @@ -781,6 +782,7 @@ void riscv_get_csr_ops(int csrno, riscv_csr_operations *ops); void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops); void riscv_cpu_register_gdb_regs_for_features(CPUState *cs); +void riscv_refresh_dynamic_csr_xml(CPUState *cs); uint8_t satp_mode_max_from_map(uint32_t map); const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 524bede865..9e97ee2c35 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -230,6 +230,8 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) bitsize = 64; } + cpu->dyn_csr_base_reg = base_reg; + g_string_printf(s, ""); g_string_append_printf(s, ""); g_string_append_printf(s, ""); @@ -349,3 +351,13 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) "riscv-csr.xml", 0); } } + +void riscv_refresh_dynamic_csr_xml(CPUState *cs) +{ + RISCVCPU *cpu = RISCV_CPU(cs); + if (!cpu->dyn_csr_xml) { + g_assert_not_reached(); + } + g_free(cpu->dyn_csr_xml); + riscv_gen_dynamic_csr_xml(cs, cpu->dyn_csr_base_reg); +} From patchwork Tue May 23 11:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommy Wu X-Patchwork-Id: 13252124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D08AC77B75 for ; Tue, 23 May 2023 11:45:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1QS5-0003rv-EK; Tue, 23 May 2023 07:45:17 -0400 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 1q1QRv-0003qZ-44 for qemu-devel@nongnu.org; Tue, 23 May 2023 07:45:07 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1QRs-0001sN-Fl for qemu-devel@nongnu.org; Tue, 23 May 2023 07:45:06 -0400 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-38e3228d120so4237278b6e.3 for ; Tue, 23 May 2023 04:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1684842303; x=1687434303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i4o3dohaZtkA0+W3204WlEGitdPVAzfsTfJ7xms/lWk=; b=VU0FQUP/Mcuxl7wACRxLWqyrzpmvLfd3eGv6G9E/vdm5t/p7PaR0Ca+X4Igw/X+qry R7YdEig+J6vVib0V+SPj25jbgt26NeE//j07hZdPvwW3yJ1j89pyikdC2UzSXg6mJeqb +n+j9A53chyanW5aM5+czcHm4ZqT0njymcQO857VkgcNwjzTZXC3W6H7pbeSWFNDcLdr LYMNtGtoZgsFWY7nEOC7fbHLSrRsHi+/sth9VbdC+CVOxnU3iyGMOEz0GiN2DQGGabVB zudQ6a8b7MTkIDOr6YOe3BR/JdJap6nxk0T9EyckyPtz/lWyu+A499xqIk2Q5iwVOq3S 0ueQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684842303; x=1687434303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i4o3dohaZtkA0+W3204WlEGitdPVAzfsTfJ7xms/lWk=; b=O8vRlT/o/BVWqcqCCgn8gPY/pCC1yjWGweorvtJPcZt9O7o7c9OFma906Cww6KOCEE /9Yo4ebawBkXCHhRppjsNCrewyRCQ7KWxC4FlGW+H05rGVFGx33TmORPFITlhIkwEv5U U4GiQQRde+ZNp9CZ50/7LVcgigKaCpp/39zy+sYjBsRv7MXiLMpbwOgXPpOpEwskV8Jo 84ZxSF1QfI8l1ay4A7Cn2LGKRpXWWnrU7h25IUvBTSRvwuKOjsB2hmln94LsmlPnGV2l 1vji086C5LqpNoofdwzMEnjAKFD8kEwSNYkKvjgXAx+5c3Yu+2ErXdnLsaHwTtH5It7/ ghpA== X-Gm-Message-State: AC+VfDzi0hPqQZ/6u7+DaUb7CMGx2xlrb2dI24SJ/YwkcAWIoUTIithf hQSIVh04K8UYbPSGuTcNA3Y9emKGvusVKu5gO+9mo+MWAZ7FOxEQ0QFmCvwxJJIeZ6d7fX6NDG4 1XTLzJ9YphT3/RpFY3JGrX84c+soxQKznfeCVnSNi398fwp+o/jB8QIfD1f6Sbs3O0fGdHmI5Xd qT X-Google-Smtp-Source: ACHHUZ5E2R42SZoMGp9iWdBJVJ1lEWdcLltsL0rvfaDB+miOobmApRWafghhOunog0bD3Bree4cApA== X-Received: by 2002:a05:6808:1c3:b0:398:15e7:529f with SMTP id x3-20020a05680801c300b0039815e7529fmr2234079oic.46.1684842302674; Tue, 23 May 2023 04:45:02 -0700 (PDT) Received: from sw05.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id e3-20020acab503000000b003924c15cf58sm3799772oif.20.2023.05.23.04.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 04:45:02 -0700 (PDT) From: Tommy Wu To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: frank.chang@sifive.com, alistair.francis@wdc.com, apatel@ventanamicro.com, palmer@rivosinc.com, dbarboza@ventanamicro.com, bin.meng@windriver.com, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Tommy Wu Subject: [PATCH 2/2] hw/intc: riscv_imsic: Refresh the CSRs xml after updating the state of the cpu. Date: Tue, 23 May 2023 04:44:54 -0700 Message-Id: <20230523114454.717708-3-tommy.wu@sifive.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230523114454.717708-1-tommy.wu@sifive.com> References: <20230523114454.717708-1-tommy.wu@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=tommy.wu@sifive.com; helo=mail-oi1-x230.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Originally, when we set the ext_smaia to true, we still cannot print the AIA CSRs in the remote gdb debugger, because the dynamic CSR xml is generated when the cpu is realized. This patch refreshes the dynamic CSR xml after we update the ext_smaia, so that we can print the AIA CSRs in the remote gdb debugger. Signed-off-by: Tommy Wu Reviewed-by: Frank Chang --- hw/intc/riscv_imsic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/intc/riscv_imsic.c b/hw/intc/riscv_imsic.c index fea3385b51..97a51d535b 100644 --- a/hw/intc/riscv_imsic.c +++ b/hw/intc/riscv_imsic.c @@ -350,6 +350,10 @@ static void riscv_imsic_realize(DeviceState *dev, Error **errp) } else { rcpu->cfg.ext_smaia = true; } + + /* Refresh the dynamic csr xml for the gdbstub. */ + riscv_refresh_dynamic_csr_xml(cpu); + riscv_cpu_set_aia_ireg_rmw_fn(env, (imsic->mmode) ? PRV_M : PRV_S, riscv_imsic_rmw, imsic); }