From: Alistair Francis <alistair23@gmail.com>
To: Himanshu Chauhan <hchauhan@ventanamicro.com>
Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] target/riscv: Raise an exception when sdtrig is turned off
Date: Fri, 12 Jan 2024 13:33:21 +1000 [thread overview]
Message-ID: <CAKmqyKNgWS2wdkMGJTdV7nPpjT5XZWEnynf0ir5WSiRBf8xC8g@mail.gmail.com> (raw)
In-Reply-To: <20240110040203.1920924-3-hchauhan@ventanamicro.com>
On Wed, Jan 10, 2024 at 2:03 PM Himanshu Chauhan
<hchauhan@ventanamicro.com> wrote:
>
> When sdtrig is turned off by "sdtrig=false" option, raise
> and illegal instruction exception on any read/write to
> sdtrig CSRs.
>
> Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
> ---
> target/riscv/csr.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index c50a33397c..b9ca016ef2 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -3854,6 +3854,10 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno,
> static RISCVException read_tselect(CPURISCVState *env, int csrno,
> target_ulong *val)
> {
> + if (!riscv_cpu_cfg(env)->ext_sdtrig) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
Thanks for the patch!
You should be able to add this check to the
static RISCVException debug(CPURISCVState *env, int csrno)
function instead
Alistair
> +
> *val = tselect_csr_read(env);
> return RISCV_EXCP_NONE;
> }
> @@ -3861,6 +3865,10 @@ static RISCVException read_tselect(CPURISCVState *env, int csrno,
> static RISCVException write_tselect(CPURISCVState *env, int csrno,
> target_ulong val)
> {
> + if (!riscv_cpu_cfg(env)->ext_sdtrig) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
> +
> tselect_csr_write(env, val);
> return RISCV_EXCP_NONE;
> }
> @@ -3868,6 +3876,10 @@ static RISCVException write_tselect(CPURISCVState *env, int csrno,
> static RISCVException read_tdata(CPURISCVState *env, int csrno,
> target_ulong *val)
> {
> + if (!riscv_cpu_cfg(env)->ext_sdtrig) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
> +
> /* return 0 in tdata1 to end the trigger enumeration */
> if (env->trigger_cur >= RV_MAX_TRIGGERS && csrno == CSR_TDATA1) {
> *val = 0;
> @@ -3885,6 +3897,10 @@ static RISCVException read_tdata(CPURISCVState *env, int csrno,
> static RISCVException write_tdata(CPURISCVState *env, int csrno,
> target_ulong val)
> {
> + if (!riscv_cpu_cfg(env)->ext_sdtrig) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
> +
> if (!tdata_available(env, csrno - CSR_TDATA1)) {
> return RISCV_EXCP_ILLEGAL_INST;
> }
> @@ -3896,6 +3912,10 @@ static RISCVException write_tdata(CPURISCVState *env, int csrno,
> static RISCVException read_tinfo(CPURISCVState *env, int csrno,
> target_ulong *val)
> {
> + if (!riscv_cpu_cfg(env)->ext_sdtrig) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
> +
> *val = tinfo_csr_read(env);
> return RISCV_EXCP_NONE;
> }
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2024-01-12 3:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 4:02 [PATCH 0/2] Export debug triggers as an extension Himanshu Chauhan
2024-01-10 4:02 ` [PATCH 1/2] target/riscv: Export sdtrig as an extension and ISA string Himanshu Chauhan
2024-01-12 3:34 ` Alistair Francis
2024-01-10 4:02 ` [PATCH 2/2] target/riscv: Raise an exception when sdtrig is turned off Himanshu Chauhan
2024-01-12 3:33 ` Alistair Francis [this message]
2024-01-10 19:19 ` [PATCH 0/2] Export debug triggers as an extension Daniel Henrique Barboza
2024-01-12 3:52 ` Alistair Francis
2024-01-12 13:34 ` Rob Bradford
2024-01-17 16:59 ` Daniel Henrique Barboza
2024-01-17 17:44 ` Himanshu Chauhan
2024-01-22 5:42 ` Alistair Francis
2024-01-22 9:16 ` Andrew Jones
2024-02-05 4:05 ` Alistair Francis
2024-02-05 4:50 ` Anup Patel
2024-02-05 5:57 ` Alistair Francis
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=CAKmqyKNgWS2wdkMGJTdV7nPpjT5XZWEnynf0ir5WSiRBf8xC8g@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=hchauhan@ventanamicro.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/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).