mirror of https://github.com/xemu-project/xemu.git
target/riscv: Convert env->virt to a bool env->virt_enabled
Currently we only use the env->virt to encode the virtual mode enabled status. Let's make it a bool type. Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn> Message-ID: <20230325145348.1208-1-zhiwei_liu@linux.alibaba.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230327080858.39703-6-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
c43732f505
commit
b3c5077bef
|
@ -185,7 +185,7 @@ struct CPUArchState {
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
target_ulong priv;
|
target_ulong priv;
|
||||||
/* This contains QEMU specific information about the virt state. */
|
/* This contains QEMU specific information about the virt state. */
|
||||||
target_ulong virt;
|
bool virt_enabled;
|
||||||
target_ulong geilen;
|
target_ulong geilen;
|
||||||
uint64_t resetvec;
|
uint64_t resetvec;
|
||||||
|
|
||||||
|
|
|
@ -611,9 +611,6 @@ typedef enum {
|
||||||
#define PRV_H 2 /* Reserved */
|
#define PRV_H 2 /* Reserved */
|
||||||
#define PRV_M 3
|
#define PRV_M 3
|
||||||
|
|
||||||
/* Virtulisation Register Fields */
|
|
||||||
#define VIRT_ONOFF 1
|
|
||||||
|
|
||||||
/* RV32 satp CSR field masks */
|
/* RV32 satp CSR field masks */
|
||||||
#define SATP32_MODE 0x80000000
|
#define SATP32_MODE 0x80000000
|
||||||
#define SATP32_ASID 0x7fc00000
|
#define SATP32_ASID 0x7fc00000
|
||||||
|
|
|
@ -560,18 +560,18 @@ void riscv_cpu_set_geilen(CPURISCVState *env, target_ulong geilen)
|
||||||
|
|
||||||
bool riscv_cpu_virt_enabled(CPURISCVState *env)
|
bool riscv_cpu_virt_enabled(CPURISCVState *env)
|
||||||
{
|
{
|
||||||
return get_field(env->virt, VIRT_ONOFF);
|
return env->virt_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function can only be called to set virt when RVH is enabled */
|
/* This function can only be called to set virt when RVH is enabled */
|
||||||
void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable)
|
void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable)
|
||||||
{
|
{
|
||||||
/* Flush the TLB on all virt mode changes. */
|
/* Flush the TLB on all virt mode changes. */
|
||||||
if (get_field(env->virt, VIRT_ONOFF) != enable) {
|
if (env->virt_enabled != enable) {
|
||||||
tlb_flush(env_cpu(env));
|
tlb_flush(env_cpu(env));
|
||||||
}
|
}
|
||||||
|
|
||||||
env->virt = set_field(env->virt, VIRT_ONOFF, enable);
|
env->virt_enabled = enable;
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -349,8 +349,8 @@ static const VMStateDescription vmstate_jvt = {
|
||||||
|
|
||||||
const VMStateDescription vmstate_riscv_cpu = {
|
const VMStateDescription vmstate_riscv_cpu = {
|
||||||
.name = "cpu",
|
.name = "cpu",
|
||||||
.version_id = 7,
|
.version_id = 8,
|
||||||
.minimum_version_id = 7,
|
.minimum_version_id = 8,
|
||||||
.post_load = riscv_cpu_post_load,
|
.post_load = riscv_cpu_post_load,
|
||||||
.fields = (VMStateField[]) {
|
.fields = (VMStateField[]) {
|
||||||
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
|
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
|
||||||
|
@ -370,7 +370,7 @@ const VMStateDescription vmstate_riscv_cpu = {
|
||||||
VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU),
|
VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU),
|
||||||
VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU),
|
VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU),
|
||||||
VMSTATE_UINTTL(env.priv, RISCVCPU),
|
VMSTATE_UINTTL(env.priv, RISCVCPU),
|
||||||
VMSTATE_UINTTL(env.virt, RISCVCPU),
|
VMSTATE_BOOL(env.virt_enabled, RISCVCPU),
|
||||||
VMSTATE_UINT64(env.resetvec, RISCVCPU),
|
VMSTATE_UINT64(env.resetvec, RISCVCPU),
|
||||||
VMSTATE_UINTTL(env.mhartid, RISCVCPU),
|
VMSTATE_UINTTL(env.mhartid, RISCVCPU),
|
||||||
VMSTATE_UINT64(env.mstatus, RISCVCPU),
|
VMSTATE_UINT64(env.mstatus, RISCVCPU),
|
||||||
|
|
|
@ -1266,8 +1266,8 @@ static void riscv_tr_disas_log(const DisasContextBase *dcbase,
|
||||||
|
|
||||||
fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first));
|
fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first));
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
fprintf(logfile, "Priv: "TARGET_FMT_ld"; Virt: "TARGET_FMT_ld"\n",
|
fprintf(logfile, "Priv: "TARGET_FMT_ld"; Virt: %d\n",
|
||||||
env->priv, env->virt);
|
env->priv, env->virt_enabled);
|
||||||
#endif
|
#endif
|
||||||
target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size);
|
target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue