target/riscv: generate virtual instruction exception

This patch adds a mechanism to generate a virtual instruction
instruction exception instead of an illegal instruction exception
during instruction decode when virt is enabled.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20221016124726.102129-4-mchitale@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
Mayuresh Chitale 2022-10-16 18:17:24 +05:30 committed by Alistair Francis
parent 252b06f638
commit fb3f3730e4
1 changed files with 7 additions and 1 deletions
target/riscv

View File

@ -76,6 +76,7 @@ typedef struct DisasContext {
to reset this known value. */ to reset this known value. */
int frm; int frm;
RISCVMXL ol; RISCVMXL ol;
bool virt_inst_excp;
bool virt_enabled; bool virt_enabled;
const RISCVCPUConfig *cfg_ptr; const RISCVCPUConfig *cfg_ptr;
bool hlsx; bool hlsx;
@ -243,7 +244,11 @@ static void gen_exception_illegal(DisasContext *ctx)
{ {
tcg_gen_st_i32(tcg_constant_i32(ctx->opcode), cpu_env, tcg_gen_st_i32(tcg_constant_i32(ctx->opcode), cpu_env,
offsetof(CPURISCVState, bins)); offsetof(CPURISCVState, bins));
generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST); if (ctx->virt_inst_excp) {
generate_exception(ctx, RISCV_EXCP_VIRT_INSTRUCTION_FAULT);
} else {
generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST);
}
} }
static void gen_exception_inst_addr_mis(DisasContext *ctx) static void gen_exception_inst_addr_mis(DisasContext *ctx)
@ -1062,6 +1067,7 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
{ has_XVentanaCondOps_p, decode_XVentanaCodeOps }, { has_XVentanaCondOps_p, decode_XVentanaCodeOps },
}; };
ctx->virt_inst_excp = false;
/* Check for compressed insn */ /* Check for compressed insn */
if (insn_len(opcode) == 2) { if (insn_len(opcode) == 2) {
if (!has_ext(ctx, RVC)) { if (!has_ext(ctx, RVC)) {