Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * PowerPC exception emulation helpers for QEMU. |
| 3 | * |
| 4 | * Copyright (c) 2003-2007 Jocelyn Mayer |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
Peter Maydell | 0d75590 | 2016-01-26 18:16:58 +0000 | [diff] [blame] | 19 | #include "qemu/osdep.h" |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 20 | #include "cpu.h" |
Richard Henderson | 2ef6175 | 2014-04-07 22:31:41 -0700 | [diff] [blame] | 21 | #include "exec/helper-proto.h" |
Paolo Bonzini | 63c9155 | 2016-03-15 13:18:37 +0100 | [diff] [blame] | 22 | #include "exec/exec-all.h" |
Paolo Bonzini | f08b617 | 2014-03-28 19:42:10 +0100 | [diff] [blame] | 23 | #include "exec/cpu_ldst.h" |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 24 | |
| 25 | #include "helper_regs.h" |
| 26 | |
| 27 | //#define DEBUG_OP |
Paolo Bonzini | 48880da | 2015-11-13 13:34:23 +0100 | [diff] [blame] | 28 | //#define DEBUG_SOFTWARE_TLB |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 29 | //#define DEBUG_EXCEPTIONS |
| 30 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 31 | #ifdef DEBUG_EXCEPTIONS |
| 32 | # define LOG_EXCP(...) qemu_log(__VA_ARGS__) |
| 33 | #else |
| 34 | # define LOG_EXCP(...) do { } while (0) |
| 35 | #endif |
| 36 | |
| 37 | /*****************************************************************************/ |
| 38 | /* PowerPC Hypercall emulation */ |
| 39 | |
Andreas Färber | 1b14670 | 2012-05-03 06:03:45 +0200 | [diff] [blame] | 40 | void (*cpu_ppc_hypercall)(PowerPCCPU *); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 41 | |
| 42 | /*****************************************************************************/ |
| 43 | /* Exception processing */ |
| 44 | #if defined(CONFIG_USER_ONLY) |
Andreas Färber | 97a8ea5 | 2013-02-02 10:57:51 +0100 | [diff] [blame] | 45 | void ppc_cpu_do_interrupt(CPUState *cs) |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 46 | { |
Andreas Färber | 97a8ea5 | 2013-02-02 10:57:51 +0100 | [diff] [blame] | 47 | PowerPCCPU *cpu = POWERPC_CPU(cs); |
| 48 | CPUPPCState *env = &cpu->env; |
| 49 | |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 50 | cs->exception_index = POWERPC_EXCP_NONE; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 51 | env->error_code = 0; |
| 52 | } |
| 53 | |
Richard Henderson | 458dd76 | 2014-09-13 09:45:32 -0700 | [diff] [blame] | 54 | static void ppc_hw_interrupt(CPUPPCState *env) |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 55 | { |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 56 | CPUState *cs = CPU(ppc_env_get_cpu(env)); |
| 57 | |
| 58 | cs->exception_index = POWERPC_EXCP_NONE; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 59 | env->error_code = 0; |
| 60 | } |
| 61 | #else /* defined(CONFIG_USER_ONLY) */ |
| 62 | static inline void dump_syscall(CPUPPCState *env) |
| 63 | { |
| 64 | qemu_log_mask(CPU_LOG_INT, "syscall r0=%016" PRIx64 " r3=%016" PRIx64 |
| 65 | " r4=%016" PRIx64 " r5=%016" PRIx64 " r6=%016" PRIx64 |
| 66 | " nip=" TARGET_FMT_lx "\n", |
| 67 | ppc_dump_gpr(env, 0), ppc_dump_gpr(env, 3), |
| 68 | ppc_dump_gpr(env, 4), ppc_dump_gpr(env, 5), |
| 69 | ppc_dump_gpr(env, 6), env->nip); |
| 70 | } |
| 71 | |
| 72 | /* Note that this function should be greatly optimized |
| 73 | * when called with a constant excp, from ppc_hw_interrupt |
| 74 | */ |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 75 | static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 76 | { |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 77 | CPUState *cs = CPU(cpu); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 78 | CPUPPCState *env = &cpu->env; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 79 | target_ulong msr, new_msr, vector; |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 80 | int srr0, srr1, asrr0, asrr1, lev, ail; |
| 81 | bool lpes0; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 82 | |
| 83 | qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx |
| 84 | " => %08x (%02x)\n", env->nip, excp, env->error_code); |
| 85 | |
| 86 | /* new srr1 value excluding must-be-zero bits */ |
Scott Wood | a1bb738 | 2012-12-21 16:15:41 +0000 | [diff] [blame] | 87 | if (excp_model == POWERPC_EXCP_BOOKE) { |
| 88 | msr = env->msr; |
| 89 | } else { |
| 90 | msr = env->msr & ~0x783f0000ULL; |
| 91 | } |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 92 | |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 93 | /* new interrupt handler msr preserves existing HV and ME unless |
| 94 | * explicitly overriden |
| 95 | */ |
| 96 | new_msr = env->msr & (((target_ulong)1 << MSR_ME) | MSR_HVB); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 97 | |
| 98 | /* target registers */ |
| 99 | srr0 = SPR_SRR0; |
| 100 | srr1 = SPR_SRR1; |
| 101 | asrr0 = -1; |
| 102 | asrr1 = -1; |
| 103 | |
Benjamin Herrenschmidt | 7778a57 | 2016-06-21 23:48:55 +0200 | [diff] [blame] | 104 | /* check for special resume at 0x100 from doze/nap/sleep/winkle on P7/P8 */ |
| 105 | if (env->in_pm_state) { |
| 106 | env->in_pm_state = false; |
| 107 | |
| 108 | /* Pretend to be returning from doze always as we don't lose state */ |
| 109 | msr |= (0x1ull << (63 - 47)); |
| 110 | |
| 111 | /* Non-machine check are routed to 0x100 with a wakeup cause |
| 112 | * encoded in SRR1 |
| 113 | */ |
| 114 | if (excp != POWERPC_EXCP_MCHECK) { |
| 115 | switch (excp) { |
| 116 | case POWERPC_EXCP_RESET: |
| 117 | msr |= 0x4ull << (63 - 45); |
| 118 | break; |
| 119 | case POWERPC_EXCP_EXTERNAL: |
| 120 | msr |= 0x8ull << (63 - 45); |
| 121 | break; |
| 122 | case POWERPC_EXCP_DECR: |
| 123 | msr |= 0x6ull << (63 - 45); |
| 124 | break; |
| 125 | case POWERPC_EXCP_SDOOR: |
| 126 | msr |= 0x5ull << (63 - 45); |
| 127 | break; |
| 128 | case POWERPC_EXCP_SDOOR_HV: |
| 129 | msr |= 0x3ull << (63 - 45); |
| 130 | break; |
| 131 | case POWERPC_EXCP_HV_MAINT: |
| 132 | msr |= 0xaull << (63 - 45); |
| 133 | break; |
| 134 | default: |
| 135 | cpu_abort(cs, "Unsupported exception %d in Power Save mode\n", |
| 136 | excp); |
| 137 | } |
| 138 | excp = POWERPC_EXCP_RESET; |
| 139 | } |
| 140 | } |
| 141 | |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 142 | /* Exception targetting modifiers |
| 143 | * |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 144 | * LPES0 is supported on POWER7/8 |
| 145 | * LPES1 is not supported (old iSeries mode) |
| 146 | * |
| 147 | * On anything else, we behave as if LPES0 is 1 |
| 148 | * (externals don't alter MSR:HV) |
| 149 | * |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 150 | * AIL is initialized here but can be cleared by |
| 151 | * selected exceptions |
| 152 | */ |
| 153 | #if defined(TARGET_PPC64) |
| 154 | if (excp_model == POWERPC_EXCP_POWER7 || |
| 155 | excp_model == POWERPC_EXCP_POWER8) { |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 156 | lpes0 = !!(env->spr[SPR_LPCR] & LPCR_LPES0); |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 157 | if (excp_model == POWERPC_EXCP_POWER8) { |
| 158 | ail = (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; |
| 159 | } else { |
| 160 | ail = 0; |
| 161 | } |
| 162 | } else |
| 163 | #endif /* defined(TARGET_PPC64) */ |
| 164 | { |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 165 | lpes0 = true; |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 166 | ail = 0; |
| 167 | } |
| 168 | |
Benjamin Herrenschmidt | 9b2fadd | 2016-06-21 23:48:51 +0200 | [diff] [blame] | 169 | /* Hypervisor emulation assistance interrupt only exists on server |
| 170 | * arch 2.05 server or later. We also don't want to generate it if |
| 171 | * we don't have HVB in msr_mask (PAPR mode). |
| 172 | */ |
| 173 | if (excp == POWERPC_EXCP_HV_EMU |
| 174 | #if defined(TARGET_PPC64) |
| 175 | && !((env->mmu_model & POWERPC_MMU_64) && (env->msr_mask & MSR_HVB)) |
| 176 | #endif /* defined(TARGET_PPC64) */ |
| 177 | |
| 178 | ) { |
| 179 | excp = POWERPC_EXCP_PROGRAM; |
| 180 | } |
| 181 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 182 | switch (excp) { |
| 183 | case POWERPC_EXCP_NONE: |
| 184 | /* Should never happen */ |
| 185 | return; |
| 186 | case POWERPC_EXCP_CRITICAL: /* Critical input */ |
| 187 | switch (excp_model) { |
| 188 | case POWERPC_EXCP_40x: |
| 189 | srr0 = SPR_40x_SRR2; |
| 190 | srr1 = SPR_40x_SRR3; |
| 191 | break; |
| 192 | case POWERPC_EXCP_BOOKE: |
| 193 | srr0 = SPR_BOOKE_CSRR0; |
| 194 | srr1 = SPR_BOOKE_CSRR1; |
| 195 | break; |
| 196 | case POWERPC_EXCP_G2: |
| 197 | break; |
| 198 | default: |
| 199 | goto excp_invalid; |
| 200 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 201 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 202 | case POWERPC_EXCP_MCHECK: /* Machine check exception */ |
| 203 | if (msr_me == 0) { |
| 204 | /* Machine check exception is not enabled. |
| 205 | * Enter checkstop state. |
| 206 | */ |
Paolo Bonzini | 013a294 | 2015-11-13 13:16:27 +0100 | [diff] [blame] | 207 | fprintf(stderr, "Machine check while not allowed. " |
| 208 | "Entering checkstop state\n"); |
| 209 | if (qemu_log_separate()) { |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 210 | qemu_log("Machine check while not allowed. " |
| 211 | "Entering checkstop state\n"); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 212 | } |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 213 | cs->halted = 1; |
| 214 | cs->interrupt_request |= CPU_INTERRUPT_EXITTB; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 215 | } |
Nicholas Piggin | 10c21b5 | 2016-10-27 23:50:58 +1100 | [diff] [blame] | 216 | if (env->msr_mask & MSR_HVB) { |
| 217 | /* ISA specifies HV, but can be delivered to guest with HV clear |
| 218 | * (e.g., see FWNMI in PAPR). |
| 219 | */ |
| 220 | new_msr |= (target_ulong)MSR_HVB; |
| 221 | } |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 222 | ail = 0; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 223 | |
| 224 | /* machine check exceptions don't have ME set */ |
| 225 | new_msr &= ~((target_ulong)1 << MSR_ME); |
| 226 | |
| 227 | /* XXX: should also have something loaded in DAR / DSISR */ |
| 228 | switch (excp_model) { |
| 229 | case POWERPC_EXCP_40x: |
| 230 | srr0 = SPR_40x_SRR2; |
| 231 | srr1 = SPR_40x_SRR3; |
| 232 | break; |
| 233 | case POWERPC_EXCP_BOOKE: |
Scott Wood | a1bb738 | 2012-12-21 16:15:41 +0000 | [diff] [blame] | 234 | /* FIXME: choose one or the other based on CPU type */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 235 | srr0 = SPR_BOOKE_MCSRR0; |
| 236 | srr1 = SPR_BOOKE_MCSRR1; |
| 237 | asrr0 = SPR_BOOKE_CSRR0; |
| 238 | asrr1 = SPR_BOOKE_CSRR1; |
| 239 | break; |
| 240 | default: |
| 241 | break; |
| 242 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 243 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 244 | case POWERPC_EXCP_DSI: /* Data storage exception */ |
| 245 | LOG_EXCP("DSI exception: DSISR=" TARGET_FMT_lx" DAR=" TARGET_FMT_lx |
| 246 | "\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 247 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 248 | case POWERPC_EXCP_ISI: /* Instruction storage exception */ |
| 249 | LOG_EXCP("ISI exception: msr=" TARGET_FMT_lx ", nip=" TARGET_FMT_lx |
| 250 | "\n", msr, env->nip); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 251 | msr |= env->error_code; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 252 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 253 | case POWERPC_EXCP_EXTERNAL: /* External input */ |
Edgar E. Iglesias | fdfba1a | 2013-11-15 14:46:38 +0100 | [diff] [blame] | 254 | cs = CPU(cpu); |
| 255 | |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 256 | if (!lpes0) { |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 257 | new_msr |= (target_ulong)MSR_HVB; |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 258 | new_msr |= env->msr & ((target_ulong)1 << MSR_RI); |
| 259 | srr0 = SPR_HSRR0; |
| 260 | srr1 = SPR_HSRR1; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 261 | } |
Alexander Graf | 68c2dd7 | 2013-01-04 11:21:04 +0100 | [diff] [blame] | 262 | if (env->mpic_proxy) { |
| 263 | /* IACK the IRQ on delivery */ |
Edgar E. Iglesias | fdfba1a | 2013-11-15 14:46:38 +0100 | [diff] [blame] | 264 | env->spr[SPR_BOOKE_EPR] = ldl_phys(cs->as, env->mpic_iack); |
Alexander Graf | 68c2dd7 | 2013-01-04 11:21:04 +0100 | [diff] [blame] | 265 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 266 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 267 | case POWERPC_EXCP_ALIGN: /* Alignment exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 268 | /* Get rS/rD and rA from faulting opcode */ |
Benjamin Herrenschmidt | 3433b73 | 2016-07-27 16:56:41 +1000 | [diff] [blame] | 269 | /* Note: the opcode fields will not be set properly for a direct |
| 270 | * store load/store, but nobody cares as nobody actually uses |
| 271 | * direct store segments. |
| 272 | */ |
| 273 | env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 274 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 275 | case POWERPC_EXCP_PROGRAM: /* Program exception */ |
| 276 | switch (env->error_code & ~0xF) { |
| 277 | case POWERPC_EXCP_FP: |
| 278 | if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) { |
| 279 | LOG_EXCP("Ignore floating point exception\n"); |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 280 | cs->exception_index = POWERPC_EXCP_NONE; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 281 | env->error_code = 0; |
| 282 | return; |
| 283 | } |
Benjamin Herrenschmidt | 1b7d17c | 2016-07-27 16:56:29 +1000 | [diff] [blame] | 284 | |
| 285 | /* FP exceptions always have NIP pointing to the faulting |
| 286 | * instruction, so always use store_next and claim we are |
| 287 | * precise in the MSR. |
| 288 | */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 289 | msr |= 0x00100000; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 290 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 291 | case POWERPC_EXCP_INVAL: |
| 292 | LOG_EXCP("Invalid instruction at " TARGET_FMT_lx "\n", env->nip); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 293 | msr |= 0x00080000; |
| 294 | env->spr[SPR_BOOKE_ESR] = ESR_PIL; |
| 295 | break; |
| 296 | case POWERPC_EXCP_PRIV: |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 297 | msr |= 0x00040000; |
| 298 | env->spr[SPR_BOOKE_ESR] = ESR_PPR; |
| 299 | break; |
| 300 | case POWERPC_EXCP_TRAP: |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 301 | msr |= 0x00020000; |
| 302 | env->spr[SPR_BOOKE_ESR] = ESR_PTR; |
| 303 | break; |
| 304 | default: |
| 305 | /* Should never occur */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 306 | cpu_abort(cs, "Invalid program exception %d. Aborting\n", |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 307 | env->error_code); |
| 308 | break; |
| 309 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 310 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 311 | case POWERPC_EXCP_SYSCALL: /* System call exception */ |
| 312 | dump_syscall(env); |
| 313 | lev = env->error_code; |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 314 | |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 315 | /* We need to correct the NIP which in this case is supposed |
| 316 | * to point to the next instruction |
| 317 | */ |
| 318 | env->nip += 4; |
| 319 | |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 320 | /* "PAPR mode" built-in hypercall emulation */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 321 | if ((lev == 1) && cpu_ppc_hypercall) { |
Andreas Färber | 1b14670 | 2012-05-03 06:03:45 +0200 | [diff] [blame] | 322 | cpu_ppc_hypercall(cpu); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 323 | return; |
| 324 | } |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 325 | if (lev == 1) { |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 326 | new_msr |= (target_ulong)MSR_HVB; |
| 327 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 328 | break; |
| 329 | case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 330 | case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 331 | case POWERPC_EXCP_DECR: /* Decrementer exception */ |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 332 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 333 | case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt */ |
| 334 | /* FIT on 4xx */ |
| 335 | LOG_EXCP("FIT exception\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 336 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 337 | case POWERPC_EXCP_WDT: /* Watchdog timer interrupt */ |
| 338 | LOG_EXCP("WDT exception\n"); |
| 339 | switch (excp_model) { |
| 340 | case POWERPC_EXCP_BOOKE: |
| 341 | srr0 = SPR_BOOKE_CSRR0; |
| 342 | srr1 = SPR_BOOKE_CSRR1; |
| 343 | break; |
| 344 | default: |
| 345 | break; |
| 346 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 347 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 348 | case POWERPC_EXCP_DTLB: /* Data TLB error */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 349 | case POWERPC_EXCP_ITLB: /* Instruction TLB error */ |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 350 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 351 | case POWERPC_EXCP_DEBUG: /* Debug interrupt */ |
| 352 | switch (excp_model) { |
| 353 | case POWERPC_EXCP_BOOKE: |
Scott Wood | a1bb738 | 2012-12-21 16:15:41 +0000 | [diff] [blame] | 354 | /* FIXME: choose one or the other based on CPU type */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 355 | srr0 = SPR_BOOKE_DSRR0; |
| 356 | srr1 = SPR_BOOKE_DSRR1; |
| 357 | asrr0 = SPR_BOOKE_CSRR0; |
| 358 | asrr1 = SPR_BOOKE_CSRR1; |
| 359 | break; |
| 360 | default: |
| 361 | break; |
| 362 | } |
| 363 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 364 | cpu_abort(cs, "Debug exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 365 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 366 | case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavailable */ |
| 367 | env->spr[SPR_BOOKE_ESR] = ESR_SPV; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 368 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 369 | case POWERPC_EXCP_EFPDI: /* Embedded floating-point data interrupt */ |
| 370 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 371 | cpu_abort(cs, "Embedded floating point data exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 372 | "is not implemented yet !\n"); |
| 373 | env->spr[SPR_BOOKE_ESR] = ESR_SPV; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 374 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 375 | case POWERPC_EXCP_EFPRI: /* Embedded floating-point round interrupt */ |
| 376 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 377 | cpu_abort(cs, "Embedded floating point round exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 378 | "is not implemented yet !\n"); |
| 379 | env->spr[SPR_BOOKE_ESR] = ESR_SPV; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 380 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 381 | case POWERPC_EXCP_EPERFM: /* Embedded performance monitor interrupt */ |
| 382 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 383 | cpu_abort(cs, |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 384 | "Performance counter exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 385 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 386 | case POWERPC_EXCP_DOORI: /* Embedded doorbell interrupt */ |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 387 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 388 | case POWERPC_EXCP_DOORCI: /* Embedded doorbell critical interrupt */ |
| 389 | srr0 = SPR_BOOKE_CSRR0; |
| 390 | srr1 = SPR_BOOKE_CSRR1; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 391 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 392 | case POWERPC_EXCP_RESET: /* System reset exception */ |
Nicholas Piggin | f85bcec | 2016-10-20 17:59:10 +1100 | [diff] [blame] | 393 | /* A power-saving exception sets ME, otherwise it is unchanged */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 394 | if (msr_pow) { |
| 395 | /* indicate that we resumed from power save mode */ |
| 396 | msr |= 0x10000; |
Nicholas Piggin | f85bcec | 2016-10-20 17:59:10 +1100 | [diff] [blame] | 397 | new_msr |= ((target_ulong)1 << MSR_ME); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 398 | } |
Nicholas Piggin | 10c21b5 | 2016-10-27 23:50:58 +1100 | [diff] [blame] | 399 | if (env->msr_mask & MSR_HVB) { |
| 400 | /* ISA specifies HV, but can be delivered to guest with HV clear |
| 401 | * (e.g., see FWNMI in PAPR, NMI injection in QEMU). |
| 402 | */ |
| 403 | new_msr |= (target_ulong)MSR_HVB; |
| 404 | } else { |
| 405 | if (msr_pow) { |
| 406 | cpu_abort(cs, "Trying to deliver power-saving system reset " |
| 407 | "exception %d with no HV support\n", excp); |
| 408 | } |
| 409 | } |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 410 | ail = 0; |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 411 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 412 | case POWERPC_EXCP_DSEG: /* Data segment exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 413 | case POWERPC_EXCP_ISEG: /* Instruction segment exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 414 | case POWERPC_EXCP_TRACE: /* Trace exception */ |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 415 | break; |
| 416 | case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 417 | case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 418 | case POWERPC_EXCP_HISI: /* Hypervisor instruction storage exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 419 | case POWERPC_EXCP_HDSEG: /* Hypervisor data segment exception */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 420 | case POWERPC_EXCP_HISEG: /* Hypervisor instruction segment exception */ |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 421 | case POWERPC_EXCP_HV_EMU: |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 422 | srr0 = SPR_HSRR0; |
| 423 | srr1 = SPR_HSRR1; |
| 424 | new_msr |= (target_ulong)MSR_HVB; |
| 425 | new_msr |= env->msr & ((target_ulong)1 << MSR_RI); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 426 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 427 | case POWERPC_EXCP_VPU: /* Vector unavailable exception */ |
Tom Musta | 1f29871 | 2013-10-22 22:06:17 +1100 | [diff] [blame] | 428 | case POWERPC_EXCP_VSXU: /* VSX unavailable exception */ |
Alexey Kardashevskiy | 7019cb3 | 2014-06-04 22:50:56 +1000 | [diff] [blame] | 429 | case POWERPC_EXCP_FU: /* Facility unavailable exception */ |
Balbir Singh | 5310799 | 2016-11-10 15:37:31 +1100 | [diff] [blame] | 430 | #ifdef TARGET_PPC64 |
| 431 | env->spr[SPR_FSCR] |= ((target_ulong)env->error_code << 56); |
| 432 | #endif |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 433 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 434 | case POWERPC_EXCP_PIT: /* Programmable interval timer interrupt */ |
| 435 | LOG_EXCP("PIT exception\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 436 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 437 | case POWERPC_EXCP_IO: /* IO error exception */ |
| 438 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 439 | cpu_abort(cs, "601 IO error exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 440 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 441 | case POWERPC_EXCP_RUNM: /* Run mode exception */ |
| 442 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 443 | cpu_abort(cs, "601 run mode exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 444 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 445 | case POWERPC_EXCP_EMUL: /* Emulation trap exception */ |
| 446 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 447 | cpu_abort(cs, "602 emulation trap exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 448 | "is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 449 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 450 | case POWERPC_EXCP_IFTLB: /* Instruction fetch TLB error */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 451 | switch (excp_model) { |
| 452 | case POWERPC_EXCP_602: |
| 453 | case POWERPC_EXCP_603: |
| 454 | case POWERPC_EXCP_603E: |
| 455 | case POWERPC_EXCP_G2: |
| 456 | goto tlb_miss_tgpr; |
| 457 | case POWERPC_EXCP_7x5: |
| 458 | goto tlb_miss; |
| 459 | case POWERPC_EXCP_74xx: |
| 460 | goto tlb_miss_74xx; |
| 461 | default: |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 462 | cpu_abort(cs, "Invalid instruction TLB miss exception\n"); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 463 | break; |
| 464 | } |
| 465 | break; |
| 466 | case POWERPC_EXCP_DLTLB: /* Data load TLB miss */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 467 | switch (excp_model) { |
| 468 | case POWERPC_EXCP_602: |
| 469 | case POWERPC_EXCP_603: |
| 470 | case POWERPC_EXCP_603E: |
| 471 | case POWERPC_EXCP_G2: |
| 472 | goto tlb_miss_tgpr; |
| 473 | case POWERPC_EXCP_7x5: |
| 474 | goto tlb_miss; |
| 475 | case POWERPC_EXCP_74xx: |
| 476 | goto tlb_miss_74xx; |
| 477 | default: |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 478 | cpu_abort(cs, "Invalid data load TLB miss exception\n"); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 479 | break; |
| 480 | } |
| 481 | break; |
| 482 | case POWERPC_EXCP_DSTLB: /* Data store TLB miss */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 483 | switch (excp_model) { |
| 484 | case POWERPC_EXCP_602: |
| 485 | case POWERPC_EXCP_603: |
| 486 | case POWERPC_EXCP_603E: |
| 487 | case POWERPC_EXCP_G2: |
| 488 | tlb_miss_tgpr: |
| 489 | /* Swap temporary saved registers with GPRs */ |
| 490 | if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) { |
| 491 | new_msr |= (target_ulong)1 << MSR_TGPR; |
| 492 | hreg_swap_gpr_tgpr(env); |
| 493 | } |
| 494 | goto tlb_miss; |
| 495 | case POWERPC_EXCP_7x5: |
| 496 | tlb_miss: |
| 497 | #if defined(DEBUG_SOFTWARE_TLB) |
| 498 | if (qemu_log_enabled()) { |
| 499 | const char *es; |
| 500 | target_ulong *miss, *cmp; |
| 501 | int en; |
| 502 | |
| 503 | if (excp == POWERPC_EXCP_IFTLB) { |
| 504 | es = "I"; |
| 505 | en = 'I'; |
| 506 | miss = &env->spr[SPR_IMISS]; |
| 507 | cmp = &env->spr[SPR_ICMP]; |
| 508 | } else { |
| 509 | if (excp == POWERPC_EXCP_DLTLB) { |
| 510 | es = "DL"; |
| 511 | } else { |
| 512 | es = "DS"; |
| 513 | } |
| 514 | en = 'D'; |
| 515 | miss = &env->spr[SPR_DMISS]; |
| 516 | cmp = &env->spr[SPR_DCMP]; |
| 517 | } |
| 518 | qemu_log("6xx %sTLB miss: %cM " TARGET_FMT_lx " %cC " |
| 519 | TARGET_FMT_lx " H1 " TARGET_FMT_lx " H2 " |
| 520 | TARGET_FMT_lx " %08x\n", es, en, *miss, en, *cmp, |
| 521 | env->spr[SPR_HASH1], env->spr[SPR_HASH2], |
| 522 | env->error_code); |
| 523 | } |
| 524 | #endif |
| 525 | msr |= env->crf[0] << 28; |
| 526 | msr |= env->error_code; /* key, D/I, S/L bits */ |
| 527 | /* Set way using a LRU mechanism */ |
| 528 | msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17; |
| 529 | break; |
| 530 | case POWERPC_EXCP_74xx: |
| 531 | tlb_miss_74xx: |
| 532 | #if defined(DEBUG_SOFTWARE_TLB) |
| 533 | if (qemu_log_enabled()) { |
| 534 | const char *es; |
| 535 | target_ulong *miss, *cmp; |
| 536 | int en; |
| 537 | |
| 538 | if (excp == POWERPC_EXCP_IFTLB) { |
| 539 | es = "I"; |
| 540 | en = 'I'; |
| 541 | miss = &env->spr[SPR_TLBMISS]; |
| 542 | cmp = &env->spr[SPR_PTEHI]; |
| 543 | } else { |
| 544 | if (excp == POWERPC_EXCP_DLTLB) { |
| 545 | es = "DL"; |
| 546 | } else { |
| 547 | es = "DS"; |
| 548 | } |
| 549 | en = 'D'; |
| 550 | miss = &env->spr[SPR_TLBMISS]; |
| 551 | cmp = &env->spr[SPR_PTEHI]; |
| 552 | } |
| 553 | qemu_log("74xx %sTLB miss: %cM " TARGET_FMT_lx " %cC " |
| 554 | TARGET_FMT_lx " %08x\n", es, en, *miss, en, *cmp, |
| 555 | env->error_code); |
| 556 | } |
| 557 | #endif |
| 558 | msr |= env->error_code; /* key bit */ |
| 559 | break; |
| 560 | default: |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 561 | cpu_abort(cs, "Invalid data store TLB miss exception\n"); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 562 | break; |
| 563 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 564 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 565 | case POWERPC_EXCP_FPA: /* Floating-point assist exception */ |
| 566 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 567 | cpu_abort(cs, "Floating point assist exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 568 | "is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 569 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 570 | case POWERPC_EXCP_DABR: /* Data address breakpoint */ |
| 571 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 572 | cpu_abort(cs, "DABR exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 573 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 574 | case POWERPC_EXCP_IABR: /* Instruction address breakpoint */ |
| 575 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 576 | cpu_abort(cs, "IABR exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 577 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 578 | case POWERPC_EXCP_SMI: /* System management interrupt */ |
| 579 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 580 | cpu_abort(cs, "SMI exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 581 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 582 | case POWERPC_EXCP_THERM: /* Thermal interrupt */ |
| 583 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 584 | cpu_abort(cs, "Thermal management exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 585 | "is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 586 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 587 | case POWERPC_EXCP_PERFM: /* Embedded performance monitor interrupt */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 588 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 589 | cpu_abort(cs, |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 590 | "Performance counter exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 591 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 592 | case POWERPC_EXCP_VPUA: /* Vector assist exception */ |
| 593 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 594 | cpu_abort(cs, "VPU assist exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 595 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 596 | case POWERPC_EXCP_SOFTP: /* Soft patch exception */ |
| 597 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 598 | cpu_abort(cs, |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 599 | "970 soft-patch exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 600 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 601 | case POWERPC_EXCP_MAINT: /* Maintenance exception */ |
| 602 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 603 | cpu_abort(cs, |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 604 | "970 maintenance exception is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 605 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 606 | case POWERPC_EXCP_MEXTBR: /* Maskable external breakpoint */ |
| 607 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 608 | cpu_abort(cs, "Maskable external exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 609 | "is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 610 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 611 | case POWERPC_EXCP_NMEXTBR: /* Non maskable external breakpoint */ |
| 612 | /* XXX: TODO */ |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 613 | cpu_abort(cs, "Non maskable external exception " |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 614 | "is not implemented yet !\n"); |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 615 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 616 | default: |
| 617 | excp_invalid: |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 618 | cpu_abort(cs, "Invalid PowerPC exception %d. Aborting\n", excp); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 619 | break; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 620 | } |
Benjamin Herrenschmidt | bd6fefe | 2016-07-27 16:56:32 +1000 | [diff] [blame] | 621 | |
| 622 | /* Save PC */ |
| 623 | env->spr[srr0] = env->nip; |
| 624 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 625 | /* Save MSR */ |
| 626 | env->spr[srr1] = msr; |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 627 | |
| 628 | /* Sanity check */ |
Nicholas Piggin | 10c21b5 | 2016-10-27 23:50:58 +1100 | [diff] [blame] | 629 | if (!(env->msr_mask & MSR_HVB)) { |
| 630 | if (new_msr & MSR_HVB) { |
| 631 | cpu_abort(cs, "Trying to deliver HV exception (MSR) %d with " |
| 632 | "no HV support\n", excp); |
| 633 | } |
| 634 | if (srr0 == SPR_HSRR0) { |
| 635 | cpu_abort(cs, "Trying to deliver HV exception (HSRR) %d with " |
| 636 | "no HV support\n", excp); |
| 637 | } |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 638 | } |
| 639 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 640 | /* If any alternate SRR register are defined, duplicate saved values */ |
| 641 | if (asrr0 != -1) { |
| 642 | env->spr[asrr0] = env->spr[srr0]; |
| 643 | } |
| 644 | if (asrr1 != -1) { |
| 645 | env->spr[asrr1] = env->spr[srr1]; |
| 646 | } |
Alexey Kardashevskiy | d5ac4f5 | 2014-06-04 22:51:05 +1000 | [diff] [blame] | 647 | |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 648 | /* Sort out endianness of interrupt, this differs depending on the |
| 649 | * CPU, the HV mode, etc... |
| 650 | */ |
Anton Blanchard | 1e0c7e5 | 2013-08-07 10:47:01 +1000 | [diff] [blame] | 651 | #ifdef TARGET_PPC64 |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 652 | if (excp_model == POWERPC_EXCP_POWER7) { |
| 653 | if (!(new_msr & MSR_HVB) && (env->spr[SPR_LPCR] & LPCR_ILE)) { |
| 654 | new_msr |= (target_ulong)1 << MSR_LE; |
| 655 | } |
| 656 | } else if (excp_model == POWERPC_EXCP_POWER8) { |
| 657 | if (new_msr & MSR_HVB) { |
| 658 | if (env->spr[SPR_HID0] & HID0_HILE) { |
| 659 | new_msr |= (target_ulong)1 << MSR_LE; |
| 660 | } |
| 661 | } else if (env->spr[SPR_LPCR] & LPCR_ILE) { |
Anton Blanchard | 1e0c7e5 | 2013-08-07 10:47:01 +1000 | [diff] [blame] | 662 | new_msr |= (target_ulong)1 << MSR_LE; |
| 663 | } |
| 664 | } else if (msr_ile) { |
| 665 | new_msr |= (target_ulong)1 << MSR_LE; |
| 666 | } |
| 667 | #else |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 668 | if (msr_ile) { |
| 669 | new_msr |= (target_ulong)1 << MSR_LE; |
| 670 | } |
Anton Blanchard | 1e0c7e5 | 2013-08-07 10:47:01 +1000 | [diff] [blame] | 671 | #endif |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 672 | |
| 673 | /* Jump to handler */ |
| 674 | vector = env->excp_vectors[excp]; |
| 675 | if (vector == (target_ulong)-1ULL) { |
Andreas Färber | a47dddd | 2013-09-03 17:38:47 +0200 | [diff] [blame] | 676 | cpu_abort(cs, "Raised an exception without defined vector %d\n", |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 677 | excp); |
| 678 | } |
| 679 | vector |= env->excp_prefix; |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 680 | |
| 681 | /* AIL only works if there is no HV transition and we are running with |
| 682 | * translations enabled |
| 683 | */ |
Benjamin Herrenschmidt | 6d49d6d | 2016-06-21 23:48:48 +0200 | [diff] [blame] | 684 | if (!((msr >> MSR_IR) & 1) || !((msr >> MSR_DR) & 1) || |
| 685 | ((new_msr & MSR_HVB) && !(msr & MSR_HVB))) { |
Cédric Le Goater | 5c94b2a | 2016-04-03 19:57:50 +0200 | [diff] [blame] | 686 | ail = 0; |
| 687 | } |
| 688 | /* Handle AIL */ |
| 689 | if (ail) { |
| 690 | new_msr |= (1 << MSR_IR) | (1 << MSR_DR); |
| 691 | switch(ail) { |
| 692 | case AIL_0001_8000: |
| 693 | vector |= 0x18000; |
| 694 | break; |
| 695 | case AIL_C000_0000_0000_4000: |
| 696 | vector |= 0xc000000000004000ull; |
| 697 | break; |
| 698 | default: |
| 699 | cpu_abort(cs, "Invalid AIL combination %d\n", ail); |
| 700 | break; |
| 701 | } |
| 702 | } |
| 703 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 704 | #if defined(TARGET_PPC64) |
| 705 | if (excp_model == POWERPC_EXCP_BOOKE) { |
Alexander Graf | e42a61f | 2012-06-20 21:20:29 +0200 | [diff] [blame] | 706 | if (env->spr[SPR_BOOKE_EPCR] & EPCR_ICM) { |
| 707 | /* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 708 | new_msr |= (target_ulong)1 << MSR_CM; |
Alexander Graf | e42a61f | 2012-06-20 21:20:29 +0200 | [diff] [blame] | 709 | } else { |
| 710 | vector = (uint32_t)vector; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 711 | } |
| 712 | } else { |
| 713 | if (!msr_isf && !(env->mmu_model & POWERPC_MMU_64)) { |
| 714 | vector = (uint32_t)vector; |
| 715 | } else { |
| 716 | new_msr |= (target_ulong)1 << MSR_SF; |
| 717 | } |
| 718 | } |
| 719 | #endif |
Benjamin Herrenschmidt | 1c953ba | 2016-06-03 14:11:18 +0200 | [diff] [blame] | 720 | /* We don't use hreg_store_msr here as already have treated |
| 721 | * any special case that could occur. Just store MSR and update hflags |
| 722 | * |
| 723 | * Note: We *MUST* not use hreg_store_msr() as-is anyway because it |
| 724 | * will prevent setting of the HV bit which some exceptions might need |
| 725 | * to do. |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 726 | */ |
| 727 | env->msr = new_msr & env->msr_mask; |
| 728 | hreg_compute_hflags(env); |
| 729 | env->nip = vector; |
| 730 | /* Reset exception state */ |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 731 | cs->exception_index = POWERPC_EXCP_NONE; |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 732 | env->error_code = 0; |
Benjamin Herrenschmidt | cd0c6f4 | 2016-05-03 18:03:25 +0200 | [diff] [blame] | 733 | |
| 734 | /* Any interrupt is context synchronizing, check if TCG TLB |
| 735 | * needs a delayed flush on ppc64 |
| 736 | */ |
Nikunj A Dadhania | e3cffe6 | 2016-09-20 22:05:00 +0530 | [diff] [blame] | 737 | check_tlb_flush(env, false); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 738 | } |
| 739 | |
Andreas Färber | 97a8ea5 | 2013-02-02 10:57:51 +0100 | [diff] [blame] | 740 | void ppc_cpu_do_interrupt(CPUState *cs) |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 741 | { |
Andreas Färber | 97a8ea5 | 2013-02-02 10:57:51 +0100 | [diff] [blame] | 742 | PowerPCCPU *cpu = POWERPC_CPU(cs); |
| 743 | CPUPPCState *env = &cpu->env; |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 744 | |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 745 | powerpc_excp(cpu, env->excp_model, cs->exception_index); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Richard Henderson | 458dd76 | 2014-09-13 09:45:32 -0700 | [diff] [blame] | 748 | static void ppc_hw_interrupt(CPUPPCState *env) |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 749 | { |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 750 | PowerPCCPU *cpu = ppc_env_get_cpu(env); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 751 | #if 0 |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 752 | CPUState *cs = CPU(cpu); |
| 753 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 754 | qemu_log_mask(CPU_LOG_INT, "%s: %p pending %08x req %08x me %d ee %d\n", |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 755 | __func__, env, env->pending_interrupts, |
| 756 | cs->interrupt_request, (int)msr_me, (int)msr_ee); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 757 | #endif |
| 758 | /* External reset */ |
| 759 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) { |
| 760 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 761 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 762 | return; |
| 763 | } |
| 764 | /* Machine check exception */ |
| 765 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) { |
| 766 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 767 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_MCHECK); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 768 | return; |
| 769 | } |
| 770 | #if 0 /* TODO */ |
| 771 | /* External debug exception */ |
| 772 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) { |
| 773 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 774 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DEBUG); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 775 | return; |
| 776 | } |
| 777 | #endif |
Benjamin Herrenschmidt | 4b236b6 | 2016-06-27 08:55:19 +0200 | [diff] [blame] | 778 | /* Hypervisor decrementer exception */ |
| 779 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) { |
| 780 | /* LPCR will be clear when not supported so this will work */ |
| 781 | bool hdice = !!(env->spr[SPR_LPCR] & LPCR_HDICE); |
| 782 | if ((msr_ee != 0 || msr_hv == 0) && hdice) { |
| 783 | /* HDEC clears on delivery */ |
| 784 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 785 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_HDECR); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 786 | return; |
| 787 | } |
| 788 | } |
Benjamin Herrenschmidt | d1dbe37 | 2016-06-27 08:55:17 +0200 | [diff] [blame] | 789 | /* Extermal interrupt can ignore MSR:EE under some circumstances */ |
| 790 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) { |
| 791 | bool lpes0 = !!(env->spr[SPR_LPCR] & LPCR_LPES0); |
| 792 | if (msr_ee != 0 || (env->has_hv_mode && msr_hv == 0 && !lpes0)) { |
| 793 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_EXTERNAL); |
| 794 | return; |
| 795 | } |
| 796 | } |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 797 | if (msr_ce != 0) { |
| 798 | /* External critical interrupt */ |
| 799 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_CEXT)) { |
| 800 | /* Taking a critical external interrupt does not clear the external |
| 801 | * critical interrupt status |
| 802 | */ |
| 803 | #if 0 |
| 804 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_CEXT); |
| 805 | #endif |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 806 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_CRITICAL); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 807 | return; |
| 808 | } |
| 809 | } |
| 810 | if (msr_ee != 0) { |
| 811 | /* Watchdog timer on embedded PowerPC */ |
| 812 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) { |
| 813 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 814 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_WDT); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 815 | return; |
| 816 | } |
| 817 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_CDOORBELL)) { |
| 818 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_CDOORBELL); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 819 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DOORCI); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 820 | return; |
| 821 | } |
| 822 | /* Fixed interval timer on embedded PowerPC */ |
| 823 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) { |
| 824 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 825 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_FIT); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 826 | return; |
| 827 | } |
| 828 | /* Programmable interval timer on embedded PowerPC */ |
| 829 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) { |
| 830 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 831 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_PIT); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 832 | return; |
| 833 | } |
| 834 | /* Decrementer exception */ |
| 835 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) { |
Alexander Graf | e81a982 | 2014-04-06 01:32:06 +0200 | [diff] [blame] | 836 | if (ppc_decr_clear_on_delivery(env)) { |
| 837 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR); |
| 838 | } |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 839 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DECR); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 840 | return; |
| 841 | } |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 842 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_DOORBELL)) { |
| 843 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DOORBELL); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 844 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DOORI); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 845 | return; |
| 846 | } |
| 847 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_PERFM)) { |
| 848 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PERFM); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 849 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_PERFM); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 850 | return; |
| 851 | } |
| 852 | /* Thermal interrupt */ |
| 853 | if (env->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) { |
| 854 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM); |
Andreas Färber | 5c26a5b | 2012-05-03 05:55:58 +0200 | [diff] [blame] | 855 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_THERM); |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 856 | return; |
| 857 | } |
| 858 | } |
| 859 | } |
Alexey Kardashevskiy | 3431648 | 2014-08-20 22:16:36 +1000 | [diff] [blame] | 860 | |
| 861 | void ppc_cpu_do_system_reset(CPUState *cs) |
| 862 | { |
| 863 | PowerPCCPU *cpu = POWERPC_CPU(cs); |
| 864 | CPUPPCState *env = &cpu->env; |
| 865 | |
| 866 | powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); |
| 867 | } |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 868 | #endif /* !CONFIG_USER_ONLY */ |
| 869 | |
Richard Henderson | 458dd76 | 2014-09-13 09:45:32 -0700 | [diff] [blame] | 870 | bool ppc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) |
| 871 | { |
| 872 | PowerPCCPU *cpu = POWERPC_CPU(cs); |
| 873 | CPUPPCState *env = &cpu->env; |
| 874 | |
| 875 | if (interrupt_request & CPU_INTERRUPT_HARD) { |
| 876 | ppc_hw_interrupt(env); |
| 877 | if (env->pending_interrupts == 0) { |
| 878 | cs->interrupt_request &= ~CPU_INTERRUPT_HARD; |
| 879 | } |
| 880 | return true; |
| 881 | } |
| 882 | return false; |
| 883 | } |
| 884 | |
Blue Swirl | c79c73f | 2012-05-30 04:23:25 +0000 | [diff] [blame] | 885 | #if defined(DEBUG_OP) |
| 886 | static void cpu_dump_rfi(target_ulong RA, target_ulong msr) |
| 887 | { |
| 888 | qemu_log("Return from exception at " TARGET_FMT_lx " with flags " |
| 889 | TARGET_FMT_lx "\n", RA, msr); |
| 890 | } |
| 891 | #endif |
| 892 | |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 893 | /*****************************************************************************/ |
| 894 | /* Exceptions processing helpers */ |
| 895 | |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 896 | void raise_exception_err_ra(CPUPPCState *env, uint32_t exception, |
| 897 | uint32_t error_code, uintptr_t raddr) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 898 | { |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 899 | CPUState *cs = CPU(ppc_env_get_cpu(env)); |
| 900 | |
Andreas Färber | 2710342 | 2013-08-26 08:31:06 +0200 | [diff] [blame] | 901 | cs->exception_index = exception; |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 902 | env->error_code = error_code; |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 903 | cpu_loop_exit_restore(cs, raddr); |
| 904 | } |
| 905 | |
| 906 | void raise_exception_err(CPUPPCState *env, uint32_t exception, |
| 907 | uint32_t error_code) |
| 908 | { |
| 909 | raise_exception_err_ra(env, exception, error_code, 0); |
| 910 | } |
| 911 | |
| 912 | void raise_exception(CPUPPCState *env, uint32_t exception) |
| 913 | { |
| 914 | raise_exception_err_ra(env, exception, 0, 0); |
| 915 | } |
| 916 | |
| 917 | void raise_exception_ra(CPUPPCState *env, uint32_t exception, |
| 918 | uintptr_t raddr) |
| 919 | { |
| 920 | raise_exception_err_ra(env, exception, 0, raddr); |
| 921 | } |
| 922 | |
| 923 | void helper_raise_exception_err(CPUPPCState *env, uint32_t exception, |
| 924 | uint32_t error_code) |
| 925 | { |
| 926 | raise_exception_err_ra(env, exception, error_code, 0); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 929 | void helper_raise_exception(CPUPPCState *env, uint32_t exception) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 930 | { |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 931 | raise_exception_err_ra(env, exception, 0, 0); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | #if !defined(CONFIG_USER_ONLY) |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 935 | void helper_store_msr(CPUPPCState *env, target_ulong val) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 936 | { |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 937 | uint32_t excp = hreg_store_msr(env, val, 0); |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 938 | |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 939 | if (excp != 0) { |
| 940 | CPUState *cs = CPU(ppc_env_get_cpu(env)); |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 941 | cs->interrupt_request |= CPU_INTERRUPT_EXITTB; |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 942 | raise_exception(env, excp); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 943 | } |
| 944 | } |
| 945 | |
Benjamin Herrenschmidt | 7778a57 | 2016-06-21 23:48:55 +0200 | [diff] [blame] | 946 | #if defined(TARGET_PPC64) |
| 947 | void helper_pminsn(CPUPPCState *env, powerpc_pm_insn_t insn) |
| 948 | { |
| 949 | CPUState *cs; |
| 950 | |
| 951 | cs = CPU(ppc_env_get_cpu(env)); |
| 952 | cs->halted = 1; |
| 953 | env->in_pm_state = true; |
| 954 | |
Benjamin Herrenschmidt | 4b236b6 | 2016-06-27 08:55:19 +0200 | [diff] [blame] | 955 | /* The architecture specifies that HDEC interrupts are |
| 956 | * discarded in PM states |
| 957 | */ |
| 958 | env->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR); |
| 959 | |
Benjamin Herrenschmidt | 7778a57 | 2016-06-21 23:48:55 +0200 | [diff] [blame] | 960 | /* Technically, nap doesn't set EE, but if we don't set it |
| 961 | * then ppc_hw_interrupt() won't deliver. We could add some |
| 962 | * other tests there based on LPCR but it's simpler to just |
| 963 | * whack EE in. It will be cleared by the 0x100 at wakeup |
| 964 | * anyway. It will still be observable by the guest in SRR1 |
| 965 | * but this doesn't seem to be a problem. |
| 966 | */ |
| 967 | env->msr |= (1ull << MSR_EE); |
Benjamin Herrenschmidt | db789c6 | 2016-07-27 16:56:19 +1000 | [diff] [blame] | 968 | raise_exception(env, EXCP_HLT); |
Benjamin Herrenschmidt | 7778a57 | 2016-06-21 23:48:55 +0200 | [diff] [blame] | 969 | } |
| 970 | #endif /* defined(TARGET_PPC64) */ |
| 971 | |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 972 | static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 973 | { |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 974 | CPUState *cs = CPU(ppc_env_get_cpu(env)); |
| 975 | |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 976 | /* MSR:POW cannot be set by any form of rfi */ |
| 977 | msr &= ~(1ULL << MSR_POW); |
| 978 | |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 979 | #if defined(TARGET_PPC64) |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 980 | /* Switching to 32-bit ? Crop the nip */ |
| 981 | if (!msr_is_64bit(env, msr)) { |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 982 | nip = (uint32_t)nip; |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 983 | } |
| 984 | #else |
| 985 | nip = (uint32_t)nip; |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 986 | #endif |
| 987 | /* XXX: beware: this is false if VLE is supported */ |
| 988 | env->nip = nip & ~((target_ulong)0x00000003); |
| 989 | hreg_store_msr(env, msr, 1); |
| 990 | #if defined(DEBUG_OP) |
| 991 | cpu_dump_rfi(env->nip, env->msr); |
| 992 | #endif |
| 993 | /* No need to raise an exception here, |
| 994 | * as rfi is always the last insn of a TB |
| 995 | */ |
Andreas Färber | 259186a | 2013-01-17 18:51:17 +0100 | [diff] [blame] | 996 | cs->interrupt_request |= CPU_INTERRUPT_EXITTB; |
Benjamin Herrenschmidt | cd0c6f4 | 2016-05-03 18:03:25 +0200 | [diff] [blame] | 997 | |
| 998 | /* Context synchronizing: check if TCG TLB needs flush */ |
Nikunj A Dadhania | e3cffe6 | 2016-09-20 22:05:00 +0530 | [diff] [blame] | 999 | check_tlb_flush(env, false); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1002 | void helper_rfi(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1003 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1004 | do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1] & 0xfffffffful); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1007 | #define MSR_BOOK3S_MASK |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1008 | #if defined(TARGET_PPC64) |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1009 | void helper_rfid(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1010 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1011 | /* The architeture defines a number of rules for which bits |
| 1012 | * can change but in practice, we handle this in hreg_store_msr() |
| 1013 | * which will be called by do_rfi(), so there is no need to filter |
| 1014 | * here |
| 1015 | */ |
| 1016 | do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1017 | } |
| 1018 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1019 | void helper_hrfid(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1020 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1021 | do_rfi(env, env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1022 | } |
| 1023 | #endif |
| 1024 | |
| 1025 | /*****************************************************************************/ |
| 1026 | /* Embedded PowerPC specific helpers */ |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1027 | void helper_40x_rfci(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1028 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1029 | do_rfi(env, env->spr[SPR_40x_SRR2], env->spr[SPR_40x_SRR3]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1032 | void helper_rfci(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1033 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1034 | do_rfi(env, env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1037 | void helper_rfdi(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1038 | { |
Scott Wood | a1bb738 | 2012-12-21 16:15:41 +0000 | [diff] [blame] | 1039 | /* FIXME: choose CSRR1 or DSRR1 based on cpu type */ |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1040 | do_rfi(env, env->spr[SPR_BOOKE_DSRR0], env->spr[SPR_BOOKE_DSRR1]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1043 | void helper_rfmci(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1044 | { |
Scott Wood | a1bb738 | 2012-12-21 16:15:41 +0000 | [diff] [blame] | 1045 | /* FIXME: choose CSRR1 or MCSRR1 based on cpu type */ |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1046 | do_rfi(env, env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1047 | } |
| 1048 | #endif |
| 1049 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1050 | void helper_tw(CPUPPCState *env, target_ulong arg1, target_ulong arg2, |
| 1051 | uint32_t flags) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1052 | { |
| 1053 | if (!likely(!(((int32_t)arg1 < (int32_t)arg2 && (flags & 0x10)) || |
| 1054 | ((int32_t)arg1 > (int32_t)arg2 && (flags & 0x08)) || |
| 1055 | ((int32_t)arg1 == (int32_t)arg2 && (flags & 0x04)) || |
| 1056 | ((uint32_t)arg1 < (uint32_t)arg2 && (flags & 0x02)) || |
| 1057 | ((uint32_t)arg1 > (uint32_t)arg2 && (flags & 0x01))))) { |
Benjamin Herrenschmidt | 72073dc | 2016-07-27 16:56:38 +1000 | [diff] [blame] | 1058 | raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, |
| 1059 | POWERPC_EXCP_TRAP, GETPC()); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | #if defined(TARGET_PPC64) |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1064 | void helper_td(CPUPPCState *env, target_ulong arg1, target_ulong arg2, |
| 1065 | uint32_t flags) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1066 | { |
| 1067 | if (!likely(!(((int64_t)arg1 < (int64_t)arg2 && (flags & 0x10)) || |
| 1068 | ((int64_t)arg1 > (int64_t)arg2 && (flags & 0x08)) || |
| 1069 | ((int64_t)arg1 == (int64_t)arg2 && (flags & 0x04)) || |
| 1070 | ((uint64_t)arg1 < (uint64_t)arg2 && (flags & 0x02)) || |
| 1071 | ((uint64_t)arg1 > (uint64_t)arg2 && (flags & 0x01))))) { |
Benjamin Herrenschmidt | 72073dc | 2016-07-27 16:56:38 +1000 | [diff] [blame] | 1072 | raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, |
| 1073 | POWERPC_EXCP_TRAP, GETPC()); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | #endif |
| 1077 | |
| 1078 | #if !defined(CONFIG_USER_ONLY) |
| 1079 | /*****************************************************************************/ |
| 1080 | /* PowerPC 601 specific instructions (POWER bridge) */ |
| 1081 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1082 | void helper_rfsvc(CPUPPCState *env) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1083 | { |
Benjamin Herrenschmidt | a2e71b2 | 2016-06-21 23:48:46 +0200 | [diff] [blame] | 1084 | do_rfi(env, env->lr, env->ctr & 0x0000FFFF); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | /* Embedded.Processor Control */ |
| 1088 | static int dbell2irq(target_ulong rb) |
| 1089 | { |
| 1090 | int msg = rb & DBELL_TYPE_MASK; |
| 1091 | int irq = -1; |
| 1092 | |
| 1093 | switch (msg) { |
| 1094 | case DBELL_TYPE_DBELL: |
| 1095 | irq = PPC_INTERRUPT_DOORBELL; |
| 1096 | break; |
| 1097 | case DBELL_TYPE_DBELL_CRIT: |
| 1098 | irq = PPC_INTERRUPT_CDOORBELL; |
| 1099 | break; |
| 1100 | case DBELL_TYPE_G_DBELL: |
| 1101 | case DBELL_TYPE_G_DBELL_CRIT: |
| 1102 | case DBELL_TYPE_G_DBELL_MC: |
| 1103 | /* XXX implement */ |
| 1104 | default: |
| 1105 | break; |
| 1106 | } |
| 1107 | |
| 1108 | return irq; |
| 1109 | } |
| 1110 | |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 1111 | void helper_msgclr(CPUPPCState *env, target_ulong rb) |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1112 | { |
| 1113 | int irq = dbell2irq(rb); |
| 1114 | |
| 1115 | if (irq < 0) { |
| 1116 | return; |
| 1117 | } |
| 1118 | |
| 1119 | env->pending_interrupts &= ~(1 << irq); |
| 1120 | } |
| 1121 | |
| 1122 | void helper_msgsnd(target_ulong rb) |
| 1123 | { |
| 1124 | int irq = dbell2irq(rb); |
| 1125 | int pir = rb & DBELL_PIRTAG_MASK; |
Andreas Färber | 182735e | 2013-05-29 22:29:20 +0200 | [diff] [blame] | 1126 | CPUState *cs; |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1127 | |
| 1128 | if (irq < 0) { |
| 1129 | return; |
| 1130 | } |
| 1131 | |
Andreas Färber | bdc4464 | 2013-06-24 23:50:24 +0200 | [diff] [blame] | 1132 | CPU_FOREACH(cs) { |
Andreas Färber | 182735e | 2013-05-29 22:29:20 +0200 | [diff] [blame] | 1133 | PowerPCCPU *cpu = POWERPC_CPU(cs); |
| 1134 | CPUPPCState *cenv = &cpu->env; |
| 1135 | |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1136 | if ((rb & DBELL_BRDCAST) || (cenv->spr[SPR_BOOKE_PIR] == pir)) { |
| 1137 | cenv->pending_interrupts |= 1 << irq; |
Andreas Färber | 182735e | 2013-05-29 22:29:20 +0200 | [diff] [blame] | 1138 | cpu_interrupt(cs, CPU_INTERRUPT_HARD); |
Blue Swirl | ad71ed6 | 2012-05-30 04:23:22 +0000 | [diff] [blame] | 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | #endif |