]> 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)
committerAlistair Francis <alistair.francis@wdc.com>
Mon, 19 May 2025 03:27:56 +0000 (13:27 +1000)
commit4541d205f03cf1529439f68d2ec5056685189399
tree53fe566f7d36553ae5c3d4685aaf6bd5a8e0784e
parentcd18dbbf9d23f309f3e46c38b99213dbe3d48d17
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
target/riscv/pmp.c