diff options
author | Frank Chang <frank.chang@sifive.com> | 2022-09-09 21:42:11 +0800 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2022-09-27 11:23:57 +1000 |
commit | 6ea8d3fc40a8db8d22d00255cea9f9f8c927d643 (patch) | |
tree | 0e566c797c43aac3b3c3f29bc087e6362ab5ffa1 | |
parent | 9495c4888a80809ab9dba6d6e536b21c018c77a4 (diff) | |
download | qemu-6ea8d3fc40a8db8d22d00255cea9f9f8c927d643.zip qemu-6ea8d3fc40a8db8d22d00255cea9f9f8c927d643.tar.gz qemu-6ea8d3fc40a8db8d22d00255cea9f9f8c927d643.tar.bz2 |
target/riscv: debug: Restrict the range of tselect value can be written
The value of tselect CSR can be written should be limited within the
range of supported triggers number.
Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-Id: <20220909134215.1843865-5-bmeng.cn@gmail.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
-rw-r--r-- | target/riscv/debug.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 06feef7..d666616 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -127,10 +127,6 @@ bool tdata_available(CPURISCVState *env, int tdata_index) return false; } - if (unlikely(env->trigger_cur >= RV_MAX_TRIGGERS)) { - return false; - } - return tdata_mapping[trigger_type][tdata_index]; } @@ -141,8 +137,9 @@ target_ulong tselect_csr_read(CPURISCVState *env) void tselect_csr_write(CPURISCVState *env, target_ulong val) { - /* all target_ulong bits of tselect are implemented */ - env->trigger_cur = val; + if (val < RV_MAX_TRIGGERS) { + env->trigger_cur = val; + } } static target_ulong tdata1_validate(CPURISCVState *env, target_ulong val, |