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 - 0x2fff : pSeries Interrupt prologs
23 * 0x3000 - 0x5fff : interrupt support common interrupt prologs
24 * 0x6000 - 0x6fff : Initial (CPU0) segment table
25 * 0x7000 - 0x7fff : FWNMI data area
26 * 0x8000 - : Early init and support code
30 * This is the start of the interrupt handlers for pSeries
31 * This code runs with relocation off.
32 * Code from here to __end_interrupts gets copied down to real
33 * address 0x100 when we are running a relocatable kernel.
34 * Therefore any relative branches in this section must only
35 * branch to labels in this section.
38 .globl __start_interrupts
41 .globl system_reset_pSeries;
45 #ifdef CONFIG_PPC_P7_NAP
47 /* Running native on arch 2.06 or later, check if we are
48 * waking up from nap. We only handle no state loss and
49 * supervisor state loss. We do -not- handle hypervisor
50 * state loss at this time.
53 rlwinm. r13,r13,47-31,30,31
56 /* waking up from powersave (nap) state */
58 /* Total loss of HV state is fatal, we could try to use the
59 * PIR to locate a PACA, then use an emergency stack etc...
60 * but for now, let's just stay stuck here
65 #ifdef CONFIG_KVM_BOOK3S_64_HV
66 li r0,KVM_HWTHREAD_IN_KERNEL
67 stb r0,HSTATE_HWTHREAD_STATE(r13)
68 /* Order setting hwthread_state vs. testing hwthread_req */
70 lbz r0,HSTATE_HWTHREAD_REQ(r13)
78 b .power7_wakeup_noloss
79 2: b .power7_wakeup_loss
81 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
82 #endif /* CONFIG_PPC_P7_NAP */
83 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
87 machine_check_pSeries_1:
88 /* This is moved out of line as it can be patched by FW, but
89 * some code path might still want to branch into the original
92 b machine_check_pSeries
95 .globl data_access_pSeries
100 b data_access_check_stab
101 data_access_not_stab:
102 END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
103 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
107 .globl data_access_slb_pSeries
108 data_access_slb_pSeries:
111 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
112 std r3,PACA_EXSLB+EX_R3(r13)
115 /* Keep that around for when we re-implement dynamic VSIDs */
117 bge slb_miss_user_pseries
118 #endif /* __DISABLED__ */
120 #ifndef CONFIG_RELOCATABLE
124 * We can't just use a direct branch to .slb_miss_realmode
125 * because the distance from here to there depends on where
126 * the kernel ends up being put.
129 ld r10,PACAKBASE(r13)
130 LOAD_HANDLER(r10, .slb_miss_realmode)
135 STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access)
138 .globl instruction_access_slb_pSeries
139 instruction_access_slb_pSeries:
142 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
143 std r3,PACA_EXSLB+EX_R3(r13)
144 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
146 /* Keep that around for when we re-implement dynamic VSIDs */
148 bge slb_miss_user_pseries
149 #endif /* __DISABLED__ */
151 #ifndef CONFIG_RELOCATABLE
155 ld r10,PACAKBASE(r13)
156 LOAD_HANDLER(r10, .slb_miss_realmode)
161 /* We open code these as we can't have a ". = x" (even with
162 * x = "." within a feature section
165 .globl hardware_interrupt_pSeries;
166 .globl hardware_interrupt_hv;
167 hardware_interrupt_pSeries:
168 hardware_interrupt_hv:
170 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
171 EXC_HV, SOFTEN_TEST_HV)
172 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
174 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
175 EXC_STD, SOFTEN_TEST_HV_201)
176 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
177 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
179 STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
180 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
182 STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
183 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
185 STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
186 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
188 MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer)
189 MASKABLE_EXCEPTION_HV(0x980, 0x982, decrementer)
191 STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a)
192 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
194 STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
195 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
198 .globl system_call_pSeries
201 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
204 std r9,PACA_EXGEN+EX_R9(r13)
205 std r10,PACA_EXGEN+EX_R10(r13)
213 END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
218 ld r10,PACAKBASE(r13)
219 LOAD_HANDLER(r10, system_call_entry)
224 b . /* prevent speculative execution */
226 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
228 /* Fast LE/BE switch system call */
229 1: mfspr r12,SPRN_SRR1
232 rfid /* return to userspace */
235 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
236 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
238 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
239 * out of line to handle them
246 b emulation_assist_hv
252 /* We need to deal with the Altivec unavailable exception
253 * here which is at 0xf20, thus in the middle of the
254 * prolog code of the PerformanceMonitor one. A little
255 * trickery is thus necessary
257 performance_monitor_pSeries_1:
259 b performance_monitor_pSeries
261 altivec_unavailable_pSeries_1:
263 b altivec_unavailable_pSeries
265 vsx_unavailable_pSeries_1:
267 b vsx_unavailable_pSeries
269 #ifdef CONFIG_CBE_RAS
270 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
271 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
272 #endif /* CONFIG_CBE_RAS */
274 STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
275 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
277 #ifdef CONFIG_CBE_RAS
278 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
279 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
280 #endif /* CONFIG_CBE_RAS */
282 STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
283 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
285 #ifdef CONFIG_CBE_RAS
286 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
287 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
288 #endif /* CONFIG_CBE_RAS */
292 /*** Out of line interrupts support ***/
294 /* moved from 0x200 */
295 machine_check_pSeries:
296 .globl machine_check_fwnmi
299 SET_SCRATCH0(r13) /* save r13 */
300 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common,
301 EXC_STD, KVMTEST, 0x200)
302 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
304 /* moved from 0x300 */
305 data_access_check_stab:
307 std r9,PACA_EXSLB+EX_R9(r13)
308 std r10,PACA_EXSLB+EX_R10(r13)
312 rlwimi r10,r9,16,0x20
313 #ifdef CONFIG_KVM_BOOK3S_PR
314 lbz r9,HSTATE_IN_GUEST(r13)
315 rlwimi r10,r9,8,0x300
319 beq do_stab_bolted_pSeries
321 ld r9,PACA_EXSLB+EX_R9(r13)
322 ld r10,PACA_EXSLB+EX_R10(r13)
323 b data_access_not_stab
324 do_stab_bolted_pSeries:
325 std r11,PACA_EXSLB+EX_R11(r13)
326 std r12,PACA_EXSLB+EX_R12(r13)
328 std r10,PACA_EXSLB+EX_R13(r13)
329 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
331 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
332 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
333 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
334 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
335 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
336 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
339 /* moved from 0xe00 */
340 STD_EXCEPTION_HV(., 0xe02, h_data_storage)
341 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
342 STD_EXCEPTION_HV(., 0xe22, h_instr_storage)
343 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
344 STD_EXCEPTION_HV(., 0xe42, emulation_assist)
345 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
346 STD_EXCEPTION_HV(., 0xe62, hmi_exception) /* need to flush cache ? */
347 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
349 /* moved from 0xf00 */
350 STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor)
351 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
352 STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable)
353 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
354 STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable)
355 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
358 * An interrupt came in while soft-disabled. We set paca->irq_happened,
359 * then, if it was a decrementer interrupt, we bump the dec to max and
360 * and return, else we hard disable and return. This is called with
361 * r10 containing the value to OR to the paca field.
363 #define MASKED_INTERRUPT(_H) \
364 masked_##_H##interrupt: \
365 std r11,PACA_EXGEN+EX_R11(r13); \
366 lbz r11,PACAIRQHAPPENED(r13); \
368 stb r11,PACAIRQHAPPENED(r13); \
369 andi. r10,r10,PACA_IRQ_DEC; \
372 ori r10,r10,0xffff; \
373 mtspr SPRN_DEC,r10; \
375 1: mfspr r10,SPRN_##_H##SRR1; \
376 rldicl r10,r10,48,1; /* clear MSR_EE */ \
378 mtspr SPRN_##_H##SRR1,r10; \
380 ld r9,PACA_EXGEN+EX_R9(r13); \
381 ld r10,PACA_EXGEN+EX_R10(r13); \
382 ld r11,PACA_EXGEN+EX_R11(r13); \
391 * Called from arch_local_irq_enable when an interrupt needs
392 * to be resent. r3 contains 0x500 or 0x900 to indicate which
393 * kind of interrupt. MSR:EE is already off. We generate a
394 * stackframe like if a real interrupt had happened.
396 * Note: While MSR:EE is off, we need to make sure that _MSR
397 * in the generated frame has EE set to 1 or the exception
398 * handler will not properly re-enable them.
400 _GLOBAL(__replay_interrupt)
401 /* We are going to jump to the exception common code which
402 * will retrieve various register values from the PACA which
403 * we don't give a damn about, so we don't bother storing them.
410 bne decrementer_common
411 b hardware_interrupt_common
413 #ifdef CONFIG_PPC_PSERIES
415 * Vectors for the FWNMI option. Share common code.
417 .globl system_reset_fwnmi
421 SET_SCRATCH0(r13) /* save r13 */
422 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
425 #endif /* CONFIG_PPC_PSERIES */
429 * This is used for when the SLB miss handler has to go virtual,
430 * which doesn't happen for now anymore but will once we re-implement
431 * dynamic VSIDs for shared page tables
433 slb_miss_user_pseries:
434 std r10,PACA_EXGEN+EX_R10(r13)
435 std r11,PACA_EXGEN+EX_R11(r13)
436 std r12,PACA_EXGEN+EX_R12(r13)
438 ld r11,PACA_EXSLB+EX_R9(r13)
439 ld r12,PACA_EXSLB+EX_R3(r13)
440 std r10,PACA_EXGEN+EX_R13(r13)
441 std r11,PACA_EXGEN+EX_R9(r13)
442 std r12,PACA_EXGEN+EX_R3(r13)
445 mfspr r11,SRR0 /* save SRR0 */
446 ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
447 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
449 mfspr r12,SRR1 /* and SRR1 */
452 b . /* prevent spec. execution */
453 #endif /* __DISABLED__ */
456 .globl __end_interrupts
460 * Code from here down to __end_handlers is invoked from the
461 * exception prologs above. Because the prologs assemble the
462 * addresses of these handlers using the LOAD_HANDLER macro,
463 * which uses an addi instruction, these handlers must be in
464 * the first 32k of the kernel image.
467 /*** Common interrupt handlers ***/
469 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
472 * Machine check is different because we use a different
473 * save area: PACA_EXMC instead of PACA_EXGEN.
476 .globl machine_check_common
477 machine_check_common:
478 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
482 addi r3,r1,STACK_FRAME_OVERHEAD
483 bl .machine_check_exception
486 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
487 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt)
488 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
489 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
490 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
491 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
492 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception)
493 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception)
494 STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception)
495 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
496 #ifdef CONFIG_ALTIVEC
497 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
499 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
501 #ifdef CONFIG_CBE_RAS
502 STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
503 STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
504 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
505 #endif /* CONFIG_CBE_RAS */
511 ppc64_runlatch_on_trampoline:
512 b .__ppc64_runlatch_on
515 * Here we have detected that the kernel stack pointer is bad.
516 * R9 contains the saved CR, r13 points to the paca,
517 * r10 contains the (bad) kernel stack pointer,
518 * r11 and r12 contain the saved SRR0 and SRR1.
519 * We switch to using an emergency stack, save the registers there,
520 * and call kernel_bad_stack(), which panics.
523 ld r1,PACAEMERGSP(r13)
524 subi r1,r1,64+INT_FRAME_SIZE
556 std r10,ORIG_GPR3(r1)
557 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
560 lhz r12,PACA_TRAP_SAVE(r13)
562 addi r11,r1,INT_FRAME_SIZE
567 ld r11,exception_marker@toc(r2)
569 std r11,STACK_FRAME_OVERHEAD-16(r1)
570 1: addi r3,r1,STACK_FRAME_OVERHEAD
575 * Here r13 points to the paca, r9 contains the saved CR,
576 * SRR0 and SRR1 are saved in r11 and r12,
577 * r9 - r13 are saved in paca->exgen.
580 .globl data_access_common
583 std r10,PACA_EXGEN+EX_DAR(r13)
585 stw r10,PACA_EXGEN+EX_DSISR(r13)
586 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
589 ld r3,PACA_EXGEN+EX_DAR(r13)
590 lwz r4,PACA_EXGEN+EX_DSISR(r13)
592 b .do_hash_page /* Try to handle as hpte fault */
595 .globl h_data_storage_common
596 h_data_storage_common:
598 std r10,PACA_EXGEN+EX_DAR(r13)
599 mfspr r10,SPRN_HDSISR
600 stw r10,PACA_EXGEN+EX_DSISR(r13)
601 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
604 addi r3,r1,STACK_FRAME_OVERHEAD
605 bl .unknown_exception
609 .globl instruction_access_common
610 instruction_access_common:
611 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
617 b .do_hash_page /* Try to handle as hpte fault */
619 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception)
622 * Here is the common SLB miss user that is used when going to virtual
623 * mode for SLB misses, that is currently not used
627 .globl slb_miss_user_common
628 slb_miss_user_common:
630 std r3,PACA_EXGEN+EX_DAR(r13)
631 stw r9,PACA_EXGEN+EX_CCR(r13)
632 std r10,PACA_EXGEN+EX_LR(r13)
633 std r11,PACA_EXGEN+EX_SRR0(r13)
634 bl .slb_allocate_user
636 ld r10,PACA_EXGEN+EX_LR(r13)
637 ld r3,PACA_EXGEN+EX_R3(r13)
638 lwz r9,PACA_EXGEN+EX_CCR(r13)
639 ld r11,PACA_EXGEN+EX_SRR0(r13)
643 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
644 beq- unrecov_user_slb
652 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
658 ld r9,PACA_EXGEN+EX_R9(r13)
659 ld r10,PACA_EXGEN+EX_R10(r13)
660 ld r11,PACA_EXGEN+EX_R11(r13)
661 ld r12,PACA_EXGEN+EX_R12(r13)
662 ld r13,PACA_EXGEN+EX_R13(r13)
667 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
668 ld r4,PACA_EXGEN+EX_DAR(r13)
675 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
678 1: addi r3,r1,STACK_FRAME_OVERHEAD
679 bl .unrecoverable_exception
682 #endif /* __DISABLED__ */
686 * r13 points to the PACA, r9 contains the saved CR,
687 * r12 contain the saved SRR1, SRR0 is still ready for return
688 * r3 has the faulting address
689 * r9 - r13 are saved in paca->exslb.
690 * r3 is saved in paca->slb_r3
691 * We assume we aren't going to take any exceptions during this procedure.
693 _GLOBAL(slb_miss_realmode)
695 #ifdef CONFIG_RELOCATABLE
699 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
700 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
702 bl .slb_allocate_realmode
704 /* All done -- return from exception. */
706 ld r10,PACA_EXSLB+EX_LR(r13)
707 ld r3,PACA_EXSLB+EX_R3(r13)
708 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
712 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
718 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
721 ld r9,PACA_EXSLB+EX_R9(r13)
722 ld r10,PACA_EXSLB+EX_R10(r13)
723 ld r11,PACA_EXSLB+EX_R11(r13)
724 ld r12,PACA_EXSLB+EX_R12(r13)
725 ld r13,PACA_EXSLB+EX_R13(r13)
727 b . /* prevent speculative execution */
729 2: mfspr r11,SPRN_SRR0
730 ld r10,PACAKBASE(r13)
731 LOAD_HANDLER(r10,unrecov_slb)
739 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
742 1: addi r3,r1,STACK_FRAME_OVERHEAD
743 bl .unrecoverable_exception
747 #ifdef CONFIG_PPC_970_NAP
750 std r9,TI_LOCAL_FLAGS(r11)
751 ld r10,_LINK(r1) /* make idle task do the */
752 std r10,_NIP(r1) /* equivalent of a blr */
757 .globl alignment_common
760 std r10,PACA_EXGEN+EX_DAR(r13)
762 stw r10,PACA_EXGEN+EX_DSISR(r13)
763 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
764 ld r3,PACA_EXGEN+EX_DAR(r13)
765 lwz r4,PACA_EXGEN+EX_DSISR(r13)
770 addi r3,r1,STACK_FRAME_OVERHEAD
771 bl .alignment_exception
775 .globl program_check_common
776 program_check_common:
777 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
780 addi r3,r1,STACK_FRAME_OVERHEAD
781 bl .program_check_exception
785 .globl fp_unavailable_common
786 fp_unavailable_common:
787 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
788 bne 1f /* if from user, just load it up */
791 addi r3,r1,STACK_FRAME_OVERHEAD
792 bl .kernel_fp_unavailable_exception
795 b fast_exception_return
798 .globl altivec_unavailable_common
799 altivec_unavailable_common:
800 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
801 #ifdef CONFIG_ALTIVEC
805 b fast_exception_return
807 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
811 addi r3,r1,STACK_FRAME_OVERHEAD
812 bl .altivec_unavailable_exception
816 .globl vsx_unavailable_common
817 vsx_unavailable_common:
818 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
824 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
828 addi r3,r1,STACK_FRAME_OVERHEAD
829 bl .vsx_unavailable_exception
833 .globl __end_handlers
840 _STATIC(do_hash_page)
844 andis. r0,r4,0xa410 /* weird error? */
845 bne- handle_page_fault /* if not, try to insert a HPTE */
846 andis. r0,r4,DSISR_DABRMATCH@h
847 bne- handle_dabr_fault
850 andis. r0,r4,0x0020 /* Is it a segment table fault? */
851 bne- do_ste_alloc /* If so handle it */
852 END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
854 clrrdi r11,r1,THREAD_SHIFT
855 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
856 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
857 bne 77f /* then don't call hash_page now */
859 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
860 * accessing a userspace segment (even from the kernel). We assume
861 * kernel addresses always have the high bit set.
863 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
864 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
865 orc r0,r12,r0 /* MSR_PR | ~high_bit */
866 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
867 ori r4,r4,1 /* add _PAGE_PRESENT */
868 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
871 * r3 contains the faulting address
872 * r4 contains the required access permissions
873 * r5 contains the trap number
875 * at return r3 = 0 for success, 1 for page fault, negative for error
877 bl .hash_page /* build HPTE if possible */
878 cmpdi r3,0 /* see if hash_page succeeded */
881 beq fast_exc_return_irq /* Return from exception on success */
886 /* Here we have a page fault that hash_page can't handle. */
890 addi r3,r1,STACK_FRAME_OVERHEAD
896 addi r3,r1,STACK_FRAME_OVERHEAD
901 /* We have a data breakpoint exception - handle it */
906 addi r3,r1,STACK_FRAME_OVERHEAD
908 12: b .ret_from_except_lite
911 /* We have a page fault that hash_page could handle but HV refused
916 addi r3,r1,STACK_FRAME_OVERHEAD
922 * We come here as a result of a DSI at a point where we don't want
923 * to call hash_page, such as when we are accessing memory (possibly
924 * user memory) inside a PMU interrupt that occurred while interrupts
925 * were soft-disabled. We want to invoke the exception handler for
926 * the access, or panic if there isn't a handler.
930 addi r3,r1,STACK_FRAME_OVERHEAD
935 /* here we have a segment miss */
937 bl .ste_allocate /* try to insert stab entry */
939 bne- handle_page_fault
940 b fast_exception_return
943 * r13 points to the PACA, r9 contains the saved CR,
944 * r11 and r12 contain the saved SRR0 and SRR1.
945 * r9 - r13 are saved in paca->exslb.
946 * We assume we aren't going to take any exceptions during this procedure.
947 * We assume (DAR >> 60) == 0xc.
950 _GLOBAL(do_stab_bolted)
951 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
952 std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
954 /* Hash to the primary group */
955 ld r10,PACASTABVIRT(r13)
958 rldimi r10,r11,7,52 /* r10 = first ste of the group */
961 /* This is a kernel address, so protovsid = ESID */
962 ASM_VSID_SCRAMBLE(r11, r9, 256M)
963 rldic r9,r11,12,16 /* r9 = vsid << 12 */
965 /* Search the primary group for a free entry */
966 1: ld r11,0(r10) /* Test valid bit of the current ste */
973 /* Stick for only searching the primary group for now. */
974 /* At least for now, we use a very simple random castout scheme */
975 /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
977 rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
980 /* r10 currently points to an ste one past the group of interest */
981 /* make it point to the randomly selected entry */
983 or r10,r10,r11 /* r10 is the entry to invalidate */
985 isync /* mark the entry invalid */
987 rldicl r11,r11,56,1 /* clear the valid bit */
992 clrrdi r11,r11,28 /* Get the esid part of the ste */
995 2: std r9,8(r10) /* Store the vsid part of the ste */
998 mfspr r11,SPRN_DAR /* Get the new esid */
999 clrrdi r11,r11,28 /* Permits a full 32b of ESID */
1000 ori r11,r11,0x90 /* Turn on valid and kp */
1001 std r11,0(r10) /* Put new entry back into the stab */
1005 /* All done -- return from exception. */
1006 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1007 ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
1009 andi. r10,r12,MSR_RI
1012 mtcrf 0x80,r9 /* restore CR */
1020 ld r9,PACA_EXSLB+EX_R9(r13)
1021 ld r10,PACA_EXSLB+EX_R10(r13)
1022 ld r11,PACA_EXSLB+EX_R11(r13)
1023 ld r12,PACA_EXSLB+EX_R12(r13)
1024 ld r13,PACA_EXSLB+EX_R13(r13)
1026 b . /* prevent speculative execution */
1028 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1030 * Data area reserved for FWNMI option.
1031 * This address (0x7000) is fixed by the RPA.
1034 .globl fwnmi_data_area
1037 /* pseries and powernv need to keep the whole page from
1038 * 0x7000 to 0x8000 free for use by the firmware
1041 #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
1043 /* Space for CPU0's segment table */
1049 #ifdef CONFIG_PPC_POWERNV
1050 _GLOBAL(opal_mc_secondary_handler)
1056 std r3,PACA_OPAL_MC_EVT(r13)
1057 ld r13,OPAL_MC_SRR0(r3)
1059 ld r13,OPAL_MC_SRR1(r3)
1061 ld r3,OPAL_MC_GPR3(r3)
1063 b machine_check_pSeries
1064 #endif /* CONFIG_PPC_POWERNV */