mirror of https://github.com/xemu-project/xemu.git
RISC-V: Add priv_ver to DisasContext
The gen methods should access state from DisasContext. Add priv_ver field to the DisasContext struct. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
parent
fb73883964
commit
d75377bf7b
|
@ -43,6 +43,7 @@ typedef struct DisasContext {
|
||||||
DisasContextBase base;
|
DisasContextBase base;
|
||||||
/* pc_succ_insn points to the instruction following base.pc_next */
|
/* pc_succ_insn points to the instruction following base.pc_next */
|
||||||
target_ulong pc_succ_insn;
|
target_ulong pc_succ_insn;
|
||||||
|
target_ulong priv_ver;
|
||||||
uint32_t opcode;
|
uint32_t opcode;
|
||||||
uint32_t mstatus_fs;
|
uint32_t mstatus_fs;
|
||||||
uint32_t mem_idx;
|
uint32_t mem_idx;
|
||||||
|
@ -1330,7 +1331,7 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
/* Extract funct7 value and check whether it matches SFENCE.VMA */
|
/* Extract funct7 value and check whether it matches SFENCE.VMA */
|
||||||
if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) {
|
if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) {
|
||||||
if (env->priv_ver == PRIV_VERSION_1_10_0) {
|
if (ctx->priv_ver == PRIV_VERSION_1_10_0) {
|
||||||
/* sfence.vma */
|
/* sfence.vma */
|
||||||
/* TODO: handle ASID specific fences */
|
/* TODO: handle ASID specific fences */
|
||||||
gen_helper_tlb_flush(cpu_env);
|
gen_helper_tlb_flush(cpu_env);
|
||||||
|
@ -1384,7 +1385,7 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
|
||||||
gen_helper_wfi(cpu_env);
|
gen_helper_wfi(cpu_env);
|
||||||
break;
|
break;
|
||||||
case 0x104: /* SFENCE.VM */
|
case 0x104: /* SFENCE.VM */
|
||||||
if (env->priv_ver <= PRIV_VERSION_1_09_1) {
|
if (ctx->priv_ver <= PRIV_VERSION_1_09_1) {
|
||||||
gen_helper_tlb_flush(cpu_env);
|
gen_helper_tlb_flush(cpu_env);
|
||||||
} else {
|
} else {
|
||||||
gen_exception_illegal(ctx);
|
gen_exception_illegal(ctx);
|
||||||
|
@ -1854,10 +1855,12 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx)
|
||||||
static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
||||||
{
|
{
|
||||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||||
|
CPURISCVState *env = cs->env_ptr;
|
||||||
|
|
||||||
ctx->pc_succ_insn = ctx->base.pc_first;
|
ctx->pc_succ_insn = ctx->base.pc_first;
|
||||||
ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK;
|
ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK;
|
||||||
ctx->mstatus_fs = ctx->base.tb->flags & TB_FLAGS_MSTATUS_FS;
|
ctx->mstatus_fs = ctx->base.tb->flags & TB_FLAGS_MSTATUS_FS;
|
||||||
|
ctx->priv_ver = env->priv_ver;
|
||||||
ctx->frm = -1; /* unknown rounding mode */
|
ctx->frm = -1; /* unknown rounding mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue