]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv: pmp: fix checks on writes to pmpcfg in Smepmp MML mode
authorLoïc Lefort <loic@rivosinc.com>
Thu, 13 Mar 2025 19:30:09 +0000 (20:30 +0100)
committerAlistair Francis <alistair.francis@wdc.com>
Mon, 19 May 2025 03:29:29 +0000 (13:29 +1000)
commit19cf1a7d9e59b71bf8d6571d4747e5c82667c3d1
treefb5993c8e6b8c77f25954c904031ff70cae96855
parent915b203745540e908943758f78f5da49e0a15e45
target/riscv: pmp: fix checks on writes to pmpcfg in Smepmp MML mode

With Machine Mode Lockdown (mseccfg.MML) set and RLB not set, checks on pmpcfg
writes would match the wrong cases of Smepmp truth table.

The existing code allows writes for the following cases:
- L=1, X=0: cases 8, 10, 12, 14
- L=0, RWX!=WX: cases 0-2, 4-6
This leaves cases 3, 7, 9, 11, 13, 15 for which writes are ignored.

From the Smepmp specification: "Adding a rule with executable privileges that
either is M-mode-only or a locked Shared-Region is not possible (...)" This
description matches cases 9-11, 13 of the truth table.

This commit implements an explicit check for these cases by using
pmp_get_epmp_operation to convert between PMP configuration and Smepmp truth
table cases.

Signed-off-by: Loïc Lefort <loic@rivosinc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-ID: <20250313193011.720075-4-loic@rivosinc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Cc: qemu-stable@nongnu.org
target/riscv/pmp.c