All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target/riscv: Fix exception type when VU accesses supervisor CSRs
@ 2025-07-08  6:07 Xu Lu
  2025-07-08  8:32 ` Xu Lu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Xu Lu @ 2025-07-08  6:07 UTC (permalink / raw)
  To: palmer, alistair.francis, liwei1518, zhiwei_liu, apatel
  Cc: qemu-riscv, qemu-devel, Xu Lu

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;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-29  3:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-07-29  3:25 ` Alistair Francis

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.