target/riscv: fix hedeleg writable mask [GL4592]
Subsystems (2)
PATCH 1/1 target/riscv: fix hedeleg writable mask [GL4592]
Bit 19 (hardware error) must be writable in hedeleg, i.e. it must be delegable. Add it DELEGABLE_EXCPS.
While we're at it, hedeleg bit 0 is only writable if IALIGN = 16, i.e. RVC is enabled. Remove bit 0 from the delegation/writable mask if RVC is enabled.
Fixes bc083a51caff ("target/riscv: hardwire bits in hideleg and hedeleg")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4592
Signed-off-by Daniel Henrique Barboza <[email protected]>
--- target/riscv/tcg/csr.c | 11 +++++ tests/tcg/riscv64/system/meson.build | 7 ++++ tests/tcg/riscv64/test-hedeleg-write.S | 57 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 tests/tcg/riscv64/test-hedeleg-write.S
target/riscv/tcg/csr.c +11 -0
@@ -1837,6 +1837,7 @@ static const uint64_t all_ints = M_MODE_INTERRUPTS | S_MODE_INTERRUPTS | (1ULL << (RISCV_EXCP_LOAD_PAGE_FAULT )) | \ (1ULL << (RISCV_EXCP_STORE_PAGE_FAULT )) | \ (1ULL << (RISCV_EXCP_SW_CHECK )) | \ + (1ULL << (RISCV_EXCP_HW_ERR )) | \ (1ULL << (RISCV_EXCP_INST_GUEST_PAGE_FAULT )) | \ (1ULL << (RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT )) | \ (1ULL << (RISCV_EXCP_VIRT_INSTRUCTION_FAULT)) | \
@@ -4913,6 +4914,16 @@ static RISCVException write_hedeleg(CPURISCVState *env, int csrno, target_ulong val, uintptr_t ra) { env->hedeleg = val & vs_delegable_excps; + +/* +* delegable_excps includes bit 0, which is writable only if +* IALIGN = 32 (no RVC present). Ergo clear bit 0 if we have +* RVC. +*/ +if (riscv_has_ext (env,RVC )) { + env->hedeleg &= ~1ULL ; + } +return RISCV_EXCP_NONE ; }
tests/tcg/riscv64/system/meson.build +7 -0
@@ -89,6 +89,13 @@ tests += { } } +tests += { + 'test-hedeleg-write.S': { + 'cflags': cflags, + 'qemu_args': ['-cpu', 'max', qemu_args], + } +} + if 'qemu-system-riscv64' in emulators tcg_tests += { 'riscv64-softmmu': {
tests/tcg/riscv64/test-hedeleg-write.S new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.43.0