mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
target/riscv: Add MXL/SXL/UXL to TB_FLAGS
Begin adding support for switching XLEN at runtime. Extract the effective XLEN from MISA and MSTATUS and store for use during translation. Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20211020031709.359469-6-richard.henderson@linaro.org Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
db23e5d981
commit
92371bd903
5 changed files with 47 additions and 1 deletions
|
@ -35,6 +35,37 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
|
|||
#endif
|
||||
}
|
||||
|
||||
static RISCVMXL cpu_get_xl(CPURISCVState *env)
|
||||
{
|
||||
#if defined(TARGET_RISCV32)
|
||||
return MXL_RV32;
|
||||
#elif defined(CONFIG_USER_ONLY)
|
||||
return MXL_RV64;
|
||||
#else
|
||||
RISCVMXL xl = riscv_cpu_mxl(env);
|
||||
|
||||
/*
|
||||
* When emulating a 32-bit-only cpu, use RV32.
|
||||
* When emulating a 64-bit cpu, and MXL has been reduced to RV32,
|
||||
* MSTATUSH doesn't have UXL/SXL, therefore XLEN cannot be widened
|
||||
* back to RV64 for lower privs.
|
||||
*/
|
||||
if (xl != MXL_RV32) {
|
||||
switch (env->priv) {
|
||||
case PRV_M:
|
||||
break;
|
||||
case PRV_U:
|
||||
xl = get_field(env->mstatus, MSTATUS64_UXL);
|
||||
break;
|
||||
default: /* PRV_S | PRV_H */
|
||||
xl = get_field(env->mstatus, MSTATUS64_SXL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return xl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
|
||||
target_ulong *cs_base, uint32_t *pflags)
|
||||
{
|
||||
|
@ -78,6 +109,8 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
|
|||
}
|
||||
#endif
|
||||
|
||||
flags = FIELD_DP32(flags, TB_FLAGS, XL, cpu_get_xl(env));
|
||||
|
||||
*pflags = flags;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue