]> 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)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 May 2025 06:55:13 +0000 (09:55 +0300)
commitbc15a8db4ff857172625176b03b03138aa7624d1
tree67272b8db515d1c390f303b7112915172351bb23
parent504dcda206464fe30ebf8224fc39a963dadad1e6
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
(cherry picked from commit 19cf1a7d9e59b71bf8d6571d4747e5c82667c3d1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/pmp.c