Commit f24e5695e5fab2d4d143c34ffe8164ddeac9b12b
1 parent
7668a27f
avoid generating useless exceptions (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1656 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
26 additions
and
11 deletions
target-ppc/translate.c
... | ... | @@ -177,17 +177,16 @@ RET_EXCP((ctx), EXCP_PROGRAM, EXCP_INVAL | EXCP_PRIV_OPC) |
177 | 177 | #define RET_PRIVREG(ctx) \ |
178 | 178 | RET_EXCP((ctx), EXCP_PROGRAM, EXCP_INVAL | EXCP_PRIV_REG) |
179 | 179 | |
180 | -#define RET_MTMSR(ctx) \ | |
181 | -RET_EXCP((ctx), EXCP_MTMSR, 0) | |
182 | - | |
180 | +/* Stop translation */ | |
183 | 181 | static inline void RET_STOP (DisasContext *ctx) |
184 | 182 | { |
185 | - RET_EXCP(ctx, EXCP_MTMSR, 0); | |
183 | + gen_op_update_nip((ctx)->nip); | |
184 | + ctx->exception = EXCP_MTMSR; | |
186 | 185 | } |
187 | 186 | |
187 | +/* No need to update nip here, as execution flow will change */ | |
188 | 188 | static inline void RET_CHG_FLOW (DisasContext *ctx) |
189 | 189 | { |
190 | - gen_op_raise_exception_err(EXCP_MTMSR, 0); | |
191 | 190 | ctx->exception = EXCP_MTMSR; |
192 | 191 | } |
193 | 192 | |
... | ... | @@ -2051,11 +2050,19 @@ static inline void gen_op_mfspr (DisasContext *ctx) |
2051 | 2050 | gen_op_store_T0_gpr(rD(ctx->opcode)); |
2052 | 2051 | } else { |
2053 | 2052 | /* Privilege exception */ |
2053 | + if (loglevel) { | |
2054 | + fprintf(logfile, "Trying to read priviledged spr %d %03x\n", | |
2055 | + sprn, sprn); | |
2056 | + } | |
2054 | 2057 | printf("Trying to read priviledged spr %d %03x\n", sprn, sprn); |
2055 | 2058 | RET_PRIVREG(ctx); |
2056 | 2059 | } |
2057 | 2060 | } else { |
2058 | 2061 | /* Not defined */ |
2062 | + if (loglevel) { | |
2063 | + fprintf(logfile, "Trying to read invalid spr %d %03x\n", | |
2064 | + sprn, sprn); | |
2065 | + } | |
2059 | 2066 | printf("Trying to read invalid spr %d %03x\n", sprn, sprn); |
2060 | 2067 | RET_EXCP(ctx, EXCP_PROGRAM, EXCP_INVAL | EXCP_INVAL_SPR); |
2061 | 2068 | } |
... | ... | @@ -2093,7 +2100,7 @@ GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001FF801, PPC_MISC) |
2093 | 2100 | gen_op_load_gpr_T0(rS(ctx->opcode)); |
2094 | 2101 | gen_op_store_msr(); |
2095 | 2102 | /* Must stop the translation as machine state (may have) changed */ |
2096 | - RET_MTMSR(ctx); | |
2103 | + RET_STOP(ctx); | |
2097 | 2104 | #endif |
2098 | 2105 | } |
2099 | 2106 | |
... | ... | @@ -2115,11 +2122,19 @@ GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000001, PPC_MISC) |
2115 | 2122 | (*write_cb)(ctx, sprn); |
2116 | 2123 | } else { |
2117 | 2124 | /* Privilege exception */ |
2125 | + if (loglevel) { | |
2126 | + fprintf(logfile, "Trying to write priviledged spr %d %03x\n", | |
2127 | + sprn, sprn); | |
2128 | + } | |
2118 | 2129 | printf("Trying to write priviledged spr %d %03x\n", sprn, sprn); |
2119 | 2130 | RET_PRIVREG(ctx); |
2120 | 2131 | } |
2121 | 2132 | } else { |
2122 | 2133 | /* Not defined */ |
2134 | + if (loglevel) { | |
2135 | + fprintf(logfile, "Trying to write invalid spr %d %03x\n", | |
2136 | + sprn, sprn); | |
2137 | + } | |
2123 | 2138 | printf("Trying to write invalid spr %d %03x\n", sprn, sprn); |
2124 | 2139 | RET_EXCP(ctx, EXCP_PROGRAM, EXCP_INVAL | EXCP_INVAL_SPR); |
2125 | 2140 | } |
... | ... | @@ -2278,7 +2293,7 @@ GEN_HANDLER(mtsr, 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT) |
2278 | 2293 | } |
2279 | 2294 | gen_op_load_gpr_T0(rS(ctx->opcode)); |
2280 | 2295 | gen_op_store_sr(SR(ctx->opcode)); |
2281 | - RET_MTMSR(ctx); | |
2296 | + RET_STOP(ctx); | |
2282 | 2297 | #endif |
2283 | 2298 | } |
2284 | 2299 | |
... | ... | @@ -2295,7 +2310,7 @@ GEN_HANDLER(mtsrin, 0x1F, 0x12, 0x07, 0x001F0001, PPC_SEGMENT) |
2295 | 2310 | gen_op_load_gpr_T0(rS(ctx->opcode)); |
2296 | 2311 | gen_op_load_gpr_T1(rB(ctx->opcode)); |
2297 | 2312 | gen_op_store_srin(); |
2298 | - RET_MTMSR(ctx); | |
2313 | + RET_STOP(ctx); | |
2299 | 2314 | #endif |
2300 | 2315 | } |
2301 | 2316 | |
... | ... | @@ -2314,7 +2329,7 @@ GEN_HANDLER(tlbia, 0x1F, 0x12, 0x0B, 0x03FFFC01, PPC_MEM_TLBIA) |
2314 | 2329 | return; |
2315 | 2330 | } |
2316 | 2331 | gen_op_tlbia(); |
2317 | - RET_MTMSR(ctx); | |
2332 | + RET_STOP(ctx); | |
2318 | 2333 | #endif |
2319 | 2334 | } |
2320 | 2335 | |
... | ... | @@ -2330,7 +2345,7 @@ GEN_HANDLER(tlbie, 0x1F, 0x12, 0x09, 0x03FF0001, PPC_MEM) |
2330 | 2345 | } |
2331 | 2346 | gen_op_load_gpr_T0(rB(ctx->opcode)); |
2332 | 2347 | gen_op_tlbie(); |
2333 | - RET_MTMSR(ctx); | |
2348 | + RET_STOP(ctx); | |
2334 | 2349 | #endif |
2335 | 2350 | } |
2336 | 2351 | |
... | ... | @@ -2347,7 +2362,7 @@ GEN_HANDLER(tlbsync, 0x1F, 0x16, 0x11, 0x03FFF801, PPC_MEM) |
2347 | 2362 | /* This has no effect: it should ensure that all previous |
2348 | 2363 | * tlbie have completed |
2349 | 2364 | */ |
2350 | - RET_MTMSR(ctx); | |
2365 | + RET_STOP(ctx); | |
2351 | 2366 | #endif |
2352 | 2367 | } |
2353 | 2368 | ... | ... |