qemu-riscv.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Tommy Wu <tommy.wu@sifive.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	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
Subject: Re: [PATCH 1/2] target/riscv: Add a function to refresh the dynamic CSRs xml.
Date: Fri, 9 Jun 2023 16:37:41 +0800	[thread overview]
Message-ID: <CANj3q_ng7=2-gosL7HywNRVcqZqkK4aWodBNp6rjqV8OpMJDEA@mail.gmail.com> (raw)
In-Reply-To: <CAKmqyKOfkhN=3+asF-u3r7y83GiZjv34mv42Yp0Ye0NzUEnezQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3083 bytes --]

Hi Alistair,
Thanks for the suggestion! Do you mean
```
    ...
    g_free(cpu->dyn_csr_xml);
    riscv_gen_dynamic_csr_xml(cs, cpu-> gdb_num_regs  -  CSR_TABLE_SIZE);
    ...
``` ?

Or maybe we don't need this refresh function, and just add ext_ssaia &
ext_smaia in the command line.

Best Regards,
Tommy

On Thu, May 25, 2023 at 10:33 AM Alistair Francis <alistair23@gmail.com>
wrote:

> On Tue, May 23, 2023 at 9:46 PM Tommy Wu <tommy.wu@sifive.com> wrote:
> >
> > 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 <tommy.wu@sifive.com>
> > Reviewed-by: Frank Chang <frank.chang@sifive.com>
> > ---
> >  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, "<?xml version=\"1.0\"?>");
> >      g_string_append_printf(s, "<!DOCTYPE feature SYSTEM
> \"gdb-target.dtd\">");
> >      g_string_append_printf(s, "<feature
> name=\"org.gnu.gdb.riscv.csr\">");
> > @@ -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);
>
> I don't really understand why we need dyn_csr_base_reg, could we just
> use cs->gdb_num_regs directly here?
>
> Alistair
>
> > +}
> > --
> > 2.38.1
> >
> >
>

[-- Attachment #2: Type: text/html, Size: 4188 bytes --]

  reply	other threads:[~2023-06-09  8:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 11:44 [PATCH 0/2] Refresh the dynamic CSR xml after updating the state of the cpu Tommy Wu
2023-05-23 11:44 ` [PATCH 1/2] target/riscv: Add a function to refresh the dynamic CSRs xml Tommy Wu
2023-05-23 14:37   ` Weiwei Li
2023-05-24  1:59     ` Tommy Wu
2023-05-24  2:10       ` Weiwei Li
2023-05-24  5:35         ` Tommy Wu
2023-05-24  6:18           ` Weiwei Li
2023-05-25  2:33   ` Alistair Francis
2023-06-09  8:37     ` Tommy Wu [this message]
2023-06-12  2:52       ` Alistair Francis
2023-05-23 11:44 ` [PATCH 2/2] hw/intc: riscv_imsic: Refresh the CSRs xml after updating the state of the cpu Tommy Wu
2023-05-23 14:43   ` Weiwei Li
2023-05-24  1:51     ` Tommy Wu
2023-05-24  2:34       ` Weiwei Li
2023-05-24  5:46         ` Tommy Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANj3q_ng7=2-gosL7HywNRVcqZqkK4aWodBNp6rjqV8OpMJDEA@mail.gmail.com' \
    --to=tommy.wu@sifive.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=apatel@ventanamicro.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=frank.chang@sifive.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=palmer@rivosinc.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).