diff options
author | Andrew Bresticker <abrestic@rivosinc.com> | 2022-12-15 17:45:41 -0500 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2023-01-20 10:14:14 +1000 |
commit | e471a8c9850f1af0c1bc5768ca28285348cdd6c5 (patch) | |
tree | a8be9f3c6190f5b4de4f52e97ac7b1a68e45e868 | |
parent | 06d85c24c28f42a57680dc21955e343f58d93089 (diff) | |
download | qemu-e471a8c9850f1af0c1bc5768ca28285348cdd6c5.zip qemu-e471a8c9850f1af0c1bc5768ca28285348cdd6c5.tar.gz qemu-e471a8c9850f1af0c1bc5768ca28285348cdd6c5.tar.bz2 |
target/riscv: Trap on writes to stimecmp from VS when hvictl.VTI=1
Per the AIA specification, writes to stimecmp from VS level should
trap when hvictl.VTI is set since the write may cause vsip.STIP to
become unset.
Fixes: 3ec0fe18a31f ("target/riscv: Add vstimecmp support")
Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20221215224541.1423431-2-abrestic@rivosinc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
-rw-r--r-- | target/riscv/csr.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 270de7b..62e6c4a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1037,6 +1037,9 @@ static RISCVException write_stimecmp(CPURISCVState *env, int csrno, RISCVCPU *cpu = env_archcpu(env); if (riscv_cpu_virt_enabled(env)) { + if (env->hvictl & HVICTL_VTI) { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } return write_vstimecmp(env, csrno, val); } @@ -1057,6 +1060,9 @@ static RISCVException write_stimecmph(CPURISCVState *env, int csrno, RISCVCPU *cpu = env_archcpu(env); if (riscv_cpu_virt_enabled(env)) { + if (env->hvictl & HVICTL_VTI) { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } return write_vstimecmph(env, csrno, val); } |