]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv: pmp: don't allow RLB to bypass rule privileges
authorLoïc Lefort <loic@rivosinc.com>
Thu, 13 Mar 2025 19:30:07 +0000 (20:30 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 May 2025 06:54:12 +0000 (09:54 +0300)
commitf82dd2837c30af394fa5285523f2f517815c83a1
tree1489a34169e876f62d93f5cd27cd98b261befcc1
parent15143814cddef24b69f3b19a9baca1b964dfe40c
target/riscv: pmp: don't allow RLB to bypass rule privileges

When Smepmp is supported, mseccfg.RLB allows bypassing locks when writing CSRs
but should not affect interpretation of actual PMP rules.

This is not the case with the current implementation where pmp_hart_has_privs
calls pmp_is_locked which implements mseccfg.RLB bypass.

This commit implements the correct behavior by removing mseccfg.RLB bypass from
pmp_is_locked.

RLB bypass when writing CSRs is implemented by adding a new pmp_is_readonly
function that calls pmp_is_locked and check mseccfg.RLB. pmp_write_cfg and
pmpaddr_csr_write are changed to use this new function.

Signed-off-by: Loïc Lefort <loic@rivosinc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: LIU Zhiwei  <zhiwei_liu@linux.alibaba.com>
Message-ID: <20250313193011.720075-2-loic@rivosinc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Cc: qemu-stable@nongnu.org
(cherry picked from commit 4541d205f03cf1529439f68d2ec5056685189399)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/pmp.c