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.
7 * This file is meant to be #included from head_64.S due to
8 * position dependent assembly.
10 * Most of this originates from head_64.S and thus has the same
15 #include <asm/hw_irq.h>
16 #include <asm/exception-64s.h>
17 #include <asm/ptrace.h>
18 #include <asm/cpuidle.h>
21 * We layout physical memory as follows:
22 * 0x0000 - 0x00ff : Secondary processor spin code
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
27 * 0x7000 - 0x7fff : FWNMI data area
28 * 0x8000 - 0x8fff : Initial (CPU0) segment table
29 * 0x9000 - : Early init and support code
31 /* Syscall routine is used twice, in reloc-off and reloc-on paths */
32 #define SYSCALL_PSERIES_1 \
36 END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
39 mfspr r11,SPRN_SRR0 ; \
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 ; \
50 b . ; /* prevent speculative execution */
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 */ \
58 b . ; /* prevent speculative execution */
60 #if defined(CONFIG_RELOCATABLE)
62 * We can't branch directly so we do it via the CTR which
63 * is volatile across system calls.
65 #define SYSCALL_PSERIES_2_DIRECT \
67 ld r12,PACAKBASE(r13) ; \
68 LOAD_HANDLER(r12, system_call_entry) ; \
70 mfspr r12,SPRN_SRR1 ; \
71 /* Re-use of r13... No spare regs to do this */ \
74 GET_PACA(r13) ; /* get r13 back */ \
77 /* We can branch directly */
78 #define SYSCALL_PSERIES_2_DIRECT \
79 mfspr r12,SPRN_SRR1 ; \
81 mtmsrd r10,1 ; /* Set RI (EE=0) */ \
82 b system_call_common ;
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.
94 .globl __start_interrupts
97 .globl system_reset_pSeries;
100 #ifdef CONFIG_PPC_P7_NAP
102 /* Running native on arch 2.06 or later, check if we are
103 * waking up from nap/sleep/winkle.
106 rlwinm. r13,r13,47-31,30,31
112 * Check if last bit of HSPGR0 is set. This indicates whether we are
113 * waking up from winkle.
119 mtspr SPRN_HSPRG0,r13
121 lbz r0,PACA_THREAD_IDLE_STATE(r13)
122 cmpwi cr2,r0,PNV_THREAD_NAP
123 bgt cr2,8f /* Either sleep or Winkle */
125 /* Waking up from nap should not cause hypervisor state loss */
128 /* Waking up from nap */
129 li r0,PNV_THREAD_RUNNING
130 stb r0,PACA_THREAD_IDLE_STATE(r13) /* Clear thread state */
132 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
133 li r0,KVM_HWTHREAD_IN_KERNEL
134 stb r0,HSTATE_HWTHREAD_STATE(r13)
135 /* Order setting hwthread_state vs. testing hwthread_req */
137 lbz r0,HSTATE_HWTHREAD_REQ(r13)
144 /* Return SRR1 from power7_nap() */
147 b power7_wakeup_noloss
148 2: b power7_wakeup_loss
150 /* Fast Sleep wakeup on PowerNV */
152 b power7_wakeup_tb_loss
155 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
156 #endif /* CONFIG_PPC_P7_NAP */
157 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
161 machine_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
166 SET_SCRATCH0(r13) /* save r13 */
167 #ifdef CONFIG_PPC_P7_NAP
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.
175 rlwinm. r13,r13,47-31,30,31
176 OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
180 rlwinm. r13,r13,47-31,30,31
181 /* waking up from powersave (nap) state */
183 /* Total loss of HV state is fatal. let's just stay stuck here */
184 OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
187 OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
188 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
189 #endif /* CONFIG_PPC_P7_NAP */
190 EXCEPTION_PROLOG_0(PACA_EXMC)
192 b machine_check_pSeries_early
194 b machine_check_pSeries_0
195 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
198 .globl data_access_pSeries
201 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
205 .globl data_access_slb_pSeries
206 data_access_slb_pSeries:
208 EXCEPTION_PROLOG_0(PACA_EXSLB)
209 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
210 std r3,PACA_EXSLB+EX_R3(r13)
213 /* Keep that around for when we re-implement dynamic VSIDs */
215 bge slb_miss_user_pseries
216 #endif /* __DISABLED__ */
218 #ifndef CONFIG_RELOCATABLE
222 * We can't just use a direct branch to slb_miss_realmode
223 * because the distance from here to there depends on where
224 * the kernel ends up being put.
227 ld r10,PACAKBASE(r13)
228 LOAD_HANDLER(r10, slb_miss_realmode)
233 STD_EXCEPTION_PSERIES(0x400, instruction_access)
236 .globl instruction_access_slb_pSeries
237 instruction_access_slb_pSeries:
239 EXCEPTION_PROLOG_0(PACA_EXSLB)
240 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x480)
241 std r3,PACA_EXSLB+EX_R3(r13)
242 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
244 /* Keep that around for when we re-implement dynamic VSIDs */
246 bge slb_miss_user_pseries
247 #endif /* __DISABLED__ */
249 #ifndef CONFIG_RELOCATABLE
253 ld r10,PACAKBASE(r13)
254 LOAD_HANDLER(r10, slb_miss_realmode)
259 /* We open code these as we can't have a ". = x" (even with
260 * x = "." within a feature section
263 .globl hardware_interrupt_pSeries;
264 .globl hardware_interrupt_hv;
265 hardware_interrupt_pSeries:
266 hardware_interrupt_hv:
268 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
269 EXC_HV, SOFTEN_TEST_HV)
270 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
272 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
273 EXC_STD, SOFTEN_TEST_PR)
274 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
275 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
277 STD_EXCEPTION_PSERIES(0x600, alignment)
278 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x600)
280 STD_EXCEPTION_PSERIES(0x700, program_check)
281 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x700)
283 STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
284 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x800)
287 .globl decrementer_pSeries
289 _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR)
291 STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
293 MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super)
294 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xa00)
296 STD_EXCEPTION_PSERIES(0xb00, trap_0b)
297 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xb00)
300 .globl system_call_pSeries
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.
309 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
312 std r9,PACA_EXGEN+EX_R9(r13)
313 OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR);
315 std r10,PACA_EXGEN+EX_R10(r13)
316 OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR);
324 SYSCALL_PSERIES_2_RFID
326 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
328 STD_EXCEPTION_PSERIES(0xd00, single_step)
329 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xd00)
331 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
332 * out of line to handle them
335 hv_data_storage_trampoline:
337 EXCEPTION_PROLOG_0(PACA_EXGEN)
341 hv_instr_storage_trampoline:
343 EXCEPTION_PROLOG_0(PACA_EXGEN)
347 emulation_assist_trampoline:
349 EXCEPTION_PROLOG_0(PACA_EXGEN)
350 b emulation_assist_hv
353 hv_exception_trampoline:
355 EXCEPTION_PROLOG_0(PACA_EXGEN)
356 b hmi_exception_early
359 hv_doorbell_trampoline:
361 EXCEPTION_PROLOG_0(PACA_EXGEN)
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
370 performance_monitor_pseries_trampoline:
372 EXCEPTION_PROLOG_0(PACA_EXGEN)
373 b performance_monitor_pSeries
376 altivec_unavailable_pseries_trampoline:
378 EXCEPTION_PROLOG_0(PACA_EXGEN)
379 b altivec_unavailable_pSeries
382 vsx_unavailable_pseries_trampoline:
384 EXCEPTION_PROLOG_0(PACA_EXGEN)
385 b vsx_unavailable_pSeries
388 facility_unavailable_trampoline:
390 EXCEPTION_PROLOG_0(PACA_EXGEN)
391 b facility_unavailable_pSeries
394 hv_facility_unavailable_trampoline:
396 EXCEPTION_PROLOG_0(PACA_EXGEN)
397 b facility_unavailable_hv
399 #ifdef CONFIG_CBE_RAS
400 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
401 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
402 #endif /* CONFIG_CBE_RAS */
404 STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint)
405 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
408 .global denorm_exception_hv
410 mtspr SPRN_SPRG_HSCRATCH0,r13
411 EXCEPTION_PROLOG_0(PACA_EXGEN)
412 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
414 #ifdef CONFIG_PPC_DENORMALISATION
416 mfspr r11,SPRN_HSRR0 /* save HSRR0 */
417 andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */
418 addi r11,r11,-4 /* HSRR0 is next instruction */
423 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
424 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500)
426 #ifdef CONFIG_CBE_RAS
427 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
428 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
429 #endif /* CONFIG_CBE_RAS */
431 STD_EXCEPTION_PSERIES(0x1700, altivec_assist)
432 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x1700)
434 #ifdef CONFIG_CBE_RAS
435 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
436 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
439 #endif /* CONFIG_CBE_RAS */
442 /*** Out of line interrupts support ***/
445 /* moved from 0x200 */
446 machine_check_pSeries_early:
448 EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
453 * Original R9 to R13 is saved on PACA_EXMC
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
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
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.
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.
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 */
477 0: 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)
480 /* Limit nested MCE to level 4 to avoid stack overflow */
482 bgt 2f /* Check if we hit limit of 4 */
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 */
487 mfspr r11,SPRN_SRR1 /* Save SRR1 */
489 mfspr r11,SPRN_DAR /* Save DAR */
491 mfspr r11,SPRN_DSISR /* Save DSISR */
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)
501 1: mtspr SPRN_SRR0,r12
504 b . /* prevent speculative execution */
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.
510 addi r1,r1,INT_FRAME_SIZE /* go back to previous stack frame */
512 ld r12,PACAKBASE(r13)
513 LOAD_HANDLER(r12, unrecover_mce)
515 andc r11,r11,r10 /* Turn off MSR_ME */
517 b . /* prevent speculative execution */
518 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
520 machine_check_pSeries:
521 .globl machine_check_fwnmi
523 SET_SCRATCH0(r13) /* save r13 */
524 EXCEPTION_PROLOG_0(PACA_EXMC)
525 machine_check_pSeries_0:
526 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200)
527 EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD)
528 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
529 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
530 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
531 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x400)
532 KVM_HANDLER(PACA_EXSLB, EXC_STD, 0x480)
533 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x900)
534 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
536 #ifdef CONFIG_PPC_DENORMALISATION
540 * To denormalise we need to move a copy of the register to itself.
541 * For POWER6 do that here for all FP regs.
544 ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1)
545 xori r10,r10,(MSR_FE0|MSR_FE1)
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)
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.
562 oris r10,r10,MSR_VSX@h
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)
573 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206)
577 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
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
586 ld r9,PACA_EXGEN+EX_R9(r13)
587 RESTORE_PPR_PACA(PACA_EXGEN, r10)
589 ld r10,PACA_EXGEN+EX_CFAR(r13)
591 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
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)
601 /* moved from 0xe00 */
602 STD_EXCEPTION_HV_OOL(0xe02, h_data_storage)
603 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
604 STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage)
605 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
606 STD_EXCEPTION_HV_OOL(0xe42, emulation_assist)
607 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
608 MASKABLE_EXCEPTION_HV_OOL(0xe62, hmi_exception)
609 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
611 MASKABLE_EXCEPTION_HV_OOL(0xe82, h_doorbell)
612 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe82)
614 /* moved from 0xf00 */
615 STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
616 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf00)
617 STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
618 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf20)
619 STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
620 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf40)
621 STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
622 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf60)
623 STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable)
624 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82)
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.
631 * - If it was a HMI we return immediately since we handled it in realmode
632 * and it won't refire.
633 * - else we hard disable and return.
634 * This is called with r10 containing the value to OR to the paca field.
636 #define MASKED_INTERRUPT(_H) \
637 masked_##_H##interrupt: \
638 std r11,PACA_EXGEN+EX_R11(r13); \
639 lbz r11,PACAIRQHAPPENED(r13); \
641 stb r11,PACAIRQHAPPENED(r13); \
642 cmpwi r10,PACA_IRQ_DEC; \
645 ori r10,r10,0xffff; \
646 mtspr SPRN_DEC,r10; \
648 1: cmpwi r10,PACA_IRQ_DBELL; \
650 cmpwi r10,PACA_IRQ_HMI; \
652 mfspr r10,SPRN_##_H##SRR1; \
653 rldicl r10,r10,48,1; /* clear MSR_EE */ \
655 mtspr SPRN_##_H##SRR1,r10; \
657 ld r9,PACA_EXGEN+EX_R9(r13); \
658 ld r10,PACA_EXGEN+EX_R10(r13); \
659 ld r11,PACA_EXGEN+EX_R11(r13); \
668 * Called from arch_local_irq_enable when an interrupt needs
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
671 * stackframe like if a real interrupt had happened.
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.
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.
687 beq decrementer_common
689 beq hardware_interrupt_common
692 beq h_doorbell_common
695 beq doorbell_super_common
696 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
699 #ifdef CONFIG_PPC_PSERIES
701 * Vectors for the FWNMI option. Share common code.
703 .globl system_reset_fwnmi
706 SET_SCRATCH0(r13) /* save r13 */
707 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
710 #endif /* CONFIG_PPC_PSERIES */
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
718 slb_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)
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)
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
734 mfspr r12,SRR1 /* and SRR1 */
737 b . /* prevent spec. execution */
738 #endif /* __DISABLED__ */
740 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
741 kvmppc_skip_interrupt:
743 * Here all GPRs are unchanged from when the interrupt happened
744 * except for r13, which is saved in SPRG_SCRATCH0.
753 kvmppc_skip_Hinterrupt:
755 * Here all GPRs are unchanged from when the interrupt happened
756 * except for r13, which is saved in SPRG_SCRATCH0.
758 mfspr r13, SPRN_HSRR0
760 mtspr SPRN_HSRR0, r13
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,
770 * which uses an ori instruction, these handlers must be in
771 * the first 64k of the kernel image.
774 /*** Common interrupt handlers ***/
776 STD_EXCEPTION_COMMON(0x100, system_reset, system_reset_exception)
778 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
779 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, timer_interrupt)
780 STD_EXCEPTION_COMMON(0x980, hdecrementer, hdec_interrupt)
781 #ifdef CONFIG_PPC_DOORBELL
782 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, doorbell_exception)
784 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, unknown_exception)
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)
790 STD_EXCEPTION_COMMON_ASYNC(0xe60, hmi_exception, handle_hmi_exception)
791 #ifdef CONFIG_PPC_DOORBELL
792 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, doorbell_exception)
794 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, unknown_exception)
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)
799 #ifdef CONFIG_ALTIVEC
800 STD_EXCEPTION_COMMON(0x1700, altivec_assist, altivec_assist_exception)
802 STD_EXCEPTION_COMMON(0x1700, altivec_assist, unknown_exception)
804 #ifdef CONFIG_CBE_RAS
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)
808 #endif /* CONFIG_CBE_RAS */
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.
821 * This uses the standard macro, since the original 0x300 vector
822 * only has extra guff for STAB-based processors -- which never
825 STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access)
827 .globl data_access_slb_relon_pSeries
828 data_access_slb_relon_pSeries:
830 EXCEPTION_PROLOG_0(PACA_EXSLB)
831 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
832 std r3,PACA_EXSLB+EX_R3(r13)
835 #ifndef CONFIG_RELOCATABLE
839 * We can't just use a direct branch to slb_miss_realmode
840 * because the distance from here to there depends on where
841 * the kernel ends up being put.
844 ld r10,PACAKBASE(r13)
845 LOAD_HANDLER(r10, slb_miss_realmode)
850 STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access)
852 .globl instruction_access_slb_relon_pSeries
853 instruction_access_slb_relon_pSeries:
855 EXCEPTION_PROLOG_0(PACA_EXSLB)
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 */
860 #ifndef CONFIG_RELOCATABLE
864 ld r10,PACAKBASE(r13)
865 LOAD_HANDLER(r10, slb_miss_realmode)
871 .globl hardware_interrupt_relon_pSeries;
872 .globl hardware_interrupt_relon_hv;
873 hardware_interrupt_relon_pSeries:
874 hardware_interrupt_relon_hv:
876 _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
878 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
879 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
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)
885 MASKABLE_RELON_EXCEPTION_PSERIES(0x4a00, 0xa00, doorbell_super)
886 STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b)
889 .globl system_call_relon_pSeries
890 system_call_relon_pSeries:
893 SYSCALL_PSERIES_2_DIRECT
896 STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step)
899 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
902 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
905 emulation_assist_relon_trampoline:
907 EXCEPTION_PROLOG_0(PACA_EXGEN)
908 b emulation_assist_relon_hv
911 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
914 h_doorbell_relon_trampoline:
916 EXCEPTION_PROLOG_0(PACA_EXGEN)
917 b h_doorbell_relon_hv
920 performance_monitor_relon_pseries_trampoline:
922 EXCEPTION_PROLOG_0(PACA_EXGEN)
923 b performance_monitor_relon_pSeries
926 altivec_unavailable_relon_pseries_trampoline:
928 EXCEPTION_PROLOG_0(PACA_EXGEN)
929 b altivec_unavailable_relon_pSeries
932 vsx_unavailable_relon_pseries_trampoline:
934 EXCEPTION_PROLOG_0(PACA_EXGEN)
935 b vsx_unavailable_relon_pSeries
938 facility_unavailable_relon_trampoline:
940 EXCEPTION_PROLOG_0(PACA_EXGEN)
941 b facility_unavailable_relon_pSeries
944 hv_facility_unavailable_relon_trampoline:
946 EXCEPTION_PROLOG_0(PACA_EXGEN)
947 b hv_facility_unavailable_relon_hv
949 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
950 #ifdef CONFIG_PPC_DENORMALISATION
952 b denorm_exception_hv
954 STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
956 /* Other future vectors */
958 .globl __end_interrupts
965 ppc64_runlatch_on_trampoline:
966 b __ppc64_runlatch_on
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.
974 .globl data_access_common
977 std r10,PACA_EXGEN+EX_DAR(r13)
979 stw r10,PACA_EXGEN+EX_DSISR(r13)
980 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
981 RECONCILE_IRQ_STATE(r10, r11)
983 ld r3,PACA_EXGEN+EX_DAR(r13)
984 lwz r4,PACA_EXGEN+EX_DSISR(r13)
986 b do_hash_page /* Try to handle as hpte fault */
989 .globl h_data_storage_common
990 h_data_storage_common:
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)
997 RECONCILE_IRQ_STATE(r10, r11)
998 addi r3,r1,STACK_FRAME_OVERHEAD
1003 .globl instruction_access_common
1004 instruction_access_common:
1005 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
1006 RECONCILE_IRQ_STATE(r10, r11)
1009 andis. r4,r12,0x5820
1011 b do_hash_page /* Try to handle as hpte fault */
1013 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, unknown_exception)
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
1021 .globl slb_miss_user_common
1022 slb_miss_user_common:
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)
1028 bl slb_allocate_user
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)
1037 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1038 beq- unrecov_user_slb
1046 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
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)
1061 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
1062 ld r4,PACA_EXGEN+EX_DAR(r13)
1069 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
1070 RECONCILE_IRQ_STATE(r10, r11)
1072 1: addi r3,r1,STACK_FRAME_OVERHEAD
1073 bl unrecoverable_exception
1076 #endif /* __DISABLED__ */
1080 * Machine check is different because we use a different
1081 * save area: PACA_EXMC instead of PACA_EXGEN.
1084 .globl machine_check_common
1085 machine_check_common:
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)
1093 RECONCILE_IRQ_STATE(r10, r11)
1094 ld r3,PACA_EXGEN+EX_DAR(r13)
1095 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1099 addi r3,r1,STACK_FRAME_OVERHEAD
1100 bl machine_check_exception
1104 .globl alignment_common
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)
1116 RECONCILE_IRQ_STATE(r10, r11)
1117 addi r3,r1,STACK_FRAME_OVERHEAD
1118 bl alignment_exception
1122 .globl program_check_common
1123 program_check_common:
1124 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
1126 RECONCILE_IRQ_STATE(r10, r11)
1127 addi r3,r1,STACK_FRAME_OVERHEAD
1128 bl program_check_exception
1132 .globl fp_unavailable_common
1133 fp_unavailable_common:
1134 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
1135 bne 1f /* if from user, just load it up */
1137 RECONCILE_IRQ_STATE(r10, r11)
1138 addi r3,r1,STACK_FRAME_OVERHEAD
1139 bl kernel_fp_unavailable_exception
1142 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1144 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1145 * transaction), go do TM stuff
1147 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1149 END_FTR_SECTION_IFSET(CPU_FTR_TM)
1152 b fast_exception_return
1153 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1154 2: /* User process was in a transaction */
1156 RECONCILE_IRQ_STATE(r10, r11)
1157 addi r3,r1,STACK_FRAME_OVERHEAD
1158 bl fp_unavailable_tm
1162 .globl altivec_unavailable_common
1163 altivec_unavailable_common:
1164 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
1165 #ifdef CONFIG_ALTIVEC
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
1173 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1175 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1178 b fast_exception_return
1179 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1180 2: /* User process was in a transaction */
1182 RECONCILE_IRQ_STATE(r10, r11)
1183 addi r3,r1,STACK_FRAME_OVERHEAD
1184 bl altivec_unavailable_tm
1188 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1191 RECONCILE_IRQ_STATE(r10, r11)
1192 addi r3,r1,STACK_FRAME_OVERHEAD
1193 bl altivec_unavailable_exception
1197 .globl vsx_unavailable_common
1198 vsx_unavailable_common:
1199 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
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
1208 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1210 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1213 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1214 2: /* User process was in a transaction */
1216 RECONCILE_IRQ_STATE(r10, r11)
1217 addi r3,r1,STACK_FRAME_OVERHEAD
1218 bl vsx_unavailable_tm
1222 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1225 RECONCILE_IRQ_STATE(r10, r11)
1226 addi r3,r1,STACK_FRAME_OVERHEAD
1227 bl vsx_unavailable_exception
1230 STD_EXCEPTION_COMMON(0xf60, facility_unavailable, facility_unavailable_exception)
1231 STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, facility_unavailable_exception)
1234 .globl __end_handlers
1237 /* Equivalents to the above handlers for relocation-on interrupt vectors */
1238 STD_RELON_EXCEPTION_HV_OOL(0xe40, emulation_assist)
1239 MASKABLE_RELON_EXCEPTION_HV_OOL(0xe80, h_doorbell)
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)
1244 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1245 STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1247 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1249 * Data area reserved for FWNMI option.
1250 * This address (0x7000) is fixed by the RPA.
1253 .globl fwnmi_data_area
1256 /* pseries and powernv need to keep the whole page from
1257 * 0x7000 to 0x8000 free for use by the firmware
1260 #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
1262 .globl hmi_exception_early
1263 hmi_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. */
1281 /* Move original HSRR0 and HSRR1 into the respective regs */
1299 /* restore original r1. */
1303 * Go to virtual mode and pull the HMI event information from
1306 .globl hmi_exception_after_realmode
1307 hmi_exception_after_realmode:
1309 EXCEPTION_PROLOG_0(PACA_EXGEN)
1313 #define MACHINE_CHECK_HANDLER_WINDUP \
1314 /* Clear MSR_RI before setting SRR0 and SRR1. */\
1316 mfmsr r9; /* get MSR value */ \
1318 mtmsrd r9,1; /* Clear MSR_RI */ \
1319 /* Move original SRR0 and SRR1 into the respective regs */ \
1321 mtspr SPRN_SRR1,r9; \
1323 mtspr SPRN_SRR0,r3; \
1331 REST_8GPRS(2, r1); \
1335 /* Decrement paca->in_mce. */ \
1336 lhz r12,PACA_IN_MCE(r13); \
1338 sth r12,PACA_IN_MCE(r13); \
1340 REST_2GPRS(12, r1); \
1341 /* restore original r1. */ \
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.
1349 .globl machine_check_handle_early
1350 machine_check_handle_early:
1351 std r0,GPR0(r1) /* Save r0 */
1352 EXCEPTION_PROLOG_COMMON_3(0x200)
1354 addi r3,r1,STACK_FRAME_OVERHEAD
1355 bl machine_check_early
1356 std r3,RESULT(r1) /* Save result */
1358 #ifdef CONFIG_PPC_P7_NAP
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
1366 * Go back to nap again if (b) is true.
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. */
1373 /* Supervisor state loss */
1375 stb r0,PACA_NAPSTATELOST(r13)
1376 3: bl machine_check_queue_event
1377 MACHINE_CHECK_HANDLER_WINDUP
1380 li r3,PNV_THREAD_NAP
1381 b power7_enter_nap_mode
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.
1388 rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */
1390 andi. r11,r12,MSR_PR /* See if coming from user. */
1391 bne 9f /* continue in V mode if we are. */
1394 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
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.
1400 lbz r11,HSTATE_IN_GUEST(r13)
1401 cmpwi r11,0 /* Check if coming from guest */
1402 bne 9f /* continue if we are. */
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.
1410 andi. r11,r12,MSR_RI
1412 1: mfspr r11,SPRN_SRR0
1413 ld r10,PACAKBASE(r13)
1414 LOAD_HANDLER(r10,unrecover_mce)
1416 ld r10,PACAKMSR(r13)
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.
1425 andc r10,r10,r3 /* Turn off MSR_ME */
1431 * Check if we have successfully handled/recovered from error, if not
1432 * then stay on emergency stack and panic.
1434 ld r3,RESULT(r1) /* Load result */
1435 cmpdi r3,0 /* see if we handled MCE successfully */
1437 beq 1b /* if !handled then panic */
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.
1443 bl machine_check_queue_event
1444 MACHINE_CHECK_HANDLER_WINDUP
1447 /* Deliver the machine check to host kernel in V mode. */
1448 MACHINE_CHECK_HANDLER_WINDUP
1449 b machine_check_pSeries
1452 /* Invoke machine_check_exception to print MCE event and panic. */
1453 addi r3,r1,STACK_FRAME_OVERHEAD
1454 bl machine_check_exception
1456 * We will not reach here. Even if we did, there is no way out. Call
1457 * unrecoverable_exception and die.
1459 1: addi r3,r1,STACK_FRAME_OVERHEAD
1460 bl unrecoverable_exception
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.
1472 #ifdef CONFIG_RELOCATABLE
1476 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1477 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
1479 bl slb_allocate_realmode
1481 /* All done -- return from exception. */
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 */
1489 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1495 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
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)
1505 b . /* prevent speculative execution */
1507 2: mfspr r11,SPRN_SRR0
1508 ld r10,PACAKBASE(r13)
1509 LOAD_HANDLER(r10,unrecov_slb)
1511 ld r10,PACAKMSR(r13)
1517 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
1518 RECONCILE_IRQ_STATE(r10, r11)
1520 1: addi r3,r1,STACK_FRAME_OVERHEAD
1521 bl unrecoverable_exception
1525 #ifdef CONFIG_PPC_970_NAP
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 */
1542 andis. r0,r4,0xa410 /* weird error? */
1543 bne- handle_page_fault /* if not, try to insert a HPTE */
1544 andis. r0,r4,DSISR_DABRMATCH@h
1545 bne- handle_dabr_fault
1546 CURRENT_THREAD_INFO(r11, r1)
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 */
1552 * r3 contains the faulting address
1554 * r5 contains the trap number
1557 * at return r3 = 0 for success, 1 for page fault, negative for error
1561 bl __hash_page /* build HPTE if possible */
1562 cmpdi r3,0 /* see if __hash_page succeeded */
1565 beq fast_exc_return_irq /* Return from exception on success */
1570 /* Here we have a page fault that hash_page can't handle. */
1574 addi r3,r1,STACK_FRAME_OVERHEAD
1580 addi r3,r1,STACK_FRAME_OVERHEAD
1585 /* We have a data breakpoint exception - handle it */
1590 addi r3,r1,STACK_FRAME_OVERHEAD
1592 12: b ret_from_except_lite
1595 /* We have a page fault that hash_page could handle but HV refused
1600 addi r3,r1,STACK_FRAME_OVERHEAD
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.
1614 addi r3,r1,STACK_FRAME_OVERHEAD
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.
1628 ld r1,PACAEMERGSP(r13)
1629 subi r1,r1,64+INT_FRAME_SIZE
1635 mfspr r12,SPRN_DSISR
1661 std r10,ORIG_GPR3(r1)
1662 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
1665 lhz r12,PACA_TRAP_SAVE(r13)
1667 addi r11,r1,INT_FRAME_SIZE
1672 ld r11,exception_marker@toc(r2)
1674 std r11,STACK_FRAME_OVERHEAD-16(r1)
1675 1: addi r3,r1,STACK_FRAME_OVERHEAD