@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/target-info.h"
#include "qemu/log.h"
#include "qemu/timer.h"
#include "cpu.h"
@@ -2143,17 +2144,18 @@ static RISCVException read_misa_i128(CPURISCVState *env, int csrno,
static RISCVException read_misa(CPURISCVState *env, int csrno,
target_ulong *val)
{
- target_ulong misa;
+ uint64_t misa;
switch (env->misa_mxl) {
case MXL_RV32:
- misa = (target_ulong)MXL_RV32 << 30;
+ misa = (uint64_t)MXL_RV32 << 30;
break;
-#ifdef TARGET_RISCV64
case MXL_RV64:
- misa = (target_ulong)MXL_RV64 << 62;
+ if (!target_riscv64()) {
+ g_assert_not_reached();
+ }
+ misa = (uint64_t)MXL_RV64 << 62;
break;
-#endif
default:
g_assert_not_reached();
}
@@ -5430,13 +5432,11 @@ static RISCVException read_pmpaddr(CPURISCVState *env, int csrno,
* here to avoid complaints about masking bits 0-53
* of a potential 32 bit target_ulong '*var'.
*/
-#ifdef TARGET_RISCV64
- if (env->misa_mxl == MXL_RV64
+ if (target_riscv64() && env->misa_mxl == MXL_RV64
&& csrno >= CSR_PMPADDR0 && csrno <= CSR_PMPADDR63) {
- target_ulong read_mask = MAKE_64BIT_MASK(0, 54);
+ uint64_t read_mask = MAKE_64BIT_MASK(0, 54);
*val &= read_mask;
}
-#endif
return RISCV_EXCP_NONE;
}
@@ -5755,7 +5755,7 @@ RISCVException riscv_csrrw(CPURISCVState *env, int csrno,
RISCVException riscv_csr_write_i64(CPURISCVState *env, int csrno, uint64_t val)
{
return riscv_csrrw(env, csrno, NULL, val,
- MAKE_64BIT_MASK(0, TARGET_LONG_BITS), 0);
+ MAKE_64BIT_MASK(0, target_long_bits()), 0);
}
RISCVException riscv_csr_read_i64(CPURISCVState *env, int csrno, uint64_t *res)
- Use target_long_bits() instead of TARGET_LONG_BITS for the CSR write mask. - Use target_riscv64() instead of TARGET_RISCV64 for MISA RV64 and the PMP address mask. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> --- target/riscv/tcg/csr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)