static RISCVException read_minstretcfg(CPURISCVState *env, int csrno,
target_ulong *val)
{
- *val = env->minstretcfg;
+ bool rv32 = riscv_cpu_mxl(env) == MXL_RV32;
+ *val = extract64(env->minstretcfg, 0, rv32 ? 32 : 64);
return RISCV_EXCP_NONE;
}
static RISCVException read_minstretcfgh(CPURISCVState *env, int csrno,
target_ulong *val)
{
- *val = env->minstretcfgh;
+ *val = extract64(env->minstretcfg, 32, 32);
return RISCV_EXCP_NONE;
}
inh_avail_mask |= (riscv_has_ext(env, RVH) &&
riscv_has_ext(env, RVS)) ? MINSTRETCFGH_BIT_VSINH : 0;
- env->minstretcfgh = val & inh_avail_mask;
+ env->minstretcfg = deposit64(env->minstretcfg, 32, 32,
+ val & inh_avail_mask);
return RISCV_EXCP_NONE;
}
if (counter_idx == 0) {
cfg_val = env->mcyclecfg;
} else if (counter_idx == 2) {
- cfg_val = upper_half ? ((uint64_t)env->minstretcfgh << 32) :
- env->minstretcfg;
+ cfg_val = env->minstretcfg;
} else {
cfg_val = env->mhpmevent_val[counter_idx];
cfg_val &= MHPMEVENT_FILTER_MASK;
}
break;
case 2: /* INSTRETCFGH */
+ cfgh = extract64(env->minstretcfg, 32, 32);
if (wr_mask) {
wr_mask &= ~MINSTRETCFGH_BIT_MINH;
- env->minstretcfgh = (new_val & wr_mask) |
- (env->minstretcfgh & ~wr_mask);
+ cfgh = (new_val & wr_mask) | (cfgh & ~wr_mask);
+ env->minstretcfg = deposit64(env->minstretcfg, 32, 32, cfgh);
} else {
- *val = env->minstretcfgh;
+ *val = cfgh;
}
break;
default: