All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Liu <chao.liu.zevorn@gmail.com>
To: Zephyr Li <fritchleybohrer@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, palmer@dabbelt.com,
	 alistair.francis@wdc.com, liwei1518@gmail.com,
	zhiwei_liu@linux.alibaba.com,  daniel.barboza@oss.qualcomm.com
Subject: Re: [PATCH] target/riscv: Do not hide Sstc CSRs from gdbstub
Date: Mon, 25 May 2026 12:29:35 +0800	[thread overview]
Message-ID: <ahPQJbUYBqXx8dfc@ChaodeMacBook-Pro.local> (raw)
In-Reply-To: <20260525024220.39027-1-fritchleybohrer@gmail.com>

On Mon, May 25, 2026 at 10:42:20AM +0800, Zephyr Li wrote:
> The Sstc predicate currently checks both ext_sstc and rdtime_fn. This
> causes the gdbstub CSR XML generation to skip Sstc CSRs when rdtime_fn
> has not been initialized yet, even if the CPU supports Sstc.
> 
> As a result, GDB reports $stimecmp as void with a CPU that exposes the
> sstc extension.
> 
> Only use ext_sstc for the early existence check, and keep the rdtime_fn
> check for non-debugger accesses.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3496
> Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>

Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>

> ---
> 
> Testing:
>     Start QEMU with:
>         qemu-system-riscv64 -M virt,aclint=on -cpu max,sstc=true -s -S -nographic
> 
>     Before:
>         (gdb) p $stimecmp
>         $1 = void
> 
>     After:
>         (gdb) p $stimecmp
>         $1 = 0
> 
>  target/riscv/csr.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index da366cf562..c17df147f7 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -586,7 +586,7 @@ static RISCVException sstc(CPURISCVState *env, int csrno)
>  {
>      bool hmode_check = false;
>  
> -    if (!riscv_cpu_cfg(env)->ext_sstc || !env->rdtime_fn) {
> +    if (!riscv_cpu_cfg(env)->ext_sstc) {
>          return RISCV_EXCP_ILLEGAL_INST;
>      }
>  
> @@ -603,6 +603,10 @@ static RISCVException sstc(CPURISCVState *env, int csrno)
>          return RISCV_EXCP_NONE;
>      }
>  
> +    if (!env->rdtime_fn) {
> +        return RISCV_EXCP_ILLEGAL_INST;
> +    }
> +
>      if (env->priv == PRV_M) {
>          return RISCV_EXCP_NONE;
>      }
> -- 
> 2.43.0
> 


  reply	other threads:[~2026-05-25  4:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25  2:42 [PATCH] target/riscv: Do not hide Sstc CSRs from gdbstub Zephyr Li
2026-05-25  4:29 ` Chao Liu [this message]
2026-05-27  0:05 ` Alistair Francis
2026-05-27  0:09 ` 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=ahPQJbUYBqXx8dfc@ChaodeMacBook-Pro.local \
    --to=chao.liu.zevorn@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=fritchleybohrer@gmail.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.