From: Chao Liu via <qemu-riscv@nongnu.org>
To: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Chinmay Rath" <rathc@linux.ibm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Helge Deller" <deller@gmx.de>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Warner Losh" <imp@bsdimp.com>, "Kyle Evans" <kevans@freebsd.org>
Subject: Re: [PATCH 08/10] target/riscv: bypass smstateen check in debugger mode
Date: Thu, 1 Oct 2026 08:57:21 +0800 [thread overview]
Message-ID: <ar2sNh_PW7XllZF0@MacBook-Pro-4.local> (raw)
In-Reply-To: <7a320a89-efb4-4520-80bf-d673d514e39a@oss.qualcomm.com>
On Wed, Sep 30, 2026 at 03:24:34PM +0800, Daniel Henrique Barboza wrote:
>
>
> On 9/11/2026 9:27 AM, Marc-André Lureau wrote:
> > Allow to read CSRs gated by Smstateen extension when env->debugger.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > target/riscv/tcg/csr.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/target/riscv/tcg/csr.c b/target/riscv/tcg/csr.c
> > index bd4b6dc114bc..93a7f419f29f 100644
> > --- a/target/riscv/tcg/csr.c
> > +++ b/target/riscv/tcg/csr.c
> > @@ -53,7 +53,8 @@ RISCVException smstateen_acc_ok(CPURISCVState *env, int index, uint64_t bit)
> > {
> > bool virt = env->virt_enabled;
> > - if (env->priv == PRV_M || !riscv_cpu_cfg(env)->ext_smstateen) {
> > + if (env->debugger || env->priv == PRV_M ||
> > + !riscv_cpu_cfg(env)->ext_smstateen) {
>
> We have an going work in qemu-riscv (sdext, currently on v10) that adds
> a new 'debug' mode that is higher than the machine mode (PRV_M). It
> already uses env->debugger in its logic.
>
Looks good to me. Debug Mode uses M-mode privileges as a baseline, with
additional access to debug-only CSRs.
One thought came to mind here that I'd like to share: for CSR access,
`env->debugger` and 'debug' mode both indicate a debugging context,
entered through QEMU's GDB stub or the CPU's architectural debug
mechanism. CSR access rules differ in that context.
I think a shared helper could check these two flags together,
and include `PRV_M` where the same access rules apply. This is outside
the scope of this patch, but we can look into it once Sdext is merged.
I'll work on it if I have time.
Reviewed-by: Chao Liu <chao.liu@processmission.com>
Thanks,
Chao
> I believe this change is already in line with what we want there, i.e. debug
> mode having at least the same accesses as PRV_M.
>
>
> Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
>
>
>
> > return RISCV_EXCP_NONE;
> > }
> >
>
next prev parent reply other threads:[~2026-10-01 0:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 12:27 [PATCH 00/10] monitor/hmp: replace MonitorDef with GDB registers Marc-André Lureau
2026-09-11 12:27 ` [PATCH 01/10] hmp: don't crash on invalid register Marc-André Lureau
2026-09-30 16:59 ` Philippe Mathieu-Daudé
2026-09-11 12:27 ` [PATCH 02/10] gdbstub: fix next register base after register gaps Marc-André Lureau
2026-09-11 15:29 ` Alex Bennée
2026-09-11 12:27 ` [PATCH 03/10] gdbstub: set feature->base_reg for dynamic features Marc-André Lureau
2026-09-30 17:18 ` Philippe Mathieu-Daudé
2026-09-11 12:27 ` [PATCH 04/10] target/i386: expose segment limits via GDB Marc-André Lureau
2026-09-11 12:27 ` [PATCH 05/10] monitor/hmp: add CPUClass::get_pc fallback for HMP $pc Marc-André Lureau
2026-09-30 17:31 ` Philippe Mathieu-Daudé
2026-09-11 12:27 ` [PATCH 06/10] target/m68k: expose system registers via GDB Marc-André Lureau
2026-09-11 12:27 ` [PATCH 07/10] target/sparc64: " Marc-André Lureau
2026-09-11 12:27 ` [PATCH 08/10] target/riscv: bypass smstateen check in debugger mode Marc-André Lureau
2026-09-30 18:24 ` Daniel Henrique Barboza
2026-10-01 0:57 ` Chao Liu via [this message]
2026-09-11 12:27 ` [PATCH 09/10] target/riscv: expose register aliases via GDB Marc-André Lureau
2026-09-11 12:27 ` [PATCH 10/10] monitor/hmp: remove legacy MonitorDef infrastructure Marc-André Lureau
2026-09-30 8:49 ` [PATCH 00/10] monitor/hmp: replace MonitorDef with GDB registers Marc-André Lureau
2026-09-30 17:18 ` Philippe Mathieu-Daudé
2026-10-01 8:00 ` Akihiko Odaki
2026-10-06 14:31 ` Marc-André Lureau
2026-10-07 3:08 ` Akihiko Odaki
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=ar2sNh_PW7XllZF0@MacBook-Pro-4.local \
--to=qemu-riscv@nongnu.org \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=atar4qemu@gmail.com \
--cc=chao.liu@processmission.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=dave@treblig.org \
--cc=deller@gmx.de \
--cc=harshpb@linux.ibm.com \
--cc=imp@bsdimp.com \
--cc=jcmvbkbc@gmail.com \
--cc=kevans@freebsd.org \
--cc=laurent@vivier.eu \
--cc=liwei1518@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=zhao1.liu@intel.com \
--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