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