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