aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Meng <bmeng@tinylab.org>2023-02-28 18:40:19 +0800
committerPalmer Dabbelt <palmer@rivosinc.com>2023-03-01 16:40:12 -0800
commit0ee342256af9205e7388efdf193a6d8f1ba1a617 (patch)
tree124c9b5f95c9ce6118682aa8897d91280b50fc55
parenta5e0f68652fe1ed0231311d6c8aaeaf55c631821 (diff)
downloadqemu-0ee342256af9205e7388efdf193a6d8f1ba1a617.zip
qemu-0ee342256af9205e7388efdf193a6d8f1ba1a617.tar.gz
qemu-0ee342256af9205e7388efdf193a6d8f1ba1a617.tar.bz2
target/riscv: Use g_assert() for the predicate() NULL check
At present riscv_csrrw_check() checks the CSR predicate() against NULL and throws RISCV_EXCP_ILLEGAL_INST if it is NULL. But this is a pure software check, and has nothing to do with the emulation of the hardware behavior, thus it is inappropriate to return illegal instruction exception when software forgets to install the hook. Change to use g_assert() instead. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Weiwei Li<liweiwei@iscas.ac.cn> Message-ID: <20230228104035.1879882-4-bmeng@tinylab.org> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
-rw-r--r--target/riscv/csr.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 4cc2c63..cfd7ffc 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -3786,11 +3786,6 @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env,
return RISCV_EXCP_ILLEGAL_INST;
}
- /* check predicate */
- if (!csr_ops[csrno].predicate) {
- return RISCV_EXCP_ILLEGAL_INST;
- }
-
/* read / write check */
if (write_mask && read_only) {
return RISCV_EXCP_ILLEGAL_INST;
@@ -3803,6 +3798,7 @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env,
* illegal instruction exception should be triggered instead of virtual
* instruction exception. Hence this comes after the read / write check.
*/
+ g_assert(csr_ops[csrno].predicate != NULL);
RISCVException ret = csr_ops[csrno].predicate(env, csrno);
if (ret != RISCV_EXCP_NONE) {
return ret;