]>
Commit | Line | Data |
---|---|---|
0ebc4cda BH |
1 | /* |
2 | * This file contains the 64-bit "server" PowerPC variant | |
3 | * of the low level exception handling including exception | |
4 | * vectors, exception return, part of the slb and stab | |
5 | * handling and other fixed offset specific things. | |
6 | * | |
7 | * This file is meant to be #included from head_64.S due to | |
25985edc | 8 | * position dependent assembly. |
0ebc4cda BH |
9 | * |
10 | * Most of this originates from head_64.S and thus has the same | |
11 | * copyright history. | |
12 | * | |
13 | */ | |
14 | ||
7230c564 | 15 | #include <asm/hw_irq.h> |
8aa34ab8 | 16 | #include <asm/exception-64s.h> |
46f52210 | 17 | #include <asm/ptrace.h> |
7cba160a | 18 | #include <asm/cpuidle.h> |
8aa34ab8 | 19 | |
0ebc4cda BH |
20 | /* |
21 | * We layout physical memory as follows: | |
22 | * 0x0000 - 0x00ff : Secondary processor spin code | |
c1fb6816 MN |
23 | * 0x0100 - 0x17ff : pSeries Interrupt prologs |
24 | * 0x1800 - 0x4000 : interrupt support common interrupt prologs | |
25 | * 0x4000 - 0x5fff : pSeries interrupts with IR=1,DR=1 | |
26 | * 0x6000 - 0x6fff : more interrupt support including for IR=1,DR=1 | |
0ebc4cda | 27 | * 0x7000 - 0x7fff : FWNMI data area |
c1fb6816 MN |
28 | * 0x8000 - 0x8fff : Initial (CPU0) segment table |
29 | * 0x9000 - : Early init and support code | |
0ebc4cda | 30 | */ |
742415d6 MN |
31 | /* Syscall routine is used twice, in reloc-off and reloc-on paths */ |
32 | #define SYSCALL_PSERIES_1 \ | |
33 | BEGIN_FTR_SECTION \ | |
34 | cmpdi r0,0x1ebe ; \ | |
35 | beq- 1f ; \ | |
36 | END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ | |
37 | mr r9,r13 ; \ | |
38 | GET_PACA(r13) ; \ | |
39 | mfspr r11,SPRN_SRR0 ; \ | |
40 | 0: | |
41 | ||
42 | #define SYSCALL_PSERIES_2_RFID \ | |
43 | mfspr r12,SPRN_SRR1 ; \ | |
44 | ld r10,PACAKBASE(r13) ; \ | |
45 | LOAD_HANDLER(r10, system_call_entry) ; \ | |
46 | mtspr SPRN_SRR0,r10 ; \ | |
47 | ld r10,PACAKMSR(r13) ; \ | |
48 | mtspr SPRN_SRR1,r10 ; \ | |
49 | rfid ; \ | |
50 | b . ; /* prevent speculative execution */ | |
51 | ||
52 | #define SYSCALL_PSERIES_3 \ | |
53 | /* Fast LE/BE switch system call */ \ | |
54 | 1: mfspr r12,SPRN_SRR1 ; \ | |
55 | xori r12,r12,MSR_LE ; \ | |
56 | mtspr SPRN_SRR1,r12 ; \ | |
57 | rfid ; /* return to userspace */ \ | |
742415d6 MN |
58 | b . ; /* prevent speculative execution */ |
59 | ||
4700dfaf MN |
60 | #if defined(CONFIG_RELOCATABLE) |
61 | /* | |
05b05f28 AB |
62 | * We can't branch directly so we do it via the CTR which |
63 | * is volatile across system calls. | |
4700dfaf MN |
64 | */ |
65 | #define SYSCALL_PSERIES_2_DIRECT \ | |
66 | mflr r10 ; \ | |
67 | ld r12,PACAKBASE(r13) ; \ | |
05b05f28 | 68 | LOAD_HANDLER(r12, system_call_entry) ; \ |
6a404806 | 69 | mtctr r12 ; \ |
4700dfaf MN |
70 | mfspr r12,SPRN_SRR1 ; \ |
71 | /* Re-use of r13... No spare regs to do this */ \ | |
72 | li r13,MSR_RI ; \ | |
73 | mtmsrd r13,1 ; \ | |
74 | GET_PACA(r13) ; /* get r13 back */ \ | |
6a404806 | 75 | bctr ; |
4700dfaf MN |
76 | #else |
77 | /* We can branch directly */ | |
78 | #define SYSCALL_PSERIES_2_DIRECT \ | |
79 | mfspr r12,SPRN_SRR1 ; \ | |
80 | li r10,MSR_RI ; \ | |
81 | mtmsrd r10,1 ; /* Set RI (EE=0) */ \ | |
d20be433 | 82 | b system_call_common ; |
4700dfaf | 83 | #endif |
0ebc4cda | 84 | |
0ebc4cda BH |
85 | /* |
86 | * This is the start of the interrupt handlers for pSeries | |
87 | * This code runs with relocation off. | |
88 | * Code from here to __end_interrupts gets copied down to real | |
89 | * address 0x100 when we are running a relocatable kernel. | |
90 | * Therefore any relative branches in this section must only | |
91 | * branch to labels in this section. | |
92 | */ | |
93 | . = 0x100 | |
94 | .globl __start_interrupts | |
95 | __start_interrupts: | |
96 | ||
948cf67c BH |
97 | .globl system_reset_pSeries; |
98 | system_reset_pSeries: | |
948cf67c BH |
99 | SET_SCRATCH0(r13) |
100 | #ifdef CONFIG_PPC_P7_NAP | |
101 | BEGIN_FTR_SECTION | |
102 | /* Running native on arch 2.06 or later, check if we are | |
77b54e9f | 103 | * waking up from nap/sleep/winkle. |
948cf67c BH |
104 | */ |
105 | mfspr r13,SPRN_SRR1 | |
371fefd6 PM |
106 | rlwinm. r13,r13,47-31,30,31 |
107 | beq 9f | |
108 | ||
7cba160a | 109 | cmpwi cr3,r13,2 |
371fefd6 | 110 | GET_PACA(r13) |
17065671 | 111 | bl power7_restore_hyp_resource |
77b54e9f | 112 | |
7cba160a SP |
113 | li r0,PNV_THREAD_RUNNING |
114 | stb r0,PACA_THREAD_IDLE_STATE(r13) /* Clear thread state */ | |
371fefd6 | 115 | |
3a167bea | 116 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
f0888f70 PM |
117 | li r0,KVM_HWTHREAD_IN_KERNEL |
118 | stb r0,HSTATE_HWTHREAD_STATE(r13) | |
119 | /* Order setting hwthread_state vs. testing hwthread_req */ | |
120 | sync | |
121 | lbz r0,HSTATE_HWTHREAD_REQ(r13) | |
122 | cmpwi r0,0 | |
123 | beq 1f | |
371fefd6 PM |
124 | b kvm_start_guest |
125 | 1: | |
126 | #endif | |
127 | ||
56548fc0 PM |
128 | /* Return SRR1 from power7_nap() */ |
129 | mfspr r3,SPRN_SRR1 | |
17065671 SP |
130 | blt cr3,2f |
131 | b power7_wakeup_loss | |
132 | 2: b power7_wakeup_noloss | |
aca79d2b | 133 | |
371fefd6 | 134 | 9: |
969391c5 | 135 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
948cf67c | 136 | #endif /* CONFIG_PPC_P7_NAP */ |
b01c8b54 PM |
137 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
138 | NOTEST, 0x100) | |
0ebc4cda BH |
139 | |
140 | . = 0x200 | |
b01c8b54 PM |
141 | machine_check_pSeries_1: |
142 | /* This is moved out of line as it can be patched by FW, but | |
143 | * some code path might still want to branch into the original | |
144 | * vector | |
145 | */ | |
1707dd16 | 146 | SET_SCRATCH0(r13) /* save r13 */ |
1c51089f MS |
147 | #ifdef CONFIG_PPC_P7_NAP |
148 | BEGIN_FTR_SECTION | |
149 | /* Running native on arch 2.06 or later, check if we are | |
150 | * waking up from nap. We only handle no state loss and | |
151 | * supervisor state loss. We do -not- handle hypervisor | |
152 | * state loss at this time. | |
153 | */ | |
154 | mfspr r13,SPRN_SRR1 | |
155 | rlwinm. r13,r13,47-31,30,31 | |
d410ae21 | 156 | OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
157 | beq 9f |
158 | ||
d410ae21 MS |
159 | mfspr r13,SPRN_SRR1 |
160 | rlwinm. r13,r13,47-31,30,31 | |
1c51089f MS |
161 | /* waking up from powersave (nap) state */ |
162 | cmpwi cr1,r13,2 | |
163 | /* Total loss of HV state is fatal. let's just stay stuck here */ | |
d410ae21 | 164 | OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
165 | bgt cr1,. |
166 | 9: | |
d410ae21 | 167 | OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) |
1c51089f MS |
168 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
169 | #endif /* CONFIG_PPC_P7_NAP */ | |
1707dd16 | 170 | EXCEPTION_PROLOG_0(PACA_EXMC) |
1e9b4507 | 171 | BEGIN_FTR_SECTION |
2513767d | 172 | b machine_check_powernv_early |
1e9b4507 | 173 | FTR_SECTION_ELSE |
1707dd16 | 174 | b machine_check_pSeries_0 |
1e9b4507 | 175 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) |
0ebc4cda BH |
176 | |
177 | . = 0x300 | |
178 | .globl data_access_pSeries | |
179 | data_access_pSeries: | |
673b189a | 180 | SET_SCRATCH0(r13) |
b01c8b54 | 181 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD, |
697d3899 | 182 | KVMTEST, 0x300) |
0ebc4cda BH |
183 | |
184 | . = 0x380 | |
185 | .globl data_access_slb_pSeries | |
186 | data_access_slb_pSeries: | |
673b189a | 187 | SET_SCRATCH0(r13) |
1707dd16 | 188 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
697d3899 | 189 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380) |
0ebc4cda BH |
190 | std r3,PACA_EXSLB+EX_R3(r13) |
191 | mfspr r3,SPRN_DAR | |
b01c8b54 | 192 | mfspr r12,SPRN_SRR1 |
0ebc4cda | 193 | #ifndef CONFIG_RELOCATABLE |
b1576fec | 194 | b slb_miss_realmode |
0ebc4cda BH |
195 | #else |
196 | /* | |
ad0289e4 | 197 | * We can't just use a direct branch to slb_miss_realmode |
0ebc4cda BH |
198 | * because the distance from here to there depends on where |
199 | * the kernel ends up being put. | |
200 | */ | |
201 | mfctr r11 | |
202 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 203 | LOAD_HANDLER(r10, slb_miss_realmode) |
0ebc4cda BH |
204 | mtctr r10 |
205 | bctr | |
206 | #endif | |
207 | ||
2613265c | 208 | STD_EXCEPTION_PSERIES(0x400, instruction_access) |
0ebc4cda BH |
209 | |
210 | . = 0x480 | |
211 | .globl instruction_access_slb_pSeries | |
212 | instruction_access_slb_pSeries: | |
673b189a | 213 | SET_SCRATCH0(r13) |
1707dd16 | 214 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
31a40e2b | 215 | EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x480) |
0ebc4cda BH |
216 | std r3,PACA_EXSLB+EX_R3(r13) |
217 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ | |
b01c8b54 | 218 | mfspr r12,SPRN_SRR1 |
0ebc4cda | 219 | #ifndef CONFIG_RELOCATABLE |
b1576fec | 220 | b slb_miss_realmode |
0ebc4cda BH |
221 | #else |
222 | mfctr r11 | |
223 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 224 | LOAD_HANDLER(r10, slb_miss_realmode) |
0ebc4cda BH |
225 | mtctr r10 |
226 | bctr | |
227 | #endif | |
228 | ||
b3e6b5df BH |
229 | /* We open code these as we can't have a ". = x" (even with |
230 | * x = "." within a feature section | |
231 | */ | |
a5d4f3ad | 232 | . = 0x500; |
b3e6b5df BH |
233 | .globl hardware_interrupt_pSeries; |
234 | .globl hardware_interrupt_hv; | |
a5d4f3ad | 235 | hardware_interrupt_pSeries: |
b3e6b5df | 236 | hardware_interrupt_hv: |
a5d4f3ad | 237 | BEGIN_FTR_SECTION |
b01c8b54 PM |
238 | _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt, |
239 | EXC_HV, SOFTEN_TEST_HV) | |
240 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502) | |
de56a948 PM |
241 | FTR_SECTION_ELSE |
242 | _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt, | |
31a40e2b | 243 | EXC_STD, SOFTEN_TEST_PR) |
de56a948 | 244 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500) |
969391c5 | 245 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) |
a5d4f3ad | 246 | |
2613265c | 247 | STD_EXCEPTION_PSERIES(0x600, alignment) |
31a40e2b | 248 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x600) |
b01c8b54 | 249 | |
2613265c | 250 | STD_EXCEPTION_PSERIES(0x700, program_check) |
31a40e2b | 251 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x700) |
b01c8b54 | 252 | |
2613265c | 253 | STD_EXCEPTION_PSERIES(0x800, fp_unavailable) |
31a40e2b | 254 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x800) |
a5d4f3ad | 255 | |
a485c709 PM |
256 | . = 0x900 |
257 | .globl decrementer_pSeries | |
258 | decrementer_pSeries: | |
259 | _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR) | |
260 | ||
dabe859e | 261 | STD_EXCEPTION_HV(0x980, 0x982, hdecrementer) |
a5d4f3ad | 262 | |
1dbdafec | 263 | MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super) |
31a40e2b | 264 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xa00) |
b01c8b54 | 265 | |
2613265c | 266 | STD_EXCEPTION_PSERIES(0xb00, trap_0b) |
31a40e2b | 267 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xb00) |
0ebc4cda BH |
268 | |
269 | . = 0xc00 | |
270 | .globl system_call_pSeries | |
271 | system_call_pSeries: | |
8b91a255 SW |
272 | /* |
273 | * If CONFIG_KVM_BOOK3S_64_HANDLER is set, save the PPR (on systems | |
274 | * that support it) before changing to HMT_MEDIUM. That allows the KVM | |
275 | * code to save that value into the guest state (it is the guest's PPR | |
276 | * value). Otherwise just change to HMT_MEDIUM as userspace has | |
277 | * already saved the PPR. | |
278 | */ | |
b01c8b54 PM |
279 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
280 | SET_SCRATCH0(r13) | |
281 | GET_PACA(r13) | |
282 | std r9,PACA_EXGEN+EX_R9(r13) | |
8b91a255 SW |
283 | OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); |
284 | HMT_MEDIUM; | |
b01c8b54 | 285 | std r10,PACA_EXGEN+EX_R10(r13) |
8b91a255 | 286 | OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR); |
b01c8b54 PM |
287 | mfcr r9 |
288 | KVMTEST(0xc00) | |
289 | GET_SCRATCH0(r13) | |
8b91a255 SW |
290 | #else |
291 | HMT_MEDIUM; | |
b01c8b54 | 292 | #endif |
742415d6 MN |
293 | SYSCALL_PSERIES_1 |
294 | SYSCALL_PSERIES_2_RFID | |
295 | SYSCALL_PSERIES_3 | |
b01c8b54 PM |
296 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) |
297 | ||
2613265c | 298 | STD_EXCEPTION_PSERIES(0xd00, single_step) |
31a40e2b | 299 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xd00) |
b3e6b5df BH |
300 | |
301 | /* At 0xe??? we have a bunch of hypervisor exceptions, we branch | |
302 | * out of line to handle them | |
303 | */ | |
304 | . = 0xe00 | |
d671ddd6 | 305 | hv_data_storage_trampoline: |
1707dd16 PM |
306 | SET_SCRATCH0(r13) |
307 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 308 | b h_data_storage_hv |
1707dd16 | 309 | |
b3e6b5df | 310 | . = 0xe20 |
d671ddd6 | 311 | hv_instr_storage_trampoline: |
1707dd16 PM |
312 | SET_SCRATCH0(r13) |
313 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 314 | b h_instr_storage_hv |
1707dd16 | 315 | |
b3e6b5df | 316 | . = 0xe40 |
d671ddd6 | 317 | emulation_assist_trampoline: |
1707dd16 PM |
318 | SET_SCRATCH0(r13) |
319 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
b3e6b5df | 320 | b emulation_assist_hv |
1707dd16 | 321 | |
b3e6b5df | 322 | . = 0xe60 |
d671ddd6 | 323 | hv_exception_trampoline: |
1707dd16 PM |
324 | SET_SCRATCH0(r13) |
325 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0869b6fd | 326 | b hmi_exception_early |
1707dd16 | 327 | |
655bb3f4 | 328 | . = 0xe80 |
d671ddd6 | 329 | hv_doorbell_trampoline: |
1707dd16 PM |
330 | SET_SCRATCH0(r13) |
331 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
655bb3f4 | 332 | b h_doorbell_hv |
0ebc4cda BH |
333 | |
334 | /* We need to deal with the Altivec unavailable exception | |
335 | * here which is at 0xf20, thus in the middle of the | |
336 | * prolog code of the PerformanceMonitor one. A little | |
337 | * trickery is thus necessary | |
338 | */ | |
339 | . = 0xf00 | |
fa111f1f | 340 | performance_monitor_pseries_trampoline: |
1707dd16 PM |
341 | SET_SCRATCH0(r13) |
342 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
343 | b performance_monitor_pSeries |
344 | ||
345 | . = 0xf20 | |
fa111f1f | 346 | altivec_unavailable_pseries_trampoline: |
1707dd16 PM |
347 | SET_SCRATCH0(r13) |
348 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
349 | b altivec_unavailable_pSeries |
350 | ||
351 | . = 0xf40 | |
fa111f1f | 352 | vsx_unavailable_pseries_trampoline: |
1707dd16 PM |
353 | SET_SCRATCH0(r13) |
354 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
0ebc4cda BH |
355 | b vsx_unavailable_pSeries |
356 | ||
d0c0c9a1 | 357 | . = 0xf60 |
fa111f1f | 358 | facility_unavailable_trampoline: |
d0c0c9a1 MN |
359 | SET_SCRATCH0(r13) |
360 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
021424a1 | 361 | b facility_unavailable_pSeries |
d0c0c9a1 | 362 | |
b14b6260 | 363 | . = 0xf80 |
fa111f1f | 364 | hv_facility_unavailable_trampoline: |
b14b6260 ME |
365 | SET_SCRATCH0(r13) |
366 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
367 | b facility_unavailable_hv | |
368 | ||
0ebc4cda | 369 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 370 | STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error) |
5ccf55dd | 371 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202) |
0ebc4cda | 372 | #endif /* CONFIG_CBE_RAS */ |
b01c8b54 | 373 | |
2613265c | 374 | STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint) |
31a40e2b | 375 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1300) |
b01c8b54 | 376 | |
b92a66a6 | 377 | . = 0x1500 |
51cf2b30 | 378 | .global denorm_exception_hv |
b92a66a6 | 379 | denorm_exception_hv: |
b92a66a6 | 380 | mtspr SPRN_SPRG_HSCRATCH0,r13 |
1707dd16 | 381 | EXCEPTION_PROLOG_0(PACA_EXGEN) |
630573c1 | 382 | EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500) |
b92a66a6 MN |
383 | |
384 | #ifdef CONFIG_PPC_DENORMALISATION | |
385 | mfspr r10,SPRN_HSRR1 | |
386 | mfspr r11,SPRN_HSRR0 /* save HSRR0 */ | |
387 | andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ | |
388 | addi r11,r11,-4 /* HSRR0 is next instruction */ | |
389 | bne+ denorm_assist | |
390 | #endif | |
391 | ||
630573c1 | 392 | KVMTEST(0x1500) |
b92a66a6 MN |
393 | EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV) |
394 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500) | |
395 | ||
0ebc4cda | 396 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 397 | STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) |
5ccf55dd | 398 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602) |
0ebc4cda | 399 | #endif /* CONFIG_CBE_RAS */ |
b01c8b54 | 400 | |
2613265c | 401 | STD_EXCEPTION_PSERIES(0x1700, altivec_assist) |
31a40e2b | 402 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x1700) |
b01c8b54 | 403 | |
0ebc4cda | 404 | #ifdef CONFIG_CBE_RAS |
b3e6b5df | 405 | STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) |
5ccf55dd | 406 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802) |
faab4dd2 MN |
407 | #else |
408 | . = 0x1800 | |
0ebc4cda BH |
409 | #endif /* CONFIG_CBE_RAS */ |
410 | ||
0ebc4cda | 411 | |
b3e6b5df BH |
412 | /*** Out of line interrupts support ***/ |
413 | ||
faab4dd2 | 414 | .align 7 |
b01c8b54 | 415 | /* moved from 0x200 */ |
2513767d | 416 | machine_check_powernv_early: |
1e9b4507 MS |
417 | BEGIN_FTR_SECTION |
418 | EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200) | |
419 | /* | |
420 | * Register contents: | |
421 | * R13 = PACA | |
422 | * R9 = CR | |
423 | * Original R9 to R13 is saved on PACA_EXMC | |
424 | * | |
e75ad93a MS |
425 | * Switch to mc_emergency stack and handle re-entrancy (we limit |
426 | * the nested MCE upto level 4 to avoid stack overflow). | |
427 | * Save MCE registers srr1, srr0, dar and dsisr and then set ME=1 | |
1e9b4507 MS |
428 | * |
429 | * We use paca->in_mce to check whether this is the first entry or | |
430 | * nested machine check. We increment paca->in_mce to track nested | |
431 | * machine checks. | |
432 | * | |
433 | * If this is the first entry then set stack pointer to | |
434 | * paca->mc_emergency_sp, otherwise r1 is already pointing to | |
435 | * stack frame on mc_emergency stack. | |
436 | * | |
437 | * NOTE: We are here with MSR_ME=0 (off), which means we risk a | |
438 | * checkstop if we get another machine check exception before we do | |
439 | * rfid with MSR_ME=1. | |
440 | */ | |
441 | mr r11,r1 /* Save r1 */ | |
442 | lhz r10,PACA_IN_MCE(r13) | |
443 | cmpwi r10,0 /* Are we in nested machine check */ | |
444 | bne 0f /* Yes, we are. */ | |
445 | /* First machine check entry */ | |
446 | ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */ | |
447 | 0: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ | |
448 | addi r10,r10,1 /* increment paca->in_mce */ | |
449 | sth r10,PACA_IN_MCE(r13) | |
e75ad93a MS |
450 | /* Limit nested MCE to level 4 to avoid stack overflow */ |
451 | cmpwi r10,4 | |
452 | bgt 2f /* Check if we hit limit of 4 */ | |
1e9b4507 MS |
453 | std r11,GPR1(r1) /* Save r1 on the stack. */ |
454 | std r11,0(r1) /* make stack chain pointer */ | |
455 | mfspr r11,SPRN_SRR0 /* Save SRR0 */ | |
456 | std r11,_NIP(r1) | |
457 | mfspr r11,SPRN_SRR1 /* Save SRR1 */ | |
458 | std r11,_MSR(r1) | |
459 | mfspr r11,SPRN_DAR /* Save DAR */ | |
460 | std r11,_DAR(r1) | |
461 | mfspr r11,SPRN_DSISR /* Save DSISR */ | |
462 | std r11,_DSISR(r1) | |
463 | std r9,_CCR(r1) /* Save CR in stackframe */ | |
464 | /* Save r9 through r13 from EXMC save area to stack frame. */ | |
465 | EXCEPTION_PROLOG_COMMON_2(PACA_EXMC) | |
466 | mfmsr r11 /* get MSR value */ | |
467 | ori r11,r11,MSR_ME /* turn on ME bit */ | |
468 | ori r11,r11,MSR_RI /* turn on RI bit */ | |
469 | ld r12,PACAKBASE(r13) /* get high part of &label */ | |
470 | LOAD_HANDLER(r12, machine_check_handle_early) | |
e75ad93a | 471 | 1: mtspr SPRN_SRR0,r12 |
1e9b4507 MS |
472 | mtspr SPRN_SRR1,r11 |
473 | rfid | |
474 | b . /* prevent speculative execution */ | |
e75ad93a MS |
475 | 2: |
476 | /* Stack overflow. Stay on emergency stack and panic. | |
477 | * Keep the ME bit off while panic-ing, so that if we hit | |
478 | * another machine check we checkstop. | |
479 | */ | |
480 | addi r1,r1,INT_FRAME_SIZE /* go back to previous stack frame */ | |
481 | ld r11,PACAKMSR(r13) | |
482 | ld r12,PACAKBASE(r13) | |
483 | LOAD_HANDLER(r12, unrecover_mce) | |
484 | li r10,MSR_ME | |
485 | andc r11,r11,r10 /* Turn off MSR_ME */ | |
486 | b 1b | |
487 | b . /* prevent speculative execution */ | |
1e9b4507 MS |
488 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) |
489 | ||
b01c8b54 PM |
490 | machine_check_pSeries: |
491 | .globl machine_check_fwnmi | |
492 | machine_check_fwnmi: | |
b01c8b54 | 493 | SET_SCRATCH0(r13) /* save r13 */ |
1707dd16 PM |
494 | EXCEPTION_PROLOG_0(PACA_EXMC) |
495 | machine_check_pSeries_0: | |
496 | EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200) | |
497 | EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD) | |
b01c8b54 | 498 | KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200) |
697d3899 PM |
499 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300) |
500 | KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380) | |
31a40e2b PM |
501 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x400) |
502 | KVM_HANDLER(PACA_EXSLB, EXC_STD, 0x480) | |
503 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x900) | |
b01c8b54 PM |
504 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982) |
505 | ||
b92a66a6 MN |
506 | #ifdef CONFIG_PPC_DENORMALISATION |
507 | denorm_assist: | |
508 | BEGIN_FTR_SECTION | |
509 | /* | |
510 | * To denormalise we need to move a copy of the register to itself. | |
511 | * For POWER6 do that here for all FP regs. | |
512 | */ | |
513 | mfmsr r10 | |
514 | ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1) | |
515 | xori r10,r10,(MSR_FE0|MSR_FE1) | |
516 | mtmsrd r10 | |
517 | sync | |
d7c67fb1 MN |
518 | |
519 | #define FMR2(n) fmr (n), (n) ; fmr n+1, n+1 | |
520 | #define FMR4(n) FMR2(n) ; FMR2(n+2) | |
521 | #define FMR8(n) FMR4(n) ; FMR4(n+4) | |
522 | #define FMR16(n) FMR8(n) ; FMR8(n+8) | |
523 | #define FMR32(n) FMR16(n) ; FMR16(n+16) | |
524 | FMR32(0) | |
525 | ||
b92a66a6 MN |
526 | FTR_SECTION_ELSE |
527 | /* | |
528 | * To denormalise we need to move a copy of the register to itself. | |
529 | * For POWER7 do that here for the first 32 VSX registers only. | |
530 | */ | |
531 | mfmsr r10 | |
532 | oris r10,r10,MSR_VSX@h | |
533 | mtmsrd r10 | |
534 | sync | |
d7c67fb1 MN |
535 | |
536 | #define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1) | |
537 | #define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2) | |
538 | #define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4) | |
539 | #define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8) | |
540 | #define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16) | |
541 | XVCPSGNDP32(0) | |
542 | ||
b92a66a6 | 543 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206) |
fb0fce3e MN |
544 | |
545 | BEGIN_FTR_SECTION | |
546 | b denorm_done | |
547 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |
548 | /* | |
549 | * To denormalise we need to move a copy of the register to itself. | |
550 | * For POWER8 we need to do that for all 64 VSX registers | |
551 | */ | |
552 | XVCPSGNDP32(32) | |
553 | denorm_done: | |
b92a66a6 MN |
554 | mtspr SPRN_HSRR0,r11 |
555 | mtcrf 0x80,r9 | |
556 | ld r9,PACA_EXGEN+EX_R9(r13) | |
44e9309f | 557 | RESTORE_PPR_PACA(PACA_EXGEN, r10) |
630573c1 PM |
558 | BEGIN_FTR_SECTION |
559 | ld r10,PACA_EXGEN+EX_CFAR(r13) | |
560 | mtspr SPRN_CFAR,r10 | |
561 | END_FTR_SECTION_IFSET(CPU_FTR_CFAR) | |
b92a66a6 MN |
562 | ld r10,PACA_EXGEN+EX_R10(r13) |
563 | ld r11,PACA_EXGEN+EX_R11(r13) | |
564 | ld r12,PACA_EXGEN+EX_R12(r13) | |
565 | ld r13,PACA_EXGEN+EX_R13(r13) | |
566 | HRFID | |
567 | b . | |
568 | #endif | |
569 | ||
b01c8b54 | 570 | .align 7 |
b3e6b5df | 571 | /* moved from 0xe00 */ |
1707dd16 | 572 | STD_EXCEPTION_HV_OOL(0xe02, h_data_storage) |
b01c8b54 | 573 | KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02) |
1707dd16 | 574 | STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage) |
b01c8b54 | 575 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22) |
1707dd16 | 576 | STD_EXCEPTION_HV_OOL(0xe42, emulation_assist) |
b01c8b54 | 577 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42) |
0869b6fd | 578 | MASKABLE_EXCEPTION_HV_OOL(0xe62, hmi_exception) |
b01c8b54 | 579 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62) |
0869b6fd | 580 | |
1707dd16 | 581 | MASKABLE_EXCEPTION_HV_OOL(0xe82, h_doorbell) |
655bb3f4 | 582 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe82) |
0ebc4cda BH |
583 | |
584 | /* moved from 0xf00 */ | |
1707dd16 | 585 | STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor) |
31a40e2b | 586 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf00) |
1707dd16 | 587 | STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable) |
31a40e2b | 588 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf20) |
1707dd16 | 589 | STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable) |
31a40e2b | 590 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf40) |
021424a1 | 591 | STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) |
31a40e2b | 592 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf60) |
b14b6260 ME |
593 | STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable) |
594 | KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82) | |
0ebc4cda BH |
595 | |
596 | /* | |
fe9e1d54 IM |
597 | * An interrupt came in while soft-disabled. We set paca->irq_happened, then: |
598 | * - If it was a decrementer interrupt, we bump the dec to max and and return. | |
599 | * - If it was a doorbell we return immediately since doorbells are edge | |
600 | * triggered and won't automatically refire. | |
0869b6fd MS |
601 | * - If it was a HMI we return immediately since we handled it in realmode |
602 | * and it won't refire. | |
fe9e1d54 IM |
603 | * - else we hard disable and return. |
604 | * This is called with r10 containing the value to OR to the paca field. | |
0ebc4cda | 605 | */ |
7230c564 BH |
606 | #define MASKED_INTERRUPT(_H) \ |
607 | masked_##_H##interrupt: \ | |
608 | std r11,PACA_EXGEN+EX_R11(r13); \ | |
609 | lbz r11,PACAIRQHAPPENED(r13); \ | |
610 | or r11,r11,r10; \ | |
611 | stb r11,PACAIRQHAPPENED(r13); \ | |
fe9e1d54 IM |
612 | cmpwi r10,PACA_IRQ_DEC; \ |
613 | bne 1f; \ | |
7230c564 BH |
614 | lis r10,0x7fff; \ |
615 | ori r10,r10,0xffff; \ | |
616 | mtspr SPRN_DEC,r10; \ | |
617 | b 2f; \ | |
fe9e1d54 | 618 | 1: cmpwi r10,PACA_IRQ_DBELL; \ |
0869b6fd MS |
619 | beq 2f; \ |
620 | cmpwi r10,PACA_IRQ_HMI; \ | |
fe9e1d54 IM |
621 | beq 2f; \ |
622 | mfspr r10,SPRN_##_H##SRR1; \ | |
7230c564 BH |
623 | rldicl r10,r10,48,1; /* clear MSR_EE */ \ |
624 | rotldi r10,r10,16; \ | |
625 | mtspr SPRN_##_H##SRR1,r10; \ | |
626 | 2: mtcrf 0x80,r9; \ | |
627 | ld r9,PACA_EXGEN+EX_R9(r13); \ | |
628 | ld r10,PACA_EXGEN+EX_R10(r13); \ | |
629 | ld r11,PACA_EXGEN+EX_R11(r13); \ | |
630 | GET_SCRATCH0(r13); \ | |
631 | ##_H##rfid; \ | |
0ebc4cda | 632 | b . |
7230c564 BH |
633 | |
634 | MASKED_INTERRUPT() | |
635 | MASKED_INTERRUPT(H) | |
0ebc4cda | 636 | |
7230c564 BH |
637 | /* |
638 | * Called from arch_local_irq_enable when an interrupt needs | |
fe9e1d54 IM |
639 | * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate |
640 | * which kind of interrupt. MSR:EE is already off. We generate a | |
7230c564 BH |
641 | * stackframe like if a real interrupt had happened. |
642 | * | |
643 | * Note: While MSR:EE is off, we need to make sure that _MSR | |
644 | * in the generated frame has EE set to 1 or the exception | |
645 | * handler will not properly re-enable them. | |
646 | */ | |
647 | _GLOBAL(__replay_interrupt) | |
648 | /* We are going to jump to the exception common code which | |
649 | * will retrieve various register values from the PACA which | |
650 | * we don't give a damn about, so we don't bother storing them. | |
651 | */ | |
652 | mfmsr r12 | |
653 | mflr r11 | |
654 | mfcr r9 | |
655 | ori r12,r12,MSR_EE | |
fe9e1d54 IM |
656 | cmpwi r3,0x900 |
657 | beq decrementer_common | |
658 | cmpwi r3,0x500 | |
659 | beq hardware_interrupt_common | |
660 | BEGIN_FTR_SECTION | |
661 | cmpwi r3,0xe80 | |
662 | beq h_doorbell_common | |
663 | FTR_SECTION_ELSE | |
664 | cmpwi r3,0xa00 | |
665 | beq doorbell_super_common | |
666 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) | |
667 | blr | |
a5d4f3ad | 668 | |
0ebc4cda BH |
669 | #ifdef CONFIG_PPC_PSERIES |
670 | /* | |
671 | * Vectors for the FWNMI option. Share common code. | |
672 | */ | |
673 | .globl system_reset_fwnmi | |
674 | .align 7 | |
675 | system_reset_fwnmi: | |
673b189a | 676 | SET_SCRATCH0(r13) /* save r13 */ |
b01c8b54 PM |
677 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, |
678 | NOTEST, 0x100) | |
0ebc4cda BH |
679 | |
680 | #endif /* CONFIG_PPC_PSERIES */ | |
681 | ||
4f6c11db PM |
682 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
683 | kvmppc_skip_interrupt: | |
684 | /* | |
685 | * Here all GPRs are unchanged from when the interrupt happened | |
686 | * except for r13, which is saved in SPRG_SCRATCH0. | |
687 | */ | |
688 | mfspr r13, SPRN_SRR0 | |
689 | addi r13, r13, 4 | |
690 | mtspr SPRN_SRR0, r13 | |
691 | GET_SCRATCH0(r13) | |
692 | rfid | |
693 | b . | |
694 | ||
695 | kvmppc_skip_Hinterrupt: | |
696 | /* | |
697 | * Here all GPRs are unchanged from when the interrupt happened | |
698 | * except for r13, which is saved in SPRG_SCRATCH0. | |
699 | */ | |
700 | mfspr r13, SPRN_HSRR0 | |
701 | addi r13, r13, 4 | |
702 | mtspr SPRN_HSRR0, r13 | |
703 | GET_SCRATCH0(r13) | |
704 | hrfid | |
705 | b . | |
706 | #endif | |
707 | ||
0ebc4cda | 708 | /* |
057b6d7e HB |
709 | * Ensure that any handlers that get invoked from the exception prologs |
710 | * above are below the first 64KB (0x10000) of the kernel image because | |
711 | * the prologs assemble the addresses of these handlers using the | |
712 | * LOAD_HANDLER macro, which uses an ori instruction. | |
0ebc4cda BH |
713 | */ |
714 | ||
715 | /*** Common interrupt handlers ***/ | |
716 | ||
35425501 | 717 | STD_EXCEPTION_COMMON(0x100, system_reset, system_reset_exception) |
0ebc4cda | 718 | |
7450f6f0 | 719 | STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ) |
35425501 AB |
720 | STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, timer_interrupt) |
721 | STD_EXCEPTION_COMMON(0x980, hdecrementer, hdec_interrupt) | |
1dbdafec | 722 | #ifdef CONFIG_PPC_DOORBELL |
35425501 | 723 | STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, doorbell_exception) |
1dbdafec | 724 | #else |
35425501 | 725 | STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, unknown_exception) |
1dbdafec | 726 | #endif |
35425501 AB |
727 | STD_EXCEPTION_COMMON(0xb00, trap_0b, unknown_exception) |
728 | STD_EXCEPTION_COMMON(0xd00, single_step, single_step_exception) | |
729 | STD_EXCEPTION_COMMON(0xe00, trap_0e, unknown_exception) | |
730 | STD_EXCEPTION_COMMON(0xe40, emulation_assist, emulation_assist_interrupt) | |
0869b6fd | 731 | STD_EXCEPTION_COMMON_ASYNC(0xe60, hmi_exception, handle_hmi_exception) |
655bb3f4 | 732 | #ifdef CONFIG_PPC_DOORBELL |
35425501 | 733 | STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, doorbell_exception) |
655bb3f4 | 734 | #else |
35425501 | 735 | STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, unknown_exception) |
655bb3f4 | 736 | #endif |
35425501 AB |
737 | STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, performance_monitor_exception) |
738 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, instruction_breakpoint_exception) | |
739 | STD_EXCEPTION_COMMON(0x1502, denorm, unknown_exception) | |
0ebc4cda | 740 | #ifdef CONFIG_ALTIVEC |
35425501 | 741 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, altivec_assist_exception) |
0ebc4cda | 742 | #else |
35425501 | 743 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, unknown_exception) |
0ebc4cda BH |
744 | #endif |
745 | #ifdef CONFIG_CBE_RAS | |
35425501 AB |
746 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, cbe_system_error_exception) |
747 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, cbe_maintenance_exception) | |
748 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, cbe_thermal_exception) | |
0ebc4cda BH |
749 | #endif /* CONFIG_CBE_RAS */ |
750 | ||
c1fb6816 MN |
751 | /* |
752 | * Relocation-on interrupts: A subset of the interrupts can be delivered | |
753 | * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering | |
754 | * it. Addresses are the same as the original interrupt addresses, but | |
755 | * offset by 0xc000000000004000. | |
756 | * It's impossible to receive interrupts below 0x300 via this mechanism. | |
757 | * KVM: None of these traps are from the guest ; anything that escalated | |
758 | * to HV=1 from HV=0 is delivered via real mode handlers. | |
759 | */ | |
760 | ||
761 | /* | |
762 | * This uses the standard macro, since the original 0x300 vector | |
763 | * only has extra guff for STAB-based processors -- which never | |
764 | * come here. | |
765 | */ | |
766 | STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access) | |
767 | . = 0x4380 | |
768 | .globl data_access_slb_relon_pSeries | |
769 | data_access_slb_relon_pSeries: | |
c1fb6816 | 770 | SET_SCRATCH0(r13) |
1707dd16 | 771 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
c1fb6816 MN |
772 | EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380) |
773 | std r3,PACA_EXSLB+EX_R3(r13) | |
774 | mfspr r3,SPRN_DAR | |
775 | mfspr r12,SPRN_SRR1 | |
776 | #ifndef CONFIG_RELOCATABLE | |
b1576fec | 777 | b slb_miss_realmode |
c1fb6816 MN |
778 | #else |
779 | /* | |
ad0289e4 | 780 | * We can't just use a direct branch to slb_miss_realmode |
c1fb6816 MN |
781 | * because the distance from here to there depends on where |
782 | * the kernel ends up being put. | |
783 | */ | |
784 | mfctr r11 | |
785 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 786 | LOAD_HANDLER(r10, slb_miss_realmode) |
c1fb6816 MN |
787 | mtctr r10 |
788 | bctr | |
789 | #endif | |
790 | ||
791 | STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access) | |
792 | . = 0x4480 | |
793 | .globl instruction_access_slb_relon_pSeries | |
794 | instruction_access_slb_relon_pSeries: | |
c1fb6816 | 795 | SET_SCRATCH0(r13) |
1707dd16 | 796 | EXCEPTION_PROLOG_0(PACA_EXSLB) |
c1fb6816 MN |
797 | EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480) |
798 | std r3,PACA_EXSLB+EX_R3(r13) | |
799 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ | |
800 | mfspr r12,SPRN_SRR1 | |
801 | #ifndef CONFIG_RELOCATABLE | |
b1576fec | 802 | b slb_miss_realmode |
c1fb6816 MN |
803 | #else |
804 | mfctr r11 | |
805 | ld r10,PACAKBASE(r13) | |
ad0289e4 | 806 | LOAD_HANDLER(r10, slb_miss_realmode) |
c1fb6816 MN |
807 | mtctr r10 |
808 | bctr | |
809 | #endif | |
810 | ||
811 | . = 0x4500 | |
812 | .globl hardware_interrupt_relon_pSeries; | |
813 | .globl hardware_interrupt_relon_hv; | |
814 | hardware_interrupt_relon_pSeries: | |
815 | hardware_interrupt_relon_hv: | |
816 | BEGIN_FTR_SECTION | |
817 | _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV) | |
818 | FTR_SECTION_ELSE | |
819 | _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR) | |
3e96ca7f | 820 | ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) |
c1fb6816 MN |
821 | STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment) |
822 | STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check) | |
823 | STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable) | |
824 | MASKABLE_RELON_EXCEPTION_PSERIES(0x4900, 0x900, decrementer) | |
825 | STD_RELON_EXCEPTION_HV(0x4980, 0x982, hdecrementer) | |
1dbdafec | 826 | MASKABLE_RELON_EXCEPTION_PSERIES(0x4a00, 0xa00, doorbell_super) |
c1fb6816 MN |
827 | STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b) |
828 | ||
829 | . = 0x4c00 | |
830 | .globl system_call_relon_pSeries | |
831 | system_call_relon_pSeries: | |
832 | HMT_MEDIUM | |
833 | SYSCALL_PSERIES_1 | |
834 | SYSCALL_PSERIES_2_DIRECT | |
835 | SYSCALL_PSERIES_3 | |
836 | ||
837 | STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step) | |
838 | ||
839 | . = 0x4e00 | |
1d567cb4 | 840 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 MN |
841 | |
842 | . = 0x4e20 | |
1d567cb4 | 843 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 MN |
844 | |
845 | . = 0x4e40 | |
d671ddd6 | 846 | emulation_assist_relon_trampoline: |
1707dd16 PM |
847 | SET_SCRATCH0(r13) |
848 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
849 | b emulation_assist_relon_hv |
850 | ||
c1fb6816 | 851 | . = 0x4e60 |
1d567cb4 | 852 | b . /* Can't happen, see v2.07 Book III-S section 6.5 */ |
c1fb6816 | 853 | |
655bb3f4 | 854 | . = 0x4e80 |
d671ddd6 | 855 | h_doorbell_relon_trampoline: |
1707dd16 PM |
856 | SET_SCRATCH0(r13) |
857 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
655bb3f4 | 858 | b h_doorbell_relon_hv |
c1fb6816 | 859 | |
c1fb6816 | 860 | . = 0x4f00 |
fa111f1f | 861 | performance_monitor_relon_pseries_trampoline: |
1707dd16 PM |
862 | SET_SCRATCH0(r13) |
863 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
864 | b performance_monitor_relon_pSeries |
865 | ||
c1fb6816 | 866 | . = 0x4f20 |
fa111f1f | 867 | altivec_unavailable_relon_pseries_trampoline: |
1707dd16 PM |
868 | SET_SCRATCH0(r13) |
869 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
870 | b altivec_unavailable_relon_pSeries |
871 | ||
c1fb6816 | 872 | . = 0x4f40 |
fa111f1f | 873 | vsx_unavailable_relon_pseries_trampoline: |
1707dd16 PM |
874 | SET_SCRATCH0(r13) |
875 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
c1fb6816 MN |
876 | b vsx_unavailable_relon_pSeries |
877 | ||
d0c0c9a1 | 878 | . = 0x4f60 |
fa111f1f | 879 | facility_unavailable_relon_trampoline: |
d0c0c9a1 MN |
880 | SET_SCRATCH0(r13) |
881 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
021424a1 | 882 | b facility_unavailable_relon_pSeries |
d0c0c9a1 | 883 | |
b14b6260 | 884 | . = 0x4f80 |
fa111f1f | 885 | hv_facility_unavailable_relon_trampoline: |
b14b6260 ME |
886 | SET_SCRATCH0(r13) |
887 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
88f09412 | 888 | b hv_facility_unavailable_relon_hv |
b14b6260 | 889 | |
c1fb6816 MN |
890 | STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint) |
891 | #ifdef CONFIG_PPC_DENORMALISATION | |
892 | . = 0x5500 | |
893 | b denorm_exception_hv | |
894 | #endif | |
c1fb6816 | 895 | STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist) |
c1fb6816 | 896 | |
0ebc4cda BH |
897 | .align 7 |
898 | system_call_entry: | |
899 | b system_call_common | |
900 | ||
fe1952fc | 901 | ppc64_runlatch_on_trampoline: |
b1576fec | 902 | b __ppc64_runlatch_on |
fe1952fc | 903 | |
0ebc4cda BH |
904 | /* |
905 | * Here r13 points to the paca, r9 contains the saved CR, | |
906 | * SRR0 and SRR1 are saved in r11 and r12, | |
907 | * r9 - r13 are saved in paca->exgen. | |
908 | */ | |
909 | .align 7 | |
910 | .globl data_access_common | |
911 | data_access_common: | |
912 | mfspr r10,SPRN_DAR | |
913 | std r10,PACA_EXGEN+EX_DAR(r13) | |
914 | mfspr r10,SPRN_DSISR | |
915 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
916 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) | |
9daf112b | 917 | RECONCILE_IRQ_STATE(r10, r11) |
a546498f | 918 | ld r12,_MSR(r1) |
0ebc4cda BH |
919 | ld r3,PACA_EXGEN+EX_DAR(r13) |
920 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
921 | li r5,0x300 | |
caca285e AK |
922 | std r3,_DAR(r1) |
923 | std r4,_DSISR(r1) | |
924 | BEGIN_MMU_FTR_SECTION | |
b1576fec | 925 | b do_hash_page /* Try to handle as hpte fault */ |
caca285e AK |
926 | MMU_FTR_SECTION_ELSE |
927 | b handle_page_fault | |
928 | ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) | |
0ebc4cda | 929 | |
b3e6b5df | 930 | .align 7 |
278a6cdc | 931 | .globl h_data_storage_common |
b3e6b5df | 932 | h_data_storage_common: |
278a6cdc MN |
933 | mfspr r10,SPRN_HDAR |
934 | std r10,PACA_EXGEN+EX_DAR(r13) | |
935 | mfspr r10,SPRN_HDSISR | |
936 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
937 | EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN) | |
b1576fec | 938 | bl save_nvgprs |
9daf112b | 939 | RECONCILE_IRQ_STATE(r10, r11) |
278a6cdc | 940 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
941 | bl unknown_exception |
942 | b ret_from_except | |
b3e6b5df | 943 | |
0ebc4cda BH |
944 | .align 7 |
945 | .globl instruction_access_common | |
946 | instruction_access_common: | |
947 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) | |
9daf112b | 948 | RECONCILE_IRQ_STATE(r10, r11) |
a546498f | 949 | ld r12,_MSR(r1) |
0ebc4cda BH |
950 | ld r3,_NIP(r1) |
951 | andis. r4,r12,0x5820 | |
952 | li r5,0x400 | |
caca285e AK |
953 | std r3,_DAR(r1) |
954 | std r4,_DSISR(r1) | |
955 | BEGIN_MMU_FTR_SECTION | |
b1576fec | 956 | b do_hash_page /* Try to handle as hpte fault */ |
caca285e AK |
957 | MMU_FTR_SECTION_ELSE |
958 | b handle_page_fault | |
959 | ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) | |
0ebc4cda | 960 | |
35425501 | 961 | STD_EXCEPTION_COMMON(0xe20, h_instr_storage, unknown_exception) |
b3e6b5df | 962 | |
4e243b79 MS |
963 | /* |
964 | * Machine check is different because we use a different | |
965 | * save area: PACA_EXMC instead of PACA_EXGEN. | |
966 | */ | |
967 | .align 7 | |
968 | .globl machine_check_common | |
969 | machine_check_common: | |
970 | ||
971 | mfspr r10,SPRN_DAR | |
972 | std r10,PACA_EXGEN+EX_DAR(r13) | |
973 | mfspr r10,SPRN_DSISR | |
974 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
975 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) | |
976 | FINISH_NAP | |
9daf112b | 977 | RECONCILE_IRQ_STATE(r10, r11) |
4e243b79 MS |
978 | ld r3,PACA_EXGEN+EX_DAR(r13) |
979 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
980 | std r3,_DAR(r1) | |
981 | std r4,_DSISR(r1) | |
b1576fec | 982 | bl save_nvgprs |
4e243b79 | 983 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
984 | bl machine_check_exception |
985 | b ret_from_except | |
4e243b79 | 986 | |
0ebc4cda BH |
987 | .align 7 |
988 | .globl alignment_common | |
989 | alignment_common: | |
990 | mfspr r10,SPRN_DAR | |
991 | std r10,PACA_EXGEN+EX_DAR(r13) | |
992 | mfspr r10,SPRN_DSISR | |
993 | stw r10,PACA_EXGEN+EX_DSISR(r13) | |
994 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) | |
995 | ld r3,PACA_EXGEN+EX_DAR(r13) | |
996 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
997 | std r3,_DAR(r1) | |
998 | std r4,_DSISR(r1) | |
b1576fec | 999 | bl save_nvgprs |
9daf112b | 1000 | RECONCILE_IRQ_STATE(r10, r11) |
0ebc4cda | 1001 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1002 | bl alignment_exception |
1003 | b ret_from_except | |
0ebc4cda BH |
1004 | |
1005 | .align 7 | |
1006 | .globl program_check_common | |
1007 | program_check_common: | |
1008 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) | |
b1576fec | 1009 | bl save_nvgprs |
9daf112b | 1010 | RECONCILE_IRQ_STATE(r10, r11) |
922b9f86 | 1011 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1012 | bl program_check_exception |
1013 | b ret_from_except | |
0ebc4cda BH |
1014 | |
1015 | .align 7 | |
1016 | .globl fp_unavailable_common | |
1017 | fp_unavailable_common: | |
1018 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) | |
1019 | bne 1f /* if from user, just load it up */ | |
b1576fec | 1020 | bl save_nvgprs |
9daf112b | 1021 | RECONCILE_IRQ_STATE(r10, r11) |
0ebc4cda | 1022 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1023 | bl kernel_fp_unavailable_exception |
0ebc4cda | 1024 | BUG_OPCODE |
bc2a9408 MN |
1025 | 1: |
1026 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | |
1027 | BEGIN_FTR_SECTION | |
1028 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1029 | * transaction), go do TM stuff | |
1030 | */ | |
1031 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1032 | bne- 2f | |
1033 | END_FTR_SECTION_IFSET(CPU_FTR_TM) | |
1034 | #endif | |
b1576fec | 1035 | bl load_up_fpu |
0ebc4cda | 1036 | b fast_exception_return |
bc2a9408 MN |
1037 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1038 | 2: /* User process was in a transaction */ | |
b1576fec | 1039 | bl save_nvgprs |
9daf112b | 1040 | RECONCILE_IRQ_STATE(r10, r11) |
bc2a9408 | 1041 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1042 | bl fp_unavailable_tm |
1043 | b ret_from_except | |
bc2a9408 | 1044 | #endif |
0ebc4cda BH |
1045 | .align 7 |
1046 | .globl altivec_unavailable_common | |
1047 | altivec_unavailable_common: | |
1048 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) | |
1049 | #ifdef CONFIG_ALTIVEC | |
1050 | BEGIN_FTR_SECTION | |
1051 | beq 1f | |
bc2a9408 MN |
1052 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1053 | BEGIN_FTR_SECTION_NESTED(69) | |
1054 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1055 | * transaction), go do TM stuff | |
1056 | */ | |
1057 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1058 | bne- 2f | |
1059 | END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69) | |
1060 | #endif | |
b1576fec | 1061 | bl load_up_altivec |
0ebc4cda | 1062 | b fast_exception_return |
bc2a9408 MN |
1063 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1064 | 2: /* User process was in a transaction */ | |
b1576fec | 1065 | bl save_nvgprs |
9daf112b | 1066 | RECONCILE_IRQ_STATE(r10, r11) |
bc2a9408 | 1067 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1068 | bl altivec_unavailable_tm |
1069 | b ret_from_except | |
bc2a9408 | 1070 | #endif |
0ebc4cda BH |
1071 | 1: |
1072 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) | |
1073 | #endif | |
b1576fec | 1074 | bl save_nvgprs |
9daf112b | 1075 | RECONCILE_IRQ_STATE(r10, r11) |
0ebc4cda | 1076 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1077 | bl altivec_unavailable_exception |
1078 | b ret_from_except | |
0ebc4cda BH |
1079 | |
1080 | .align 7 | |
1081 | .globl vsx_unavailable_common | |
1082 | vsx_unavailable_common: | |
1083 | EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN) | |
1084 | #ifdef CONFIG_VSX | |
1085 | BEGIN_FTR_SECTION | |
7230c564 | 1086 | beq 1f |
bc2a9408 MN |
1087 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1088 | BEGIN_FTR_SECTION_NESTED(69) | |
1089 | /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in | |
1090 | * transaction), go do TM stuff | |
1091 | */ | |
1092 | rldicl. r0, r12, (64-MSR_TS_LG), (64-2) | |
1093 | bne- 2f | |
1094 | END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69) | |
1095 | #endif | |
b1576fec | 1096 | b load_up_vsx |
bc2a9408 MN |
1097 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
1098 | 2: /* User process was in a transaction */ | |
b1576fec | 1099 | bl save_nvgprs |
9daf112b | 1100 | RECONCILE_IRQ_STATE(r10, r11) |
bc2a9408 | 1101 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1102 | bl vsx_unavailable_tm |
1103 | b ret_from_except | |
bc2a9408 | 1104 | #endif |
0ebc4cda BH |
1105 | 1: |
1106 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) | |
1107 | #endif | |
b1576fec | 1108 | bl save_nvgprs |
9daf112b | 1109 | RECONCILE_IRQ_STATE(r10, r11) |
0ebc4cda | 1110 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec AB |
1111 | bl vsx_unavailable_exception |
1112 | b ret_from_except | |
0ebc4cda | 1113 | |
35425501 AB |
1114 | STD_EXCEPTION_COMMON(0xf60, facility_unavailable, facility_unavailable_exception) |
1115 | STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, facility_unavailable_exception) | |
d0c0c9a1 | 1116 | |
61383407 | 1117 | /* Equivalents to the above handlers for relocation-on interrupt vectors */ |
1707dd16 | 1118 | STD_RELON_EXCEPTION_HV_OOL(0xe40, emulation_assist) |
1707dd16 | 1119 | MASKABLE_RELON_EXCEPTION_HV_OOL(0xe80, h_doorbell) |
61383407 | 1120 | |
1707dd16 PM |
1121 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor) |
1122 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable) | |
1123 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable) | |
021424a1 | 1124 | STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) |
88f09412 | 1125 | STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable) |
61383407 | 1126 | |
8ed8ab40 HB |
1127 | /* |
1128 | * The __end_interrupts marker must be past the out-of-line (OOL) | |
1129 | * handlers, so that they are copied to real address 0x100 when running | |
1130 | * a relocatable kernel. This ensures they can be reached from the short | |
1131 | * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch | |
1132 | * directly, without using LOAD_HANDLER(). | |
1133 | */ | |
1134 | .align 7 | |
1135 | .globl __end_interrupts | |
1136 | __end_interrupts: | |
1137 | ||
61383407 BH |
1138 | #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) |
1139 | /* | |
1140 | * Data area reserved for FWNMI option. | |
1141 | * This address (0x7000) is fixed by the RPA. | |
1142 | */ | |
1143 | .= 0x7000 | |
1144 | .globl fwnmi_data_area | |
1145 | fwnmi_data_area: | |
1146 | ||
1147 | /* pseries and powernv need to keep the whole page from | |
1148 | * 0x7000 to 0x8000 free for use by the firmware | |
1149 | */ | |
1150 | . = 0x8000 | |
1151 | #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ | |
1152 | ||
11d54904 GR |
1153 | .globl hmi_exception_early |
1154 | hmi_exception_early: | |
1155 | EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0xe60) | |
1156 | mr r10,r1 /* Save r1 */ | |
1157 | ld r1,PACAEMERGSP(r13) /* Use emergency stack */ | |
1158 | subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ | |
1159 | std r9,_CCR(r1) /* save CR in stackframe */ | |
1160 | mfspr r11,SPRN_HSRR0 /* Save HSRR0 */ | |
1161 | std r11,_NIP(r1) /* save HSRR0 in stackframe */ | |
1162 | mfspr r12,SPRN_HSRR1 /* Save SRR1 */ | |
1163 | std r12,_MSR(r1) /* save SRR1 in stackframe */ | |
1164 | std r10,0(r1) /* make stack chain pointer */ | |
1165 | std r0,GPR0(r1) /* save r0 in stackframe */ | |
1166 | std r10,GPR1(r1) /* save r1 in stackframe */ | |
1167 | EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN) | |
1168 | EXCEPTION_PROLOG_COMMON_3(0xe60) | |
1169 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1170 | bl hmi_exception_realmode | |
1171 | /* Windup the stack. */ | |
11d54904 GR |
1172 | /* Move original HSRR0 and HSRR1 into the respective regs */ |
1173 | ld r9,_MSR(r1) | |
1174 | mtspr SPRN_HSRR1,r9 | |
1175 | ld r3,_NIP(r1) | |
1176 | mtspr SPRN_HSRR0,r3 | |
1177 | ld r9,_CTR(r1) | |
1178 | mtctr r9 | |
1179 | ld r9,_XER(r1) | |
1180 | mtxer r9 | |
1181 | ld r9,_LINK(r1) | |
1182 | mtlr r9 | |
1183 | REST_GPR(0, r1) | |
1184 | REST_8GPRS(2, r1) | |
1185 | REST_GPR(10, r1) | |
1186 | ld r11,_CCR(r1) | |
1187 | mtcr r11 | |
1188 | REST_GPR(11, r1) | |
1189 | REST_2GPRS(12, r1) | |
1190 | /* restore original r1. */ | |
1191 | ld r1,GPR1(r1) | |
1192 | ||
1193 | /* | |
1194 | * Go to virtual mode and pull the HMI event information from | |
1195 | * firmware. | |
1196 | */ | |
1197 | .globl hmi_exception_after_realmode | |
1198 | hmi_exception_after_realmode: | |
1199 | SET_SCRATCH0(r13) | |
1200 | EXCEPTION_PROLOG_0(PACA_EXGEN) | |
1201 | b hmi_exception_hv | |
1202 | ||
61383407 | 1203 | |
4e243b79 MS |
1204 | #define MACHINE_CHECK_HANDLER_WINDUP \ |
1205 | /* Clear MSR_RI before setting SRR0 and SRR1. */\ | |
1206 | li r0,MSR_RI; \ | |
1207 | mfmsr r9; /* get MSR value */ \ | |
1208 | andc r9,r9,r0; \ | |
1209 | mtmsrd r9,1; /* Clear MSR_RI */ \ | |
1210 | /* Move original SRR0 and SRR1 into the respective regs */ \ | |
1211 | ld r9,_MSR(r1); \ | |
1212 | mtspr SPRN_SRR1,r9; \ | |
1213 | ld r3,_NIP(r1); \ | |
1214 | mtspr SPRN_SRR0,r3; \ | |
1215 | ld r9,_CTR(r1); \ | |
1216 | mtctr r9; \ | |
1217 | ld r9,_XER(r1); \ | |
1218 | mtxer r9; \ | |
1219 | ld r9,_LINK(r1); \ | |
1220 | mtlr r9; \ | |
1221 | REST_GPR(0, r1); \ | |
1222 | REST_8GPRS(2, r1); \ | |
1223 | REST_GPR(10, r1); \ | |
1224 | ld r11,_CCR(r1); \ | |
1225 | mtcr r11; \ | |
1226 | /* Decrement paca->in_mce. */ \ | |
1227 | lhz r12,PACA_IN_MCE(r13); \ | |
1228 | subi r12,r12,1; \ | |
1229 | sth r12,PACA_IN_MCE(r13); \ | |
1230 | REST_GPR(11, r1); \ | |
1231 | REST_2GPRS(12, r1); \ | |
1232 | /* restore original r1. */ \ | |
1233 | ld r1,GPR1(r1) | |
1234 | ||
1235 | /* | |
1236 | * Handle machine check early in real mode. We come here with | |
1237 | * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack. | |
1238 | */ | |
1239 | .align 7 | |
1240 | .globl machine_check_handle_early | |
1241 | machine_check_handle_early: | |
1242 | std r0,GPR0(r1) /* Save r0 */ | |
1243 | EXCEPTION_PROLOG_COMMON_3(0x200) | |
b1576fec | 1244 | bl save_nvgprs |
4e243b79 | 1245 | addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1246 | bl machine_check_early |
2749a2f2 | 1247 | std r3,RESULT(r1) /* Save result */ |
4e243b79 MS |
1248 | ld r12,_MSR(r1) |
1249 | #ifdef CONFIG_PPC_P7_NAP | |
1250 | /* | |
1251 | * Check if thread was in power saving mode. We come here when any | |
1252 | * of the following is true: | |
1253 | * a. thread wasn't in power saving mode | |
1254 | * b. thread was in power saving mode with no state loss or | |
1255 | * supervisor state loss | |
1256 | * | |
1257 | * Go back to nap again if (b) is true. | |
1258 | */ | |
1259 | rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */ | |
1260 | beq 4f /* No, it wasn;t */ | |
1261 | /* Thread was in power saving mode. Go back to nap again. */ | |
1262 | cmpwi r11,2 | |
1263 | bne 3f | |
1264 | /* Supervisor state loss */ | |
1265 | li r0,1 | |
1266 | stb r0,PACA_NAPSTATELOST(r13) | |
b1576fec | 1267 | 3: bl machine_check_queue_event |
4e243b79 MS |
1268 | MACHINE_CHECK_HANDLER_WINDUP |
1269 | GET_PACA(r13) | |
1270 | ld r1,PACAR1(r13) | |
7cba160a | 1271 | li r3,PNV_THREAD_NAP |
b1576fec | 1272 | b power7_enter_nap_mode |
4e243b79 MS |
1273 | 4: |
1274 | #endif | |
1275 | /* | |
1276 | * Check if we are coming from hypervisor userspace. If yes then we | |
1277 | * continue in host kernel in V mode to deliver the MC event. | |
1278 | */ | |
1279 | rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */ | |
1280 | beq 5f | |
1281 | andi. r11,r12,MSR_PR /* See if coming from user. */ | |
1282 | bne 9f /* continue in V mode if we are. */ | |
1283 | ||
1284 | 5: | |
44d5f6f5 | 1285 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
4e243b79 MS |
1286 | /* |
1287 | * We are coming from kernel context. Check if we are coming from | |
1288 | * guest. if yes, then we can continue. We will fall through | |
1289 | * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest. | |
1290 | */ | |
1291 | lbz r11,HSTATE_IN_GUEST(r13) | |
1292 | cmpwi r11,0 /* Check if coming from guest */ | |
1293 | bne 9f /* continue if we are. */ | |
1294 | #endif | |
1295 | /* | |
1296 | * At this point we are not sure about what context we come from. | |
1297 | * Queue up the MCE event and return from the interrupt. | |
1298 | * But before that, check if this is an un-recoverable exception. | |
1299 | * If yes, then stay on emergency stack and panic. | |
1300 | */ | |
1301 | andi. r11,r12,MSR_RI | |
1302 | bne 2f | |
2749a2f2 MS |
1303 | 1: mfspr r11,SPRN_SRR0 |
1304 | ld r10,PACAKBASE(r13) | |
1305 | LOAD_HANDLER(r10,unrecover_mce) | |
1306 | mtspr SPRN_SRR0,r10 | |
1307 | ld r10,PACAKMSR(r13) | |
1308 | /* | |
1309 | * We are going down. But there are chances that we might get hit by | |
1310 | * another MCE during panic path and we may run into unstable state | |
1311 | * with no way out. Hence, turn ME bit off while going down, so that | |
1312 | * when another MCE is hit during panic path, system will checkstop | |
1313 | * and hypervisor will get restarted cleanly by SP. | |
1314 | */ | |
1315 | li r3,MSR_ME | |
1316 | andc r10,r10,r3 /* Turn off MSR_ME */ | |
1317 | mtspr SPRN_SRR1,r10 | |
1318 | rfid | |
1319 | b . | |
4e243b79 | 1320 | 2: |
2749a2f2 MS |
1321 | /* |
1322 | * Check if we have successfully handled/recovered from error, if not | |
1323 | * then stay on emergency stack and panic. | |
1324 | */ | |
1325 | ld r3,RESULT(r1) /* Load result */ | |
1326 | cmpdi r3,0 /* see if we handled MCE successfully */ | |
1327 | ||
1328 | beq 1b /* if !handled then panic */ | |
4e243b79 MS |
1329 | /* |
1330 | * Return from MC interrupt. | |
1331 | * Queue up the MCE event so that we can log it later, while | |
1332 | * returning from kernel or opal call. | |
1333 | */ | |
b1576fec | 1334 | bl machine_check_queue_event |
4e243b79 MS |
1335 | MACHINE_CHECK_HANDLER_WINDUP |
1336 | rfid | |
1337 | 9: | |
1338 | /* Deliver the machine check to host kernel in V mode. */ | |
1339 | MACHINE_CHECK_HANDLER_WINDUP | |
1340 | b machine_check_pSeries | |
1341 | ||
2749a2f2 MS |
1342 | unrecover_mce: |
1343 | /* Invoke machine_check_exception to print MCE event and panic. */ | |
1344 | addi r3,r1,STACK_FRAME_OVERHEAD | |
ad718622 | 1345 | bl machine_check_exception |
2749a2f2 MS |
1346 | /* |
1347 | * We will not reach here. Even if we did, there is no way out. Call | |
1348 | * unrecoverable_exception and die. | |
1349 | */ | |
1350 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
ad718622 | 1351 | bl unrecoverable_exception |
2749a2f2 | 1352 | b 1b |
087aa036 CG |
1353 | /* |
1354 | * r13 points to the PACA, r9 contains the saved CR, | |
1355 | * r12 contain the saved SRR1, SRR0 is still ready for return | |
1356 | * r3 has the faulting address | |
1357 | * r9 - r13 are saved in paca->exslb. | |
1358 | * r3 is saved in paca->slb_r3 | |
1359 | * We assume we aren't going to take any exceptions during this procedure. | |
1360 | */ | |
ad0289e4 | 1361 | slb_miss_realmode: |
087aa036 CG |
1362 | mflr r10 |
1363 | #ifdef CONFIG_RELOCATABLE | |
1364 | mtctr r11 | |
1365 | #endif | |
1366 | ||
1367 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ | |
1368 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ | |
1369 | ||
caca285e AK |
1370 | #ifdef CONFIG_PPC_STD_MMU_64 |
1371 | BEGIN_MMU_FTR_SECTION | |
b1576fec | 1372 | bl slb_allocate_realmode |
caca285e AK |
1373 | END_MMU_FTR_SECTION_IFCLR(MMU_FTR_RADIX) |
1374 | #endif | |
087aa036 CG |
1375 | /* All done -- return from exception. */ |
1376 | ||
1377 | ld r10,PACA_EXSLB+EX_LR(r13) | |
1378 | ld r3,PACA_EXSLB+EX_R3(r13) | |
1379 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ | |
1380 | ||
1381 | mtlr r10 | |
087aa036 | 1382 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
6e914ee6 | 1383 | BEGIN_MMU_FTR_SECTION |
087aa036 | 1384 | beq- 2f |
6e914ee6 ME |
1385 | FTR_SECTION_ELSE |
1386 | b 2f | |
1387 | ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_RADIX) | |
087aa036 CG |
1388 | |
1389 | .machine push | |
1390 | .machine "power4" | |
1391 | mtcrf 0x80,r9 | |
1392 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ | |
1393 | .machine pop | |
1394 | ||
1395 | RESTORE_PPR_PACA(PACA_EXSLB, r9) | |
1396 | ld r9,PACA_EXSLB+EX_R9(r13) | |
1397 | ld r10,PACA_EXSLB+EX_R10(r13) | |
1398 | ld r11,PACA_EXSLB+EX_R11(r13) | |
1399 | ld r12,PACA_EXSLB+EX_R12(r13) | |
1400 | ld r13,PACA_EXSLB+EX_R13(r13) | |
1401 | rfid | |
1402 | b . /* prevent speculative execution */ | |
1403 | ||
1404 | 2: mfspr r11,SPRN_SRR0 | |
1405 | ld r10,PACAKBASE(r13) | |
1406 | LOAD_HANDLER(r10,unrecov_slb) | |
1407 | mtspr SPRN_SRR0,r10 | |
1408 | ld r10,PACAKMSR(r13) | |
1409 | mtspr SPRN_SRR1,r10 | |
1410 | rfid | |
1411 | b . | |
1412 | ||
1413 | unrecov_slb: | |
1414 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) | |
9daf112b | 1415 | RECONCILE_IRQ_STATE(r10, r11) |
b1576fec | 1416 | bl save_nvgprs |
087aa036 | 1417 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
b1576fec | 1418 | bl unrecoverable_exception |
087aa036 CG |
1419 | b 1b |
1420 | ||
1421 | ||
1422 | #ifdef CONFIG_PPC_970_NAP | |
1423 | power4_fixup_nap: | |
1424 | andc r9,r9,r10 | |
1425 | std r9,TI_LOCAL_FLAGS(r11) | |
1426 | ld r10,_LINK(r1) /* make idle task do the */ | |
1427 | std r10,_NIP(r1) /* equivalent of a blr */ | |
1428 | blr | |
1429 | #endif | |
1430 | ||
0ebc4cda BH |
1431 | /* |
1432 | * Hash table stuff | |
1433 | */ | |
1434 | .align 7 | |
6a3bab90 | 1435 | do_hash_page: |
caca285e | 1436 | #ifdef CONFIG_PPC_STD_MMU_64 |
9c7cc234 | 1437 | andis. r0,r4,0xa410 /* weird error? */ |
0ebc4cda | 1438 | bne- handle_page_fault /* if not, try to insert a HPTE */ |
9c7cc234 P |
1439 | andis. r0,r4,DSISR_DABRMATCH@h |
1440 | bne- handle_dabr_fault | |
9778b696 | 1441 | CURRENT_THREAD_INFO(r11, r1) |
9c1e1052 PM |
1442 | lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */ |
1443 | andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */ | |
1444 | bne 77f /* then don't call hash_page now */ | |
0ebc4cda BH |
1445 | |
1446 | /* | |
1447 | * r3 contains the faulting address | |
106713a1 | 1448 | * r4 msr |
0ebc4cda | 1449 | * r5 contains the trap number |
aefa5688 | 1450 | * r6 contains dsisr |
0ebc4cda | 1451 | * |
7230c564 | 1452 | * at return r3 = 0 for success, 1 for page fault, negative for error |
0ebc4cda | 1453 | */ |
106713a1 | 1454 | mr r4,r12 |
aefa5688 | 1455 | ld r6,_DSISR(r1) |
106713a1 AK |
1456 | bl __hash_page /* build HPTE if possible */ |
1457 | cmpdi r3,0 /* see if __hash_page succeeded */ | |
0ebc4cda | 1458 | |
7230c564 | 1459 | /* Success */ |
0ebc4cda | 1460 | beq fast_exc_return_irq /* Return from exception on success */ |
0ebc4cda | 1461 | |
7230c564 BH |
1462 | /* Error */ |
1463 | blt- 13f | |
caca285e | 1464 | #endif /* CONFIG_PPC_STD_MMU_64 */ |
9c7cc234 | 1465 | |
0ebc4cda BH |
1466 | /* Here we have a page fault that hash_page can't handle. */ |
1467 | handle_page_fault: | |
0ebc4cda BH |
1468 | 11: ld r4,_DAR(r1) |
1469 | ld r5,_DSISR(r1) | |
1470 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec | 1471 | bl do_page_fault |
0ebc4cda | 1472 | cmpdi r3,0 |
a546498f | 1473 | beq+ 12f |
b1576fec | 1474 | bl save_nvgprs |
0ebc4cda BH |
1475 | mr r5,r3 |
1476 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1477 | lwz r4,_DAR(r1) | |
b1576fec AB |
1478 | bl bad_page_fault |
1479 | b ret_from_except | |
0ebc4cda | 1480 | |
a546498f BH |
1481 | /* We have a data breakpoint exception - handle it */ |
1482 | handle_dabr_fault: | |
b1576fec | 1483 | bl save_nvgprs |
a546498f BH |
1484 | ld r4,_DAR(r1) |
1485 | ld r5,_DSISR(r1) | |
1486 | addi r3,r1,STACK_FRAME_OVERHEAD | |
b1576fec AB |
1487 | bl do_break |
1488 | 12: b ret_from_except_lite | |
a546498f | 1489 | |
0ebc4cda | 1490 | |
caca285e | 1491 | #ifdef CONFIG_PPC_STD_MMU_64 |
0ebc4cda BH |
1492 | /* We have a page fault that hash_page could handle but HV refused |
1493 | * the PTE insertion | |
1494 | */ | |
b1576fec | 1495 | 13: bl save_nvgprs |
0ebc4cda BH |
1496 | mr r5,r3 |
1497 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1498 | ld r4,_DAR(r1) | |
b1576fec AB |
1499 | bl low_hash_fault |
1500 | b ret_from_except | |
caca285e | 1501 | #endif |
0ebc4cda | 1502 | |
9c1e1052 PM |
1503 | /* |
1504 | * We come here as a result of a DSI at a point where we don't want | |
1505 | * to call hash_page, such as when we are accessing memory (possibly | |
1506 | * user memory) inside a PMU interrupt that occurred while interrupts | |
1507 | * were soft-disabled. We want to invoke the exception handler for | |
1508 | * the access, or panic if there isn't a handler. | |
1509 | */ | |
b1576fec | 1510 | 77: bl save_nvgprs |
9c1e1052 PM |
1511 | mr r4,r3 |
1512 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1513 | li r5,SIGSEGV | |
b1576fec AB |
1514 | bl bad_page_fault |
1515 | b ret_from_except | |
4e2bf01b ME |
1516 | |
1517 | /* | |
1518 | * Here we have detected that the kernel stack pointer is bad. | |
1519 | * R9 contains the saved CR, r13 points to the paca, | |
1520 | * r10 contains the (bad) kernel stack pointer, | |
1521 | * r11 and r12 contain the saved SRR0 and SRR1. | |
1522 | * We switch to using an emergency stack, save the registers there, | |
1523 | * and call kernel_bad_stack(), which panics. | |
1524 | */ | |
1525 | bad_stack: | |
1526 | ld r1,PACAEMERGSP(r13) | |
1527 | subi r1,r1,64+INT_FRAME_SIZE | |
1528 | std r9,_CCR(r1) | |
1529 | std r10,GPR1(r1) | |
1530 | std r11,_NIP(r1) | |
1531 | std r12,_MSR(r1) | |
1532 | mfspr r11,SPRN_DAR | |
1533 | mfspr r12,SPRN_DSISR | |
1534 | std r11,_DAR(r1) | |
1535 | std r12,_DSISR(r1) | |
1536 | mflr r10 | |
1537 | mfctr r11 | |
1538 | mfxer r12 | |
1539 | std r10,_LINK(r1) | |
1540 | std r11,_CTR(r1) | |
1541 | std r12,_XER(r1) | |
1542 | SAVE_GPR(0,r1) | |
1543 | SAVE_GPR(2,r1) | |
1544 | ld r10,EX_R3(r3) | |
1545 | std r10,GPR3(r1) | |
1546 | SAVE_GPR(4,r1) | |
1547 | SAVE_4GPRS(5,r1) | |
1548 | ld r9,EX_R9(r3) | |
1549 | ld r10,EX_R10(r3) | |
1550 | SAVE_2GPRS(9,r1) | |
1551 | ld r9,EX_R11(r3) | |
1552 | ld r10,EX_R12(r3) | |
1553 | ld r11,EX_R13(r3) | |
1554 | std r9,GPR11(r1) | |
1555 | std r10,GPR12(r1) | |
1556 | std r11,GPR13(r1) | |
1557 | BEGIN_FTR_SECTION | |
1558 | ld r10,EX_CFAR(r3) | |
1559 | std r10,ORIG_GPR3(r1) | |
1560 | END_FTR_SECTION_IFSET(CPU_FTR_CFAR) | |
1561 | SAVE_8GPRS(14,r1) | |
1562 | SAVE_10GPRS(22,r1) | |
1563 | lhz r12,PACA_TRAP_SAVE(r13) | |
1564 | std r12,_TRAP(r1) | |
1565 | addi r11,r1,INT_FRAME_SIZE | |
1566 | std r11,0(r1) | |
1567 | li r12,0 | |
1568 | std r12,0(r11) | |
1569 | ld r2,PACATOC(r13) | |
1570 | ld r11,exception_marker@toc(r2) | |
1571 | std r12,RESULT(r1) | |
1572 | std r11,STACK_FRAME_OVERHEAD-16(r1) | |
1573 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
1574 | bl kernel_bad_stack | |
1575 | b 1b |