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>
20 * We layout physical memory as follows:
21 * 0x0000 - 0x00ff : Secondary processor spin code
22 * 0x0100 - 0x17ff : pSeries Interrupt prologs
23 * 0x1800 - 0x4000 : interrupt support common interrupt prologs
24 * 0x4000 - 0x5fff : pSeries interrupts with IR=1,DR=1
25 * 0x6000 - 0x6fff : more interrupt support including for IR=1,DR=1
26 * 0x7000 - 0x7fff : FWNMI data area
27 * 0x8000 - 0x8fff : Initial (CPU0) segment table
28 * 0x9000 - : Early init and support code
30 /* Syscall routine is used twice, in reloc-off and reloc-on paths */
31 #define SYSCALL_PSERIES_1 \
35 END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
38 mfspr r11,SPRN_SRR0 ; \
41 #define SYSCALL_PSERIES_2_RFID \
42 mfspr r12,SPRN_SRR1 ; \
43 ld r10,PACAKBASE(r13) ; \
44 LOAD_HANDLER(r10, system_call_entry) ; \
45 mtspr SPRN_SRR0,r10 ; \
46 ld r10,PACAKMSR(r13) ; \
47 mtspr SPRN_SRR1,r10 ; \
49 b . ; /* prevent speculative execution */
51 #define SYSCALL_PSERIES_3 \
52 /* Fast LE/BE switch system call */ \
53 1: mfspr r12,SPRN_SRR1 ; \
54 xori r12,r12,MSR_LE ; \
55 mtspr SPRN_SRR1,r12 ; \
56 rfid ; /* return to userspace */ \
57 b . ; /* prevent speculative execution */
59 #if defined(CONFIG_RELOCATABLE)
61 * We can't branch directly; in the direct case we use LR
62 * and system_call_entry restores LR. (We thus need to move
63 * LR to r10 in the RFID case too.)
65 #define SYSCALL_PSERIES_2_DIRECT \
67 ld r12,PACAKBASE(r13) ; \
68 LOAD_HANDLER(r12, system_call_entry_direct) ; \
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_entry_direct ;
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;
99 HMT_MEDIUM_PPR_DISCARD
101 #ifdef CONFIG_PPC_P7_NAP
103 /* Running native on arch 2.06 or later, check if we are
104 * waking up from nap. We only handle no state loss and
105 * supervisor state loss. We do -not- handle hypervisor
106 * state loss at this time.
109 rlwinm. r13,r13,47-31,30,31
112 /* waking up from powersave (nap) state */
114 /* Total loss of HV state is fatal, we could try to use the
115 * PIR to locate a PACA, then use an emergency stack etc...
116 * OPAL v3 based powernv platforms have new idle states
117 * which fall in this catagory.
122 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
123 li r0,KVM_HWTHREAD_IN_KERNEL
124 stb r0,HSTATE_HWTHREAD_STATE(r13)
125 /* Order setting hwthread_state vs. testing hwthread_req */
127 lbz r0,HSTATE_HWTHREAD_REQ(r13)
135 b power7_wakeup_noloss
136 2: b power7_wakeup_loss
138 /* Fast Sleep wakeup on PowerNV */
140 b power7_wakeup_tb_loss
143 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
144 #endif /* CONFIG_PPC_P7_NAP */
145 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
149 machine_check_pSeries_1:
150 /* This is moved out of line as it can be patched by FW, but
151 * some code path might still want to branch into the original
154 HMT_MEDIUM_PPR_DISCARD
155 SET_SCRATCH0(r13) /* save r13 */
156 #ifdef CONFIG_PPC_P7_NAP
158 /* Running native on arch 2.06 or later, check if we are
159 * waking up from nap. We only handle no state loss and
160 * supervisor state loss. We do -not- handle hypervisor
161 * state loss at this time.
164 rlwinm. r13,r13,47-31,30,31
165 OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
169 rlwinm. r13,r13,47-31,30,31
170 /* waking up from powersave (nap) state */
172 /* Total loss of HV state is fatal. let's just stay stuck here */
173 OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
176 OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
177 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
178 #endif /* CONFIG_PPC_P7_NAP */
179 EXCEPTION_PROLOG_0(PACA_EXMC)
181 b machine_check_pSeries_early
183 b machine_check_pSeries_0
184 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
187 .globl data_access_pSeries
189 HMT_MEDIUM_PPR_DISCARD
191 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
195 .globl data_access_slb_pSeries
196 data_access_slb_pSeries:
197 HMT_MEDIUM_PPR_DISCARD
199 EXCEPTION_PROLOG_0(PACA_EXSLB)
200 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
201 std r3,PACA_EXSLB+EX_R3(r13)
204 /* Keep that around for when we re-implement dynamic VSIDs */
206 bge slb_miss_user_pseries
207 #endif /* __DISABLED__ */
209 #ifndef CONFIG_RELOCATABLE
213 * We can't just use a direct branch to slb_miss_realmode
214 * because the distance from here to there depends on where
215 * the kernel ends up being put.
218 ld r10,PACAKBASE(r13)
219 LOAD_HANDLER(r10, slb_miss_realmode)
224 STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access)
227 .globl instruction_access_slb_pSeries
228 instruction_access_slb_pSeries:
229 HMT_MEDIUM_PPR_DISCARD
231 EXCEPTION_PROLOG_0(PACA_EXSLB)
232 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
233 std r3,PACA_EXSLB+EX_R3(r13)
234 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
236 /* Keep that around for when we re-implement dynamic VSIDs */
238 bge slb_miss_user_pseries
239 #endif /* __DISABLED__ */
241 #ifndef CONFIG_RELOCATABLE
245 ld r10,PACAKBASE(r13)
246 LOAD_HANDLER(r10, slb_miss_realmode)
251 /* We open code these as we can't have a ". = x" (even with
252 * x = "." within a feature section
255 .globl hardware_interrupt_pSeries;
256 .globl hardware_interrupt_hv;
257 hardware_interrupt_pSeries:
258 hardware_interrupt_hv:
259 HMT_MEDIUM_PPR_DISCARD
261 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
262 EXC_HV, SOFTEN_TEST_HV)
263 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
265 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
266 EXC_STD, SOFTEN_TEST_HV_201)
267 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
268 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
270 STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
271 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
273 STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
274 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
276 STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
277 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
280 .globl decrementer_pSeries
282 _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR)
284 STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
286 MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super)
287 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
289 STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
290 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
293 .globl system_call_pSeries
296 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
299 std r9,PACA_EXGEN+EX_R9(r13)
300 std r10,PACA_EXGEN+EX_R10(r13)
306 SYSCALL_PSERIES_2_RFID
308 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
310 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
311 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
313 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
314 * out of line to handle them
317 hv_data_storage_trampoline:
319 EXCEPTION_PROLOG_0(PACA_EXGEN)
323 hv_instr_storage_trampoline:
325 EXCEPTION_PROLOG_0(PACA_EXGEN)
329 emulation_assist_trampoline:
331 EXCEPTION_PROLOG_0(PACA_EXGEN)
332 b emulation_assist_hv
335 hv_exception_trampoline:
337 EXCEPTION_PROLOG_0(PACA_EXGEN)
338 b hmi_exception_early
341 hv_doorbell_trampoline:
343 EXCEPTION_PROLOG_0(PACA_EXGEN)
346 /* We need to deal with the Altivec unavailable exception
347 * here which is at 0xf20, thus in the middle of the
348 * prolog code of the PerformanceMonitor one. A little
349 * trickery is thus necessary
352 performance_monitor_pseries_trampoline:
354 EXCEPTION_PROLOG_0(PACA_EXGEN)
355 b performance_monitor_pSeries
358 altivec_unavailable_pseries_trampoline:
360 EXCEPTION_PROLOG_0(PACA_EXGEN)
361 b altivec_unavailable_pSeries
364 vsx_unavailable_pseries_trampoline:
366 EXCEPTION_PROLOG_0(PACA_EXGEN)
367 b vsx_unavailable_pSeries
370 facility_unavailable_trampoline:
372 EXCEPTION_PROLOG_0(PACA_EXGEN)
373 b facility_unavailable_pSeries
376 hv_facility_unavailable_trampoline:
378 EXCEPTION_PROLOG_0(PACA_EXGEN)
379 b facility_unavailable_hv
381 #ifdef CONFIG_CBE_RAS
382 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
383 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
384 #endif /* CONFIG_CBE_RAS */
386 STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
387 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
390 .global denorm_exception_hv
392 HMT_MEDIUM_PPR_DISCARD
393 mtspr SPRN_SPRG_HSCRATCH0,r13
394 EXCEPTION_PROLOG_0(PACA_EXGEN)
395 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
397 #ifdef CONFIG_PPC_DENORMALISATION
399 mfspr r11,SPRN_HSRR0 /* save HSRR0 */
400 andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */
401 addi r11,r11,-4 /* HSRR0 is next instruction */
406 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
407 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500)
409 #ifdef CONFIG_CBE_RAS
410 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
411 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
412 #endif /* CONFIG_CBE_RAS */
414 STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
415 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
417 #ifdef CONFIG_CBE_RAS
418 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
419 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
422 #endif /* CONFIG_CBE_RAS */
425 /*** Out of line interrupts support ***/
428 /* moved from 0x200 */
429 machine_check_pSeries_early:
431 EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
436 * Original R9 to R13 is saved on PACA_EXMC
438 * Switch to mc_emergency stack and handle re-entrancy (we limit
439 * the nested MCE upto level 4 to avoid stack overflow).
440 * Save MCE registers srr1, srr0, dar and dsisr and then set ME=1
442 * We use paca->in_mce to check whether this is the first entry or
443 * nested machine check. We increment paca->in_mce to track nested
446 * If this is the first entry then set stack pointer to
447 * paca->mc_emergency_sp, otherwise r1 is already pointing to
448 * stack frame on mc_emergency stack.
450 * NOTE: We are here with MSR_ME=0 (off), which means we risk a
451 * checkstop if we get another machine check exception before we do
452 * rfid with MSR_ME=1.
454 mr r11,r1 /* Save r1 */
455 lhz r10,PACA_IN_MCE(r13)
456 cmpwi r10,0 /* Are we in nested machine check */
457 bne 0f /* Yes, we are. */
458 /* First machine check entry */
459 ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */
460 0: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */
461 addi r10,r10,1 /* increment paca->in_mce */
462 sth r10,PACA_IN_MCE(r13)
463 /* Limit nested MCE to level 4 to avoid stack overflow */
465 bgt 2f /* Check if we hit limit of 4 */
466 std r11,GPR1(r1) /* Save r1 on the stack. */
467 std r11,0(r1) /* make stack chain pointer */
468 mfspr r11,SPRN_SRR0 /* Save SRR0 */
470 mfspr r11,SPRN_SRR1 /* Save SRR1 */
472 mfspr r11,SPRN_DAR /* Save DAR */
474 mfspr r11,SPRN_DSISR /* Save DSISR */
476 std r9,_CCR(r1) /* Save CR in stackframe */
477 /* Save r9 through r13 from EXMC save area to stack frame. */
478 EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
479 mfmsr r11 /* get MSR value */
480 ori r11,r11,MSR_ME /* turn on ME bit */
481 ori r11,r11,MSR_RI /* turn on RI bit */
482 ld r12,PACAKBASE(r13) /* get high part of &label */
483 LOAD_HANDLER(r12, machine_check_handle_early)
484 1: mtspr SPRN_SRR0,r12
487 b . /* prevent speculative execution */
489 /* Stack overflow. Stay on emergency stack and panic.
490 * Keep the ME bit off while panic-ing, so that if we hit
491 * another machine check we checkstop.
493 addi r1,r1,INT_FRAME_SIZE /* go back to previous stack frame */
495 ld r12,PACAKBASE(r13)
496 LOAD_HANDLER(r12, unrecover_mce)
498 andc r11,r11,r10 /* Turn off MSR_ME */
500 b . /* prevent speculative execution */
501 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
503 machine_check_pSeries:
504 .globl machine_check_fwnmi
506 HMT_MEDIUM_PPR_DISCARD
507 SET_SCRATCH0(r13) /* save r13 */
508 EXCEPTION_PROLOG_0(PACA_EXMC)
509 machine_check_pSeries_0:
510 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200)
511 EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD)
512 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
513 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
514 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
515 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
516 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
517 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
518 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
520 #ifdef CONFIG_PPC_DENORMALISATION
524 * To denormalise we need to move a copy of the register to itself.
525 * For POWER6 do that here for all FP regs.
528 ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1)
529 xori r10,r10,(MSR_FE0|MSR_FE1)
533 #define FMR2(n) fmr (n), (n) ; fmr n+1, n+1
534 #define FMR4(n) FMR2(n) ; FMR2(n+2)
535 #define FMR8(n) FMR4(n) ; FMR4(n+4)
536 #define FMR16(n) FMR8(n) ; FMR8(n+8)
537 #define FMR32(n) FMR16(n) ; FMR16(n+16)
542 * To denormalise we need to move a copy of the register to itself.
543 * For POWER7 do that here for the first 32 VSX registers only.
546 oris r10,r10,MSR_VSX@h
550 #define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1)
551 #define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2)
552 #define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4)
553 #define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8)
554 #define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16)
557 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206)
561 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
563 * To denormalise we need to move a copy of the register to itself.
564 * For POWER8 we need to do that for all 64 VSX registers
570 ld r9,PACA_EXGEN+EX_R9(r13)
571 RESTORE_PPR_PACA(PACA_EXGEN, r10)
573 ld r10,PACA_EXGEN+EX_CFAR(r13)
575 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
576 ld r10,PACA_EXGEN+EX_R10(r13)
577 ld r11,PACA_EXGEN+EX_R11(r13)
578 ld r12,PACA_EXGEN+EX_R12(r13)
579 ld r13,PACA_EXGEN+EX_R13(r13)
585 /* moved from 0xe00 */
586 STD_EXCEPTION_HV_OOL(0xe02, h_data_storage)
587 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
588 STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage)
589 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
590 STD_EXCEPTION_HV_OOL(0xe42, emulation_assist)
591 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
592 MASKABLE_EXCEPTION_HV_OOL(0xe62, hmi_exception)
593 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
595 .globl hmi_exception_early
597 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0xe60)
598 mr r10,r1 /* Save r1 */
599 ld r1,PACAEMERGSP(r13) /* Use emergency stack */
600 subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */
601 std r9,_CCR(r1) /* save CR in stackframe */
602 mfspr r11,SPRN_HSRR0 /* Save HSRR0 */
603 std r11,_NIP(r1) /* save HSRR0 in stackframe */
604 mfspr r12,SPRN_HSRR1 /* Save SRR1 */
605 std r12,_MSR(r1) /* save SRR1 in stackframe */
606 std r10,0(r1) /* make stack chain pointer */
607 std r0,GPR0(r1) /* save r0 in stackframe */
608 std r10,GPR1(r1) /* save r1 in stackframe */
609 EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
610 EXCEPTION_PROLOG_COMMON_3(0xe60)
611 addi r3,r1,STACK_FRAME_OVERHEAD
612 bl hmi_exception_realmode
613 /* Windup the stack. */
614 /* Clear MSR_RI before setting SRR0 and SRR1. */
616 mfmsr r9 /* get MSR value */
618 mtmsrd r9,1 /* Clear MSR_RI */
619 /* Move original HSRR0 and HSRR1 into the respective regs */
637 /* restore original r1. */
641 * Go to virtual mode and pull the HMI event information from
644 .globl hmi_exception_after_realmode
645 hmi_exception_after_realmode:
647 EXCEPTION_PROLOG_0(PACA_EXGEN)
650 MASKABLE_EXCEPTION_HV_OOL(0xe82, h_doorbell)
651 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe82)
653 /* moved from 0xf00 */
654 STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
655 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
656 STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
657 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
658 STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
659 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
660 STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
661 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf60)
662 STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable)
663 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82)
666 * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
667 * - If it was a decrementer interrupt, we bump the dec to max and and return.
668 * - If it was a doorbell we return immediately since doorbells are edge
669 * triggered and won't automatically refire.
670 * - If it was a HMI we return immediately since we handled it in realmode
671 * and it won't refire.
672 * - else we hard disable and return.
673 * This is called with r10 containing the value to OR to the paca field.
675 #define MASKED_INTERRUPT(_H) \
676 masked_##_H##interrupt: \
677 std r11,PACA_EXGEN+EX_R11(r13); \
678 lbz r11,PACAIRQHAPPENED(r13); \
680 stb r11,PACAIRQHAPPENED(r13); \
681 cmpwi r10,PACA_IRQ_DEC; \
684 ori r10,r10,0xffff; \
685 mtspr SPRN_DEC,r10; \
687 1: cmpwi r10,PACA_IRQ_DBELL; \
689 cmpwi r10,PACA_IRQ_HMI; \
691 mfspr r10,SPRN_##_H##SRR1; \
692 rldicl r10,r10,48,1; /* clear MSR_EE */ \
694 mtspr SPRN_##_H##SRR1,r10; \
696 ld r9,PACA_EXGEN+EX_R9(r13); \
697 ld r10,PACA_EXGEN+EX_R10(r13); \
698 ld r11,PACA_EXGEN+EX_R11(r13); \
707 * Called from arch_local_irq_enable when an interrupt needs
708 * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate
709 * which kind of interrupt. MSR:EE is already off. We generate a
710 * stackframe like if a real interrupt had happened.
712 * Note: While MSR:EE is off, we need to make sure that _MSR
713 * in the generated frame has EE set to 1 or the exception
714 * handler will not properly re-enable them.
716 _GLOBAL(__replay_interrupt)
717 /* We are going to jump to the exception common code which
718 * will retrieve various register values from the PACA which
719 * we don't give a damn about, so we don't bother storing them.
726 beq decrementer_common
728 beq hardware_interrupt_common
731 beq h_doorbell_common
734 beq doorbell_super_common
735 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
738 #ifdef CONFIG_PPC_PSERIES
740 * Vectors for the FWNMI option. Share common code.
742 .globl system_reset_fwnmi
745 HMT_MEDIUM_PPR_DISCARD
746 SET_SCRATCH0(r13) /* save r13 */
747 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
750 #endif /* CONFIG_PPC_PSERIES */
754 * This is used for when the SLB miss handler has to go virtual,
755 * which doesn't happen for now anymore but will once we re-implement
756 * dynamic VSIDs for shared page tables
758 slb_miss_user_pseries:
759 std r10,PACA_EXGEN+EX_R10(r13)
760 std r11,PACA_EXGEN+EX_R11(r13)
761 std r12,PACA_EXGEN+EX_R12(r13)
763 ld r11,PACA_EXSLB+EX_R9(r13)
764 ld r12,PACA_EXSLB+EX_R3(r13)
765 std r10,PACA_EXGEN+EX_R13(r13)
766 std r11,PACA_EXGEN+EX_R9(r13)
767 std r12,PACA_EXGEN+EX_R3(r13)
770 mfspr r11,SRR0 /* save SRR0 */
771 ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
772 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
774 mfspr r12,SRR1 /* and SRR1 */
777 b . /* prevent spec. execution */
778 #endif /* __DISABLED__ */
780 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
781 kvmppc_skip_interrupt:
783 * Here all GPRs are unchanged from when the interrupt happened
784 * except for r13, which is saved in SPRG_SCRATCH0.
793 kvmppc_skip_Hinterrupt:
795 * Here all GPRs are unchanged from when the interrupt happened
796 * except for r13, which is saved in SPRG_SCRATCH0.
798 mfspr r13, SPRN_HSRR0
800 mtspr SPRN_HSRR0, r13
807 * Code from here down to __end_handlers is invoked from the
808 * exception prologs above. Because the prologs assemble the
809 * addresses of these handlers using the LOAD_HANDLER macro,
810 * which uses an ori instruction, these handlers must be in
811 * the first 64k of the kernel image.
814 /*** Common interrupt handlers ***/
816 STD_EXCEPTION_COMMON(0x100, system_reset, system_reset_exception)
818 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
819 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, timer_interrupt)
820 STD_EXCEPTION_COMMON(0x980, hdecrementer, hdec_interrupt)
821 #ifdef CONFIG_PPC_DOORBELL
822 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, doorbell_exception)
824 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, unknown_exception)
826 STD_EXCEPTION_COMMON(0xb00, trap_0b, unknown_exception)
827 STD_EXCEPTION_COMMON(0xd00, single_step, single_step_exception)
828 STD_EXCEPTION_COMMON(0xe00, trap_0e, unknown_exception)
829 STD_EXCEPTION_COMMON(0xe40, emulation_assist, emulation_assist_interrupt)
830 STD_EXCEPTION_COMMON_ASYNC(0xe60, hmi_exception, handle_hmi_exception)
831 #ifdef CONFIG_PPC_DOORBELL
832 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, doorbell_exception)
834 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, unknown_exception)
836 STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, performance_monitor_exception)
837 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, instruction_breakpoint_exception)
838 STD_EXCEPTION_COMMON(0x1502, denorm, unknown_exception)
839 #ifdef CONFIG_ALTIVEC
840 STD_EXCEPTION_COMMON(0x1700, altivec_assist, altivec_assist_exception)
842 STD_EXCEPTION_COMMON(0x1700, altivec_assist, unknown_exception)
844 #ifdef CONFIG_CBE_RAS
845 STD_EXCEPTION_COMMON(0x1200, cbe_system_error, cbe_system_error_exception)
846 STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, cbe_maintenance_exception)
847 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, cbe_thermal_exception)
848 #endif /* CONFIG_CBE_RAS */
851 * Relocation-on interrupts: A subset of the interrupts can be delivered
852 * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering
853 * it. Addresses are the same as the original interrupt addresses, but
854 * offset by 0xc000000000004000.
855 * It's impossible to receive interrupts below 0x300 via this mechanism.
856 * KVM: None of these traps are from the guest ; anything that escalated
857 * to HV=1 from HV=0 is delivered via real mode handlers.
861 * This uses the standard macro, since the original 0x300 vector
862 * only has extra guff for STAB-based processors -- which never
865 STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access)
867 .globl data_access_slb_relon_pSeries
868 data_access_slb_relon_pSeries:
870 EXCEPTION_PROLOG_0(PACA_EXSLB)
871 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
872 std r3,PACA_EXSLB+EX_R3(r13)
875 #ifndef CONFIG_RELOCATABLE
879 * We can't just use a direct branch to slb_miss_realmode
880 * because the distance from here to there depends on where
881 * the kernel ends up being put.
884 ld r10,PACAKBASE(r13)
885 LOAD_HANDLER(r10, slb_miss_realmode)
890 STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access)
892 .globl instruction_access_slb_relon_pSeries
893 instruction_access_slb_relon_pSeries:
895 EXCEPTION_PROLOG_0(PACA_EXSLB)
896 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
897 std r3,PACA_EXSLB+EX_R3(r13)
898 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
900 #ifndef CONFIG_RELOCATABLE
904 ld r10,PACAKBASE(r13)
905 LOAD_HANDLER(r10, slb_miss_realmode)
911 .globl hardware_interrupt_relon_pSeries;
912 .globl hardware_interrupt_relon_hv;
913 hardware_interrupt_relon_pSeries:
914 hardware_interrupt_relon_hv:
916 _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
918 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
919 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
920 STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment)
921 STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check)
922 STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable)
923 MASKABLE_RELON_EXCEPTION_PSERIES(0x4900, 0x900, decrementer)
924 STD_RELON_EXCEPTION_HV(0x4980, 0x982, hdecrementer)
925 MASKABLE_RELON_EXCEPTION_PSERIES(0x4a00, 0xa00, doorbell_super)
926 STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b)
929 .globl system_call_relon_pSeries
930 system_call_relon_pSeries:
933 SYSCALL_PSERIES_2_DIRECT
936 STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step)
939 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
942 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
945 emulation_assist_relon_trampoline:
947 EXCEPTION_PROLOG_0(PACA_EXGEN)
948 b emulation_assist_relon_hv
951 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
954 h_doorbell_relon_trampoline:
956 EXCEPTION_PROLOG_0(PACA_EXGEN)
957 b h_doorbell_relon_hv
960 performance_monitor_relon_pseries_trampoline:
962 EXCEPTION_PROLOG_0(PACA_EXGEN)
963 b performance_monitor_relon_pSeries
966 altivec_unavailable_relon_pseries_trampoline:
968 EXCEPTION_PROLOG_0(PACA_EXGEN)
969 b altivec_unavailable_relon_pSeries
972 vsx_unavailable_relon_pseries_trampoline:
974 EXCEPTION_PROLOG_0(PACA_EXGEN)
975 b vsx_unavailable_relon_pSeries
978 facility_unavailable_relon_trampoline:
980 EXCEPTION_PROLOG_0(PACA_EXGEN)
981 b facility_unavailable_relon_pSeries
984 hv_facility_unavailable_relon_trampoline:
986 EXCEPTION_PROLOG_0(PACA_EXGEN)
987 b hv_facility_unavailable_relon_hv
989 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
990 #ifdef CONFIG_PPC_DENORMALISATION
992 b denorm_exception_hv
994 STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
996 /* Other future vectors */
998 .globl __end_interrupts
1002 system_call_entry_direct:
1003 #if defined(CONFIG_RELOCATABLE)
1004 /* The first level prologue may have used LR to get here, saving
1005 * orig in r10. To save hacking/ifdeffing common code, restore here.
1010 b system_call_common
1012 ppc64_runlatch_on_trampoline:
1013 b __ppc64_runlatch_on
1016 * Here r13 points to the paca, r9 contains the saved CR,
1017 * SRR0 and SRR1 are saved in r11 and r12,
1018 * r9 - r13 are saved in paca->exgen.
1021 .globl data_access_common
1024 std r10,PACA_EXGEN+EX_DAR(r13)
1025 mfspr r10,SPRN_DSISR
1026 stw r10,PACA_EXGEN+EX_DSISR(r13)
1027 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
1028 RECONCILE_IRQ_STATE(r10, r11)
1030 ld r3,PACA_EXGEN+EX_DAR(r13)
1031 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1033 b do_hash_page /* Try to handle as hpte fault */
1036 .globl h_data_storage_common
1037 h_data_storage_common:
1039 std r10,PACA_EXGEN+EX_DAR(r13)
1040 mfspr r10,SPRN_HDSISR
1041 stw r10,PACA_EXGEN+EX_DSISR(r13)
1042 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
1044 RECONCILE_IRQ_STATE(r10, r11)
1045 addi r3,r1,STACK_FRAME_OVERHEAD
1046 bl unknown_exception
1050 .globl instruction_access_common
1051 instruction_access_common:
1052 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
1053 RECONCILE_IRQ_STATE(r10, r11)
1056 andis. r4,r12,0x5820
1058 b do_hash_page /* Try to handle as hpte fault */
1060 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, unknown_exception)
1063 * Here is the common SLB miss user that is used when going to virtual
1064 * mode for SLB misses, that is currently not used
1068 .globl slb_miss_user_common
1069 slb_miss_user_common:
1071 std r3,PACA_EXGEN+EX_DAR(r13)
1072 stw r9,PACA_EXGEN+EX_CCR(r13)
1073 std r10,PACA_EXGEN+EX_LR(r13)
1074 std r11,PACA_EXGEN+EX_SRR0(r13)
1075 bl slb_allocate_user
1077 ld r10,PACA_EXGEN+EX_LR(r13)
1078 ld r3,PACA_EXGEN+EX_R3(r13)
1079 lwz r9,PACA_EXGEN+EX_CCR(r13)
1080 ld r11,PACA_EXGEN+EX_SRR0(r13)
1084 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1085 beq- unrecov_user_slb
1093 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
1099 ld r9,PACA_EXGEN+EX_R9(r13)
1100 ld r10,PACA_EXGEN+EX_R10(r13)
1101 ld r11,PACA_EXGEN+EX_R11(r13)
1102 ld r12,PACA_EXGEN+EX_R12(r13)
1103 ld r13,PACA_EXGEN+EX_R13(r13)
1108 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
1109 ld r4,PACA_EXGEN+EX_DAR(r13)
1116 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
1117 RECONCILE_IRQ_STATE(r10, r11)
1119 1: addi r3,r1,STACK_FRAME_OVERHEAD
1120 bl unrecoverable_exception
1123 #endif /* __DISABLED__ */
1127 * Machine check is different because we use a different
1128 * save area: PACA_EXMC instead of PACA_EXGEN.
1131 .globl machine_check_common
1132 machine_check_common:
1135 std r10,PACA_EXGEN+EX_DAR(r13)
1136 mfspr r10,SPRN_DSISR
1137 stw r10,PACA_EXGEN+EX_DSISR(r13)
1138 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
1140 RECONCILE_IRQ_STATE(r10, r11)
1141 ld r3,PACA_EXGEN+EX_DAR(r13)
1142 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1146 addi r3,r1,STACK_FRAME_OVERHEAD
1147 bl machine_check_exception
1151 .globl alignment_common
1154 std r10,PACA_EXGEN+EX_DAR(r13)
1155 mfspr r10,SPRN_DSISR
1156 stw r10,PACA_EXGEN+EX_DSISR(r13)
1157 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
1158 ld r3,PACA_EXGEN+EX_DAR(r13)
1159 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1163 RECONCILE_IRQ_STATE(r10, r11)
1164 addi r3,r1,STACK_FRAME_OVERHEAD
1165 bl alignment_exception
1169 .globl program_check_common
1170 program_check_common:
1171 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
1173 RECONCILE_IRQ_STATE(r10, r11)
1174 addi r3,r1,STACK_FRAME_OVERHEAD
1175 bl program_check_exception
1179 .globl fp_unavailable_common
1180 fp_unavailable_common:
1181 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
1182 bne 1f /* if from user, just load it up */
1184 RECONCILE_IRQ_STATE(r10, r11)
1185 addi r3,r1,STACK_FRAME_OVERHEAD
1186 bl kernel_fp_unavailable_exception
1189 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1191 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1192 * transaction), go do TM stuff
1194 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1196 END_FTR_SECTION_IFSET(CPU_FTR_TM)
1199 b fast_exception_return
1200 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1201 2: /* User process was in a transaction */
1203 RECONCILE_IRQ_STATE(r10, r11)
1204 addi r3,r1,STACK_FRAME_OVERHEAD
1205 bl fp_unavailable_tm
1209 .globl altivec_unavailable_common
1210 altivec_unavailable_common:
1211 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
1212 #ifdef CONFIG_ALTIVEC
1215 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1216 BEGIN_FTR_SECTION_NESTED(69)
1217 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1218 * transaction), go do TM stuff
1220 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1222 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1225 b fast_exception_return
1226 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1227 2: /* User process was in a transaction */
1229 RECONCILE_IRQ_STATE(r10, r11)
1230 addi r3,r1,STACK_FRAME_OVERHEAD
1231 bl altivec_unavailable_tm
1235 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1238 RECONCILE_IRQ_STATE(r10, r11)
1239 addi r3,r1,STACK_FRAME_OVERHEAD
1240 bl altivec_unavailable_exception
1244 .globl vsx_unavailable_common
1245 vsx_unavailable_common:
1246 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
1250 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1251 BEGIN_FTR_SECTION_NESTED(69)
1252 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1253 * transaction), go do TM stuff
1255 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1257 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1260 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1261 2: /* User process was in a transaction */
1263 RECONCILE_IRQ_STATE(r10, r11)
1264 addi r3,r1,STACK_FRAME_OVERHEAD
1265 bl vsx_unavailable_tm
1269 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1272 RECONCILE_IRQ_STATE(r10, r11)
1273 addi r3,r1,STACK_FRAME_OVERHEAD
1274 bl vsx_unavailable_exception
1277 STD_EXCEPTION_COMMON(0xf60, facility_unavailable, facility_unavailable_exception)
1278 STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, facility_unavailable_exception)
1281 .globl __end_handlers
1284 /* Equivalents to the above handlers for relocation-on interrupt vectors */
1285 STD_RELON_EXCEPTION_HV_OOL(0xe40, emulation_assist)
1286 MASKABLE_RELON_EXCEPTION_HV_OOL(0xe80, h_doorbell)
1288 STD_RELON_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
1289 STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
1290 STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
1291 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1292 STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1294 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1296 * Data area reserved for FWNMI option.
1297 * This address (0x7000) is fixed by the RPA.
1300 .globl fwnmi_data_area
1303 /* pseries and powernv need to keep the whole page from
1304 * 0x7000 to 0x8000 free for use by the firmware
1307 #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
1309 #ifdef CONFIG_PPC_POWERNV
1310 _GLOBAL(opal_mc_secondary_handler)
1311 HMT_MEDIUM_PPR_DISCARD
1316 std r3,PACA_OPAL_MC_EVT(r13)
1317 ld r13,OPAL_MC_SRR0(r3)
1319 ld r13,OPAL_MC_SRR1(r3)
1321 ld r3,OPAL_MC_GPR3(r3)
1323 b machine_check_pSeries
1324 #endif /* CONFIG_PPC_POWERNV */
1327 #define MACHINE_CHECK_HANDLER_WINDUP \
1328 /* Clear MSR_RI before setting SRR0 and SRR1. */\
1330 mfmsr r9; /* get MSR value */ \
1332 mtmsrd r9,1; /* Clear MSR_RI */ \
1333 /* Move original SRR0 and SRR1 into the respective regs */ \
1335 mtspr SPRN_SRR1,r9; \
1337 mtspr SPRN_SRR0,r3; \
1345 REST_8GPRS(2, r1); \
1349 /* Decrement paca->in_mce. */ \
1350 lhz r12,PACA_IN_MCE(r13); \
1352 sth r12,PACA_IN_MCE(r13); \
1354 REST_2GPRS(12, r1); \
1355 /* restore original r1. */ \
1359 * Handle machine check early in real mode. We come here with
1360 * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack.
1363 .globl machine_check_handle_early
1364 machine_check_handle_early:
1365 std r0,GPR0(r1) /* Save r0 */
1366 EXCEPTION_PROLOG_COMMON_3(0x200)
1368 addi r3,r1,STACK_FRAME_OVERHEAD
1369 bl machine_check_early
1370 std r3,RESULT(r1) /* Save result */
1372 #ifdef CONFIG_PPC_P7_NAP
1374 * Check if thread was in power saving mode. We come here when any
1375 * of the following is true:
1376 * a. thread wasn't in power saving mode
1377 * b. thread was in power saving mode with no state loss or
1378 * supervisor state loss
1380 * Go back to nap again if (b) is true.
1382 rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */
1383 beq 4f /* No, it wasn;t */
1384 /* Thread was in power saving mode. Go back to nap again. */
1387 /* Supervisor state loss */
1389 stb r0,PACA_NAPSTATELOST(r13)
1390 3: bl machine_check_queue_event
1391 MACHINE_CHECK_HANDLER_WINDUP
1394 b power7_enter_nap_mode
1398 * Check if we are coming from hypervisor userspace. If yes then we
1399 * continue in host kernel in V mode to deliver the MC event.
1401 rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */
1403 andi. r11,r12,MSR_PR /* See if coming from user. */
1404 bne 9f /* continue in V mode if we are. */
1407 #ifdef CONFIG_KVM_BOOK3S_64_HV
1409 * We are coming from kernel context. Check if we are coming from
1410 * guest. if yes, then we can continue. We will fall through
1411 * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest.
1413 lbz r11,HSTATE_IN_GUEST(r13)
1414 cmpwi r11,0 /* Check if coming from guest */
1415 bne 9f /* continue if we are. */
1418 * At this point we are not sure about what context we come from.
1419 * Queue up the MCE event and return from the interrupt.
1420 * But before that, check if this is an un-recoverable exception.
1421 * If yes, then stay on emergency stack and panic.
1423 andi. r11,r12,MSR_RI
1425 1: mfspr r11,SPRN_SRR0
1426 ld r10,PACAKBASE(r13)
1427 LOAD_HANDLER(r10,unrecover_mce)
1429 ld r10,PACAKMSR(r13)
1431 * We are going down. But there are chances that we might get hit by
1432 * another MCE during panic path and we may run into unstable state
1433 * with no way out. Hence, turn ME bit off while going down, so that
1434 * when another MCE is hit during panic path, system will checkstop
1435 * and hypervisor will get restarted cleanly by SP.
1438 andc r10,r10,r3 /* Turn off MSR_ME */
1444 * Check if we have successfully handled/recovered from error, if not
1445 * then stay on emergency stack and panic.
1447 ld r3,RESULT(r1) /* Load result */
1448 cmpdi r3,0 /* see if we handled MCE successfully */
1450 beq 1b /* if !handled then panic */
1452 * Return from MC interrupt.
1453 * Queue up the MCE event so that we can log it later, while
1454 * returning from kernel or opal call.
1456 bl machine_check_queue_event
1457 MACHINE_CHECK_HANDLER_WINDUP
1460 /* Deliver the machine check to host kernel in V mode. */
1461 MACHINE_CHECK_HANDLER_WINDUP
1462 b machine_check_pSeries
1465 /* Invoke machine_check_exception to print MCE event and panic. */
1466 addi r3,r1,STACK_FRAME_OVERHEAD
1467 bl machine_check_exception
1469 * We will not reach here. Even if we did, there is no way out. Call
1470 * unrecoverable_exception and die.
1472 1: addi r3,r1,STACK_FRAME_OVERHEAD
1473 bl unrecoverable_exception
1476 * r13 points to the PACA, r9 contains the saved CR,
1477 * r12 contain the saved SRR1, SRR0 is still ready for return
1478 * r3 has the faulting address
1479 * r9 - r13 are saved in paca->exslb.
1480 * r3 is saved in paca->slb_r3
1481 * We assume we aren't going to take any exceptions during this procedure.
1485 #ifdef CONFIG_RELOCATABLE
1489 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1490 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
1492 bl slb_allocate_realmode
1494 /* All done -- return from exception. */
1496 ld r10,PACA_EXSLB+EX_LR(r13)
1497 ld r3,PACA_EXSLB+EX_R3(r13)
1498 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1502 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1508 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
1511 RESTORE_PPR_PACA(PACA_EXSLB, r9)
1512 ld r9,PACA_EXSLB+EX_R9(r13)
1513 ld r10,PACA_EXSLB+EX_R10(r13)
1514 ld r11,PACA_EXSLB+EX_R11(r13)
1515 ld r12,PACA_EXSLB+EX_R12(r13)
1516 ld r13,PACA_EXSLB+EX_R13(r13)
1518 b . /* prevent speculative execution */
1520 2: mfspr r11,SPRN_SRR0
1521 ld r10,PACAKBASE(r13)
1522 LOAD_HANDLER(r10,unrecov_slb)
1524 ld r10,PACAKMSR(r13)
1530 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
1531 RECONCILE_IRQ_STATE(r10, r11)
1533 1: addi r3,r1,STACK_FRAME_OVERHEAD
1534 bl unrecoverable_exception
1538 #ifdef CONFIG_PPC_970_NAP
1541 std r9,TI_LOCAL_FLAGS(r11)
1542 ld r10,_LINK(r1) /* make idle task do the */
1543 std r10,_NIP(r1) /* equivalent of a blr */
1555 andis. r0,r4,0xa410 /* weird error? */
1556 bne- handle_page_fault /* if not, try to insert a HPTE */
1557 andis. r0,r4,DSISR_DABRMATCH@h
1558 bne- handle_dabr_fault
1559 CURRENT_THREAD_INFO(r11, r1)
1560 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
1561 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
1562 bne 77f /* then don't call hash_page now */
1564 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
1565 * accessing a userspace segment (even from the kernel). We assume
1566 * kernel addresses always have the high bit set.
1568 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
1569 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
1570 orc r0,r12,r0 /* MSR_PR | ~high_bit */
1571 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
1572 ori r4,r4,1 /* add _PAGE_PRESENT */
1573 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
1576 * r3 contains the faulting address
1577 * r4 contains the required access permissions
1578 * r5 contains the trap number
1580 * at return r3 = 0 for success, 1 for page fault, negative for error
1582 bl hash_page /* build HPTE if possible */
1583 cmpdi r3,0 /* see if hash_page succeeded */
1586 beq fast_exc_return_irq /* Return from exception on success */
1591 /* Here we have a page fault that hash_page can't handle. */
1595 addi r3,r1,STACK_FRAME_OVERHEAD
1601 addi r3,r1,STACK_FRAME_OVERHEAD
1606 /* We have a data breakpoint exception - handle it */
1611 addi r3,r1,STACK_FRAME_OVERHEAD
1613 12: b ret_from_except_lite
1616 /* We have a page fault that hash_page could handle but HV refused
1621 addi r3,r1,STACK_FRAME_OVERHEAD
1627 * We come here as a result of a DSI at a point where we don't want
1628 * to call hash_page, such as when we are accessing memory (possibly
1629 * user memory) inside a PMU interrupt that occurred while interrupts
1630 * were soft-disabled. We want to invoke the exception handler for
1631 * the access, or panic if there isn't a handler.
1635 addi r3,r1,STACK_FRAME_OVERHEAD
1641 * Here we have detected that the kernel stack pointer is bad.
1642 * R9 contains the saved CR, r13 points to the paca,
1643 * r10 contains the (bad) kernel stack pointer,
1644 * r11 and r12 contain the saved SRR0 and SRR1.
1645 * We switch to using an emergency stack, save the registers there,
1646 * and call kernel_bad_stack(), which panics.
1649 ld r1,PACAEMERGSP(r13)
1650 subi r1,r1,64+INT_FRAME_SIZE
1656 mfspr r12,SPRN_DSISR
1682 std r10,ORIG_GPR3(r1)
1683 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
1686 lhz r12,PACA_TRAP_SAVE(r13)
1688 addi r11,r1,INT_FRAME_SIZE
1693 ld r11,exception_marker@toc(r2)
1695 std r11,STACK_FRAME_OVERHEAD-16(r1)
1696 1: addi r3,r1,STACK_FRAME_OVERHEAD