]> git.ipfire.org Git - thirdparty/qemu.git/commit
tests/tcg/riscv64: Add test for MEPC bit masking
authorCharalampos Mitrodimas <charmitro@posteo.net>
Thu, 3 Jul 2025 18:21:44 +0000 (18:21 +0000)
committerAlistair Francis <alistair.francis@wdc.com>
Fri, 4 Jul 2025 11:09:49 +0000 (21:09 +1000)
commita1f44e0c59081afceb5e2b389b6de96602f73977
tree57cdb4dc02e76a3ff2afe43e8e9de85f48a084c4
parentb3452452e64be647fef98d2dce16c3f5c149235a
tests/tcg/riscv64: Add test for MEPC bit masking

Add a regression test to verify that MEPC properly masks the lower
bits when an address with mode bits is written to it, as required by
the RISC-V Privileged Architecture specification.

The test sets STVEC to an address with bit 0 set (vectored mode),
triggers an illegal instruction exception, copies STVEC to MEPC in the
trap handler, and verifies that MEPC masks bits [1:0] correctly for
IALIGN=32.

Without the fix, MEPC retains the mode bits (returns non-zero/FAIL).
With the fix, MEPC clears bits [1:0] (returns 0/PASS).

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Message-ID: <20250703182157.281320-3-charmitro@posteo.net>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
tests/tcg/riscv64/Makefile.softmmu-target
tests/tcg/riscv64/test-mepc-masking.S [new file with mode: 0644]