target-mips: fix save_cpu_state() calls

The rule is:
- don't save PC if the exception is only triggered by softmmu.
- save PC if the exception can be triggered by an helper.

Fix a 64-bit kernel crash when loading modules.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Aurelien Jarno 2011-01-17 19:29:34 +01:00
parent 0bfe006c53
commit b835e919f0
1 changed files with 6 additions and 6 deletions

View File

@ -1066,7 +1066,7 @@ static void gen_ld (CPUState *env, DisasContext *ctx, uint32_t opc,
opn = "ld"; opn = "ld";
break; break;
case OPC_LLD: case OPC_LLD:
save_cpu_state(ctx, 0); save_cpu_state(ctx, 1);
op_ld_lld(t0, t0, ctx); op_ld_lld(t0, t0, ctx);
gen_store_gpr(t0, rt); gen_store_gpr(t0, rt);
opn = "lld"; opn = "lld";
@ -1086,7 +1086,7 @@ static void gen_ld (CPUState *env, DisasContext *ctx, uint32_t opc,
opn = "ldr"; opn = "ldr";
break; break;
case OPC_LDPC: case OPC_LDPC:
save_cpu_state(ctx, 1); save_cpu_state(ctx, 0);
tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); tcg_gen_movi_tl(t1, pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1); gen_op_addr_add(ctx, t0, t0, t1);
op_ld_ld(t0, t0, ctx); op_ld_ld(t0, t0, ctx);
@ -1095,7 +1095,7 @@ static void gen_ld (CPUState *env, DisasContext *ctx, uint32_t opc,
break; break;
#endif #endif
case OPC_LWPC: case OPC_LWPC:
save_cpu_state(ctx, 1); save_cpu_state(ctx, 0);
tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); tcg_gen_movi_tl(t1, pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1); gen_op_addr_add(ctx, t0, t0, t1);
op_ld_lw(t0, t0, ctx); op_ld_lw(t0, t0, ctx);
@ -1238,7 +1238,7 @@ static void gen_st_cond (DisasContext *ctx, uint32_t opc, int rt,
switch (opc) { switch (opc) {
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
case OPC_SCD: case OPC_SCD:
save_cpu_state(ctx, 0); save_cpu_state(ctx, 1);
op_st_scd(t1, t0, rt, ctx); op_st_scd(t1, t0, rt, ctx);
opn = "scd"; opn = "scd";
break; break;
@ -9971,7 +9971,7 @@ static void gen_ldst_pair (DisasContext *ctx, uint32_t opc, int rd,
opn = "lwp"; opn = "lwp";
break; break;
case SWP: case SWP:
save_cpu_state(ctx, 1); save_cpu_state(ctx, 0);
gen_load_gpr(t1, rd); gen_load_gpr(t1, rd);
op_st_sw(t1, t0, ctx); op_st_sw(t1, t0, ctx);
tcg_gen_movi_tl(t1, 4); tcg_gen_movi_tl(t1, 4);
@ -9992,7 +9992,7 @@ static void gen_ldst_pair (DisasContext *ctx, uint32_t opc, int rd,
opn = "ldp"; opn = "ldp";
break; break;
case SDP: case SDP:
save_cpu_state(ctx, 1); save_cpu_state(ctx, 0);
gen_load_gpr(t1, rd); gen_load_gpr(t1, rd);
op_st_sd(t1, t0, ctx); op_st_sd(t1, t0, ctx);
tcg_gen_movi_tl(t1, 8); tcg_gen_movi_tl(t1, 8);