From: "Nutty Liu" <liujingqi@lanxincomputing.com>
To: "Xu Lu" <luxu.kernel@bytedance.com>, <palmer@dabbelt.com>,
<alistair.francis@wdc.com>, <liwei1518@gmail.com>,
<zhiwei_liu@linux.alibaba.com>, <apatel@ventanamicro.com>
Cc: <qemu-riscv@nongnu.org>, <qemu-devel@nongnu.org>
Subject: Re: [PATCH] target/riscv: Fix exception type when VU accesses supervisor CSRs
Date: Mon, 21 Jul 2025 15:40:51 +0800 [thread overview]
Message-ID: <883ca2b3-9054-4578-b46f-efb8d67f32d3@lanxincomputing.com> (raw)
In-Reply-To: <20250708060720.7030-1-luxu.kernel@bytedance.com>
On 7/8/2025 2:07 PM, Xu Lu wrote:
> When supervisor CSRs are accessed from VU-mode, a virtual instruction
> exception should be raised instead of an illegal instruction.
>
> Fixes: c1fbcecb3a (target/riscv: Fix csr number based privilege checking)
> Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
> ---
> target/riscv/csr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 8631be97c5..9bebfae3f0 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -5577,7 +5577,7 @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env,
>
> csr_priv = get_field(csrno, 0x300);
> if (!env->debugger && (effective_priv < csr_priv)) {
> - if (csr_priv == (PRV_S + 1) && env->virt_enabled) {
> + if (csr_priv <= (PRV_S + 1) && env->virt_enabled) {
> return RISCV_EXCP_VIRT_INSTRUCTION_FAULT;
> }
> return RISCV_EXCP_ILLEGAL_INST;
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Thanks,
Nutty
next prev parent reply other threads:[~2025-07-21 7:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 6:07 [PATCH] target/riscv: Fix exception type when VU accesses supervisor CSRs Xu Lu
2025-07-08 8:32 ` Xu Lu
2025-07-15 10:03 ` Anup Patel
2025-07-21 7:40 ` Nutty Liu [this message]
2025-07-29 3:25 ` 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=883ca2b3-9054-4578-b46f-efb8d67f32d3@lanxincomputing.com \
--to=liujingqi@lanxincomputing.com \
--cc=alistair.francis@wdc.com \
--cc=apatel@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=luxu.kernel@bytedance.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.