From: Frédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
Peter reported undefined behaviors in x-rv128 pmp configuration
registers accesses detected by the clang sanitizer.
This series introduces a 128-bit version of these accesses, and
corrects other out-of-bound shifts within the handling of interrupts
that were triggered afterwards.
Changes in v5:
- Fixe the 'Fixes:' trailer lines
Note that patch 3 has a Medium issue reported by Sashiko AI
regarding the state update in riscv_cpu_post_load.
Since the correct "cause" values are computed on demand, such
state update is not necessary.
Changes in v4:
- Change version_id in machine states as we are adding new fields,
- Add Fixes: trailers in commits
Note that Sashiko AI reports a misuse of riscv_cpu_sxl in patch 2,
while all calls are related to the use of scause (or vscause).
Changes in v3:
- Extract the "interrupt" bitfield in the different versions of the
cause register in a separate field of cpu.h and build the cause
registers value on demand,
- Add these new fields into the machine migration state,
- Check that the pmp registers used in rv128 are only those allowed,
- Add tcg tests for mcause and scause accesses.
Changes in v2:
- I messed up and directly assigned a 0 to an Int128, so v2 corrects
that.
Frédéric Pétrot (4):
target/riscv: fix pmp sanitize error for x-rv128
target/riscv: fix riscv_cpu_do_interrupt sanitize error for x-rv128
target/riscv: Update machine state
target/riscv: [ms]cause tcg tests for x-rv128
target/riscv/cpu.c | 1 +
target/riscv/cpu.h | 4 +
target/riscv/machine.c | 12 ++-
target/riscv/tcg/cpu_helper.c | 20 ++++-
target/riscv/tcg/csr.c | 95 ++++++++++++++++++++----
target/riscv/tcg/csr.h | 3 +
target/riscv/tcg/pmp.c | 38 ++++++++++
tests/tcg/riscv64/system/meson.build | 14 ++++
tests/tcg/riscv64/test-rv128-mcause.S | 101 ++++++++++++++++++++++++++
tests/tcg/riscv64/test-rv128-scause.S | 94 ++++++++++++++++++++++++
10 files changed, 362 insertions(+), 20 deletions(-)
create mode 100644 tests/tcg/riscv64/test-rv128-mcause.S
create mode 100644 tests/tcg/riscv64/test-rv128-scause.S
--
2.43.0