Commit 2e15497c authored by Eric Johnson's avatar Eric Johnson Committed by Aurelien Jarno
Browse files

target-mips: add privilege level check to several Cop0 instructions



The MIPS Architecture Verification Programs (AVPs) check privileged
instructions for the required privilege level.  These changes are needed
to pass the AVP suite.
Signed-off-by: default avatarEric Johnson <ericj@mips.com>
Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
parent 08406b03
...@@ -5933,6 +5933,7 @@ static void gen_cp0 (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, int rt, ...@@ -5933,6 +5933,7 @@ static void gen_cp0 (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, int rt,
{ {
const char *opn = "ldst"; const char *opn = "ldst";
check_cp0_enabled(ctx);
switch (opc) { switch (opc) {
case OPC_MFC0: case OPC_MFC0:
if (rt == 0) { if (rt == 0) {
...@@ -10121,6 +10122,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, ...@@ -10121,6 +10122,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs,
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
case MFC0: case MFC0:
case MFC0 + 32: case MFC0 + 32:
check_cp0_enabled(ctx);
if (rt == 0) { if (rt == 0) {
/* Treat as NOP. */ /* Treat as NOP. */
break; break;
...@@ -10129,6 +10131,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, ...@@ -10129,6 +10131,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs,
break; break;
case MTC0: case MTC0:
case MTC0 + 32: case MTC0 + 32:
check_cp0_enabled(ctx);
{ {
TCGv t0 = tcg_temp_new(); TCGv t0 = tcg_temp_new();
...@@ -10225,10 +10228,12 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, ...@@ -10225,10 +10228,12 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs,
case 0x05: case 0x05:
switch (minor) { switch (minor) {
case RDPGPR: case RDPGPR:
check_cp0_enabled(ctx);
check_insn(env, ctx, ISA_MIPS32R2); check_insn(env, ctx, ISA_MIPS32R2);
gen_load_srsgpr(rt, rs); gen_load_srsgpr(rt, rs);
break; break;
case WRPGPR: case WRPGPR:
check_cp0_enabled(ctx);
check_insn(env, ctx, ISA_MIPS32R2); check_insn(env, ctx, ISA_MIPS32R2);
gen_store_srsgpr(rt, rs); gen_store_srsgpr(rt, rs);
break; break;
...@@ -10269,6 +10274,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, ...@@ -10269,6 +10274,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs,
case 0x1d: case 0x1d:
switch (minor) { switch (minor) {
case DI: case DI:
check_cp0_enabled(ctx);
{ {
TCGv t0 = tcg_temp_new(); TCGv t0 = tcg_temp_new();
...@@ -10281,6 +10287,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, ...@@ -10281,6 +10287,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs,
} }
break; break;
case EI: case EI:
check_cp0_enabled(ctx);
{ {
TCGv t0 = tcg_temp_new(); TCGv t0 = tcg_temp_new();
...@@ -10761,6 +10768,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx, ...@@ -10761,6 +10768,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
minor = (ctx->opcode >> 12) & 0xf; minor = (ctx->opcode >> 12) & 0xf;
switch (minor) { switch (minor) {
case CACHE: case CACHE:
check_cp0_enabled(ctx);
/* Treat as no-op. */ /* Treat as no-op. */
break; break;
case LWC2: case LWC2:
...@@ -12211,6 +12219,7 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) ...@@ -12211,6 +12219,7 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
gen_st_cond(ctx, op, rt, rs, imm); gen_st_cond(ctx, op, rt, rs, imm);
break; break;
case OPC_CACHE: case OPC_CACHE:
check_cp0_enabled(ctx);
check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32);
/* Treat as NOP. */ /* Treat as NOP. */
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment