target-mips: fix updating XContext on mmu exception
PATCH v2 1/1 target-mips: fix updating XContext on mmu exception
Correct updating XContext.Region field on mmu exceptions. If Config3.CTXTC = 0 then the R field of XContext has to be updated with the value of bits 63..62 of the virtual address upon a TLB exception.
Also fixed the below line which overs 80 characters.
--- target-mips/helper.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
target-mips/helper.c +7 -3
@@ -293,9 +293,13 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, (env->CP0_EntryHi &0xFF ) | (address & (TARGET_PAGE_MASK <<1 ));#if defined(TARGET_MIPS64 ) env->CP0_EntryHi &= env->SEGMask; - env->CP0_XContext = (env->CP0_XContext & ((~0ULL ) << (env->SEGBITS -7 ))) | - ((address &0xC00000000000ULL ) >> (55 - env->SEGBITS)) | - ((address & ((1ULL << env->SEGBITS) -1 ) &0xFFFFFFFFFFFFE000ULL ) >>9 ); + env->CP0_XContext = +/* PTEBase */ + (env->CP0_XContext & ((~0ULL ) << (env->SEGBITS -7 ))) | +/* R */ + (extract64 (address,62 ,2 ) << (env->SEGBITS -9 )) | +/* BadVPN2 */ + (extract64 (address,13 , env->SEGBITS -14 ) <<4 );#endif cs->exception_index = exception; env->error_code = error_code;
Signature · 1 line
1.7.1
PATCH v2 1/1 target-mips: add PC, XNP reg numbers to RDHWR
Add Performance Counter (4) and XNP (5) register numbers to RDHWR. Add check_hwrena() to simplify access control checkings. Add RDHWR support to microMIPS R6.
--- target-mips/cpu.h | 1 + target-mips/helper.h | 2 + target-mips/op_helper.c | 64 +++++++++++++++++++++++++--------------------- target-mips/translate.c | 28 ++++++++++++++++++-- 4 files changed, 63 insertions(+), 32 deletions(-)
target-mips/cpu.h +1 -0
@@ -469,6 +469,7 @@ struct CPUMIPSState {#define CP0C5_CV 29#define CP0C5_EVA 28#define CP0C5_MSAEn 27 +#define CP0C5_XNP 13#define CP0C5_UFE 9#define CP0C5_FRE 8#define CP0C5_SBRI 6
target-mips/helper.h +2 -0
@@ -358,6 +358,8 @@ DEF_HELPER_1(rdhwr_cpunum, tl, env) DEF_HELPER_1(rdhwr_synci_step, tl, env) DEF_HELPER_1(rdhwr_cc, tl, env) DEF_HELPER_1(rdhwr_ccres, tl, env) +DEF_HELPER_1(rdhwr_performance, tl, env) +DEF_HELPER_1(rdhwr_xnp, tl, env) DEF_HELPER_2(pmon, void, env, int)DEF_HELPER_1 (wait, void, env)
target-mips/op_helper.c +35 -29
94 lines not on this page · raw message
target-mips/translate.c +25 -3
@@ -10334,7 +10334,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, } } -static void gen_rdhwr (DisasContext *ctx,int rt,int rd) +static void gen_rdhwr (DisasContext *ctx,int rt,int rd,int sel) {TCGv t0;
@@ -10362,6 +10362,22 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd)gen_helper_rdhwr_ccres (t0, cpu_env);gen_store_gpr (t0, rt);break ; +case 4 : +check_insn (ctx,ISA_MIPS32R6 ); +if (sel !=0 ) { +/* Performance counter registers are not implemented other than +* control register 0. +*/ +generate_exception (ctx,EXCP_RI ); + } +gen_helper_rdhwr_performance (t0, cpu_env); +gen_store_gpr (t0, rt); +break ; +case 5 : +check_insn (ctx,ISA_MIPS32R6 ); +gen_helper_rdhwr_xnp (t0, cpu_env); +gen_store_gpr (t0, rt); +break ;case 29 :#if defined(CONFIG_USER_ONLY ) tcg_gen_ld_tl(t0, cpu_env,
@@ -11980,6 +11996,7 @@ enum {ROTR =0x3 ,SELEQZ =0x5 ,SELNEZ =0x6 , +R6_RDHWR =0x7 ,SLLV =0x0 , SRLV = 0x1,
@@ -12934,7 +12951,8 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)gen_cl (ctx, mips32_op, rt, rs);break ;case RDHWR : -gen_rdhwr (ctx, rt, rs); +check_insn_opc_removed (ctx,ISA_MIPS32R6 ); +gen_rdhwr (ctx, rt, rs,0 );break ;case WSBH :gen_bshfl (ctx,OPC_WSBH , rs, rt);
@@ -13489,6 +13507,10 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)check_insn (ctx,ISA_MIPS32R6 );gen_cond_move (ctx,OPC_SELNEZ , rd, rs, rt);break ; +case R6_RDHWR : +check_insn (ctx,ISA_MIPS32R6 ); +gen_rdhwr (ctx, rt, rs,extract32 (ctx->opcode,11 ,3 )); +break ;default : goto pool32a_invalid; }
@@ -17739,7 +17761,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)break ;#endif case OPC_RDHWR : -gen_rdhwr (ctx, rt, rd); +gen_rdhwr (ctx, rt, rd,extract32 (ctx->opcode,6 ,3 ));break ;case OPC_FORK :check_insn (ctx,ASE_MT );
Signature · 1 line
1.7.1
PATCH v2 1/1 target-mips: add SIGRIE instruction
In reply to Yongbok KimAdd SIGRIE (Signal Reserved Instruction Exception) for both MIPS and microMIPS.
The instruction allows to use the 16-bit code field for software use. This instruction is introduced by and required as of Release 6.
--- target-mips/translate.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
target-mips/translate.c +11 -1
@@ -323,6 +323,7 @@ enum {OPC_TLTIU = (0x0B <<16 ) |OPC_REGIMM ,OPC_TEQI = (0x0C <<16 ) |OPC_REGIMM ,OPC_TNEI = (0x0E <<16 ) |OPC_REGIMM , +OPC_SIGRIE = (0x17 <<16 ) |OPC_REGIMM ,OPC_SYNCI = (0x1F <<16 ) |OPC_REGIMM , OPC_DAHI = (0x06 << 16) | OPC_REGIMM,
@@ -12014,7 +12015,8 @@ enum {LSA =0x0f ,ALIGN =0x1f ,EXT =0x2c , - POOL32AXF = 0x3c +POOL32AXF =0x3c , + SIGRIE = 0x3f };/* POOL32AXF encoding of minor opcode field extension */
@@ -13633,6 +13635,10 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)case BREAK32 :generate_exception_end (ctx,EXCP_BREAK );break ; +case SIGRIE : +check_insn (ctx,ISA_MIPS32R6 ); +generate_exception_end (ctx,EXCP_RI ); +break ;default : pool32a_invalid:MIPS_INVAL ("pool32a" );
@@ -18951,6 +18957,10 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)check_insn_opc_removed (ctx,ISA_MIPS32R6 );gen_trap (ctx, op1, rs,-1 , imm);break ; +case OPC_SIGRIE : +check_insn (ctx,ISA_MIPS32R6 ); +generate_exception_end (ctx,EXCP_RI ); +break ;case OPC_SYNCI :check_insn (ctx,ISA_MIPS32R2 );/* Break the TB to be able to sync copied instructions
Signature · 1 line
1.7.1