Skip to content

Commit 86c78b2

Browse files
deepak0414alistair23
authored andcommitted
target/riscv: fix access permission checks for CSR_SSP
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: 8205bc1 ("target/riscv: introduce ssp and enabling controls for zicfiss". Thanks to Adam Zabrocki for bringing this to attention. Reported-by: Adam Zabrocki <[email protected]> Signed-off-by: Deepak Gupta <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent 17288e3 commit 86c78b2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

target/riscv/csr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ static RISCVException cfi_ss(CPURISCVState *env, int csrno)
192192
return RISCV_EXCP_ILLEGAL_INST;
193193
}
194194

195+
/* If ext implemented, M-mode always have access to SSP CSR */
196+
if (env->priv == PRV_M) {
197+
return RISCV_EXCP_NONE;
198+
}
199+
195200
/* if bcfi not active for current env, access to csr is illegal */
196201
if (!cpu_get_bcfien(env)) {
197202
#if !defined(CONFIG_USER_ONLY)

0 commit comments

Comments
 (0)