qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] target/riscv: fix access permission checks for CSR_SSP
@ 2025-03-06  6:46 Deepak Gupta
  2025-03-06  6:46 ` [PATCH v2 2/2] target/riscv: fixes a bug against `ssamoswap` behavior in M-mode Deepak Gupta
  2025-03-21 18:01 ` [PATCH v2 1/2] target/riscv: fix access permission checks for CSR_SSP Michael Tokarev
  0 siblings, 2 replies; 7+ messages in thread
From: Deepak Gupta @ 2025-03-06  6:46 UTC (permalink / raw)
  To: qemu-riscv, qemu-devel
  Cc: palmer, alistair.francis, bmeng.cn, liwei1518, dbarboza,
	zhiwei_liu, Deepak Gupta, Adam Zabrocki

Commit:8205bc1 ("target/riscv: introduce ssp and enabling controls for
zicfiss") introduced CSR_SSP but it mis-interpreted the spec on access
to CSR_SSP in M-mode. Gated to CSR_SSP is not gated via `xSSE`. But
rather rules clearly specified in section "22.2.1. Shadow Stack Pointer
(ssp) CSR access contr" in the priv spec.

Fixes: 8205bc127a83 ("target/riscv: introduce ssp and enabling controls
for zicfiss". Thanks to Adam Zabrocki for bringing this to attention.

Reported-by: Adam Zabrocki <azabrocki@nvidia.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/csr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index afb7544f07..75c661d2a1 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -191,6 +191,11 @@ static RISCVException cfi_ss(CPURISCVState *env, int csrno)
         return RISCV_EXCP_ILLEGAL_INST;
     }
 
+    /* If ext implemented, M-mode always have access to SSP CSR */
+    if (env->priv == PRV_M) {
+        return RISCV_EXCP_NONE;
+    }
+
     /* if bcfi not active for current env, access to csr is illegal */
     if (!cpu_get_bcfien(env)) {
 #if !defined(CONFIG_USER_ONLY)
-- 
2.34.1



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

end of thread, other threads:[~2025-03-24  3:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06  6:46 [PATCH v2 1/2] target/riscv: fix access permission checks for CSR_SSP Deepak Gupta
2025-03-06  6:46 ` [PATCH v2 2/2] target/riscv: fixes a bug against `ssamoswap` behavior in M-mode Deepak Gupta
2025-03-07  1:59   ` Alistair Francis
2025-03-07  2:04   ` Alistair Francis
2025-03-07  3:23     ` Deepak Gupta
2025-03-21 18:01 ` [PATCH v2 1/2] target/riscv: fix access permission checks for CSR_SSP Michael Tokarev
2025-03-24  3:05   ` Alistair Francis

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).