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 dependant assembly.
10 * Most of this originates from head_64.S and thus has the same
15 #include <asm/exception-64s.h>
16 #include <asm/ptrace.h>
19 * We layout physical memory as follows:
20 * 0x0000 - 0x00ff : Secondary processor spin code
21 * 0x0100 - 0x2fff : pSeries Interrupt prologs
22 * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs
23 * 0x6000 - 0x6fff : Initial (CPU0) segment table
24 * 0x7000 - 0x7fff : FWNMI data area
25 * 0x8000 - : Early init and support code
29 * This is the start of the interrupt handlers for pSeries
30 * This code runs with relocation off.
31 * Code from here to __end_interrupts gets copied down to real
32 * address 0x100 when we are running a relocatable kernel.
33 * Therefore any relative branches in this section must only
34 * branch to labels in this section.
37 .globl __start_interrupts
40 STD_EXCEPTION_PSERIES(0x100, system_reset)
43 _machine_check_pSeries:
46 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
47 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
50 .globl data_access_pSeries
54 mtspr SPRN_SPRG_SCRATCH0,r13
56 mfspr r13,SPRN_SPRG_PACA
57 std r9,PACA_EXSLB+EX_R9(r13)
58 std r10,PACA_EXSLB+EX_R10(r13)
65 beq do_stab_bolted_pSeries
66 ld r10,PACA_EXSLB+EX_R10(r13)
67 std r11,PACA_EXGEN+EX_R11(r13)
68 ld r11,PACA_EXSLB+EX_R9(r13)
69 std r12,PACA_EXGEN+EX_R12(r13)
70 mfspr r12,SPRN_SPRG_SCRATCH0
71 std r10,PACA_EXGEN+EX_R10(r13)
72 std r11,PACA_EXGEN+EX_R9(r13)
73 std r12,PACA_EXGEN+EX_R13(r13)
74 EXCEPTION_PROLOG_PSERIES_1(data_access_common)
76 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common)
77 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB)
80 .globl data_access_slb_pSeries
81 data_access_slb_pSeries:
84 mtspr SPRN_SPRG_SCRATCH0,r13
85 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
86 std r3,PACA_EXSLB+EX_R3(r13)
88 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
91 /* Keep that around for when we re-implement dynamic VSIDs */
93 bge slb_miss_user_pseries
94 #endif /* __DISABLED__ */
95 std r10,PACA_EXSLB+EX_R10(r13)
96 std r11,PACA_EXSLB+EX_R11(r13)
97 std r12,PACA_EXSLB+EX_R12(r13)
98 mfspr r10,SPRN_SPRG_SCRATCH0
99 std r10,PACA_EXSLB+EX_R13(r13)
100 mfspr r12,SPRN_SRR1 /* and SRR1 */
101 #ifndef CONFIG_RELOCATABLE
105 * We can't just use a direct branch to .slb_miss_realmode
106 * because the distance from here to there depends on where
107 * the kernel ends up being put.
110 ld r10,PACAKBASE(r13)
111 LOAD_HANDLER(r10, .slb_miss_realmode)
116 STD_EXCEPTION_PSERIES(0x400, instruction_access)
119 .globl instruction_access_slb_pSeries
120 instruction_access_slb_pSeries:
123 mtspr SPRN_SPRG_SCRATCH0,r13
124 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
125 std r3,PACA_EXSLB+EX_R3(r13)
126 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
127 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
130 /* Keep that around for when we re-implement dynamic VSIDs */
132 bge slb_miss_user_pseries
133 #endif /* __DISABLED__ */
134 std r10,PACA_EXSLB+EX_R10(r13)
135 std r11,PACA_EXSLB+EX_R11(r13)
136 std r12,PACA_EXSLB+EX_R12(r13)
137 mfspr r10,SPRN_SPRG_SCRATCH0
138 std r10,PACA_EXSLB+EX_R13(r13)
139 mfspr r12,SPRN_SRR1 /* and SRR1 */
140 #ifndef CONFIG_RELOCATABLE
144 ld r10,PACAKBASE(r13)
145 LOAD_HANDLER(r10, .slb_miss_realmode)
150 MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt)
151 STD_EXCEPTION_PSERIES(0x600, alignment)
152 STD_EXCEPTION_PSERIES(0x700, program_check)
153 STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
154 MASKABLE_EXCEPTION_PSERIES(0x900, decrementer)
155 STD_EXCEPTION_PSERIES(0xa00, trap_0a)
156 STD_EXCEPTION_PSERIES(0xb00, trap_0b)
159 .globl system_call_pSeries
166 END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
168 mfspr r13,SPRN_SPRG_PACA
170 ld r12,PACAKBASE(r13)
172 LOAD_HANDLER(r12, system_call_entry)
177 b . /* prevent speculative execution */
179 /* Fast LE/BE switch system call */
180 1: mfspr r12,SPRN_SRR1
183 rfid /* return to userspace */
186 STD_EXCEPTION_PSERIES(0xd00, single_step)
187 STD_EXCEPTION_PSERIES(0xe00, trap_0e)
189 /* We need to deal with the Altivec unavailable exception
190 * here which is at 0xf20, thus in the middle of the
191 * prolog code of the PerformanceMonitor one. A little
192 * trickery is thus necessary
194 performance_monitor_pSeries_1:
197 b performance_monitor_pSeries
199 altivec_unavailable_pSeries_1:
202 b altivec_unavailable_pSeries
204 vsx_unavailable_pSeries_1:
207 b vsx_unavailable_pSeries
209 #ifdef CONFIG_CBE_RAS
210 HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error)
211 #endif /* CONFIG_CBE_RAS */
212 STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint)
213 #ifdef CONFIG_CBE_RAS
214 HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance)
215 #endif /* CONFIG_CBE_RAS */
216 STD_EXCEPTION_PSERIES(0x1700, altivec_assist)
217 #ifdef CONFIG_CBE_RAS
218 HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal)
219 #endif /* CONFIG_CBE_RAS */
223 /*** pSeries interrupt support ***/
225 /* moved from 0xf00 */
226 STD_EXCEPTION_PSERIES(., performance_monitor)
227 STD_EXCEPTION_PSERIES(., altivec_unavailable)
228 STD_EXCEPTION_PSERIES(., vsx_unavailable)
231 * An interrupt came in while soft-disabled; clear EE in SRR1,
232 * clear paca->hard_enabled and return.
235 stb r10,PACAHARDIRQEN(r13)
237 ld r9,PACA_EXGEN+EX_R9(r13)
239 rldicl r10,r10,48,1 /* clear MSR_EE */
242 ld r10,PACA_EXGEN+EX_R10(r13)
243 mfspr r13,SPRN_SPRG_SCRATCH0
248 do_stab_bolted_pSeries:
249 std r11,PACA_EXSLB+EX_R11(r13)
250 std r12,PACA_EXSLB+EX_R12(r13)
251 mfspr r10,SPRN_SPRG_SCRATCH0
252 std r10,PACA_EXSLB+EX_R13(r13)
253 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted)
255 #ifdef CONFIG_PPC_PSERIES
257 * Vectors for the FWNMI option. Share common code.
259 .globl system_reset_fwnmi
263 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
264 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common)
266 .globl machine_check_fwnmi
270 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
271 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
273 #endif /* CONFIG_PPC_PSERIES */
277 * This is used for when the SLB miss handler has to go virtual,
278 * which doesn't happen for now anymore but will once we re-implement
279 * dynamic VSIDs for shared page tables
281 slb_miss_user_pseries:
282 std r10,PACA_EXGEN+EX_R10(r13)
283 std r11,PACA_EXGEN+EX_R11(r13)
284 std r12,PACA_EXGEN+EX_R12(r13)
285 mfspr r10,SPRG_SCRATCH0
286 ld r11,PACA_EXSLB+EX_R9(r13)
287 ld r12,PACA_EXSLB+EX_R3(r13)
288 std r10,PACA_EXGEN+EX_R13(r13)
289 std r11,PACA_EXGEN+EX_R9(r13)
290 std r12,PACA_EXGEN+EX_R3(r13)
293 mfspr r11,SRR0 /* save SRR0 */
294 ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
295 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
297 mfspr r12,SRR1 /* and SRR1 */
300 b . /* prevent spec. execution */
301 #endif /* __DISABLED__ */
303 /* KVM's trampoline code needs to be close to the interrupt handlers */
305 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
306 #include "../kvm/book3s_rmhandlers.S"
310 .globl __end_interrupts
314 * Code from here down to __end_handlers is invoked from the
315 * exception prologs above. Because the prologs assemble the
316 * addresses of these handlers using the LOAD_HANDLER macro,
317 * which uses an addi instruction, these handlers must be in
318 * the first 32k of the kernel image.
321 /*** Common interrupt handlers ***/
323 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
326 * Machine check is different because we use a different
327 * save area: PACA_EXMC instead of PACA_EXGEN.
330 .globl machine_check_common
331 machine_check_common:
332 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
336 addi r3,r1,STACK_FRAME_OVERHEAD
337 bl .machine_check_exception
340 STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt)
341 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
342 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
343 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
344 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
345 STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception)
346 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
347 #ifdef CONFIG_ALTIVEC
348 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
350 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
352 #ifdef CONFIG_CBE_RAS
353 STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
354 STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
355 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
356 #endif /* CONFIG_CBE_RAS */
363 * Here we have detected that the kernel stack pointer is bad.
364 * R9 contains the saved CR, r13 points to the paca,
365 * r10 contains the (bad) kernel stack pointer,
366 * r11 and r12 contain the saved SRR0 and SRR1.
367 * We switch to using an emergency stack, save the registers there,
368 * and call kernel_bad_stack(), which panics.
371 ld r1,PACAEMERGSP(r13)
372 subi r1,r1,64+INT_FRAME_SIZE
393 lhz r12,PACA_TRAP_SAVE(r13)
395 addi r11,r1,INT_FRAME_SIZE
400 1: addi r3,r1,STACK_FRAME_OVERHEAD
405 * Here r13 points to the paca, r9 contains the saved CR,
406 * SRR0 and SRR1 are saved in r11 and r12,
407 * r9 - r13 are saved in paca->exgen.
410 .globl data_access_common
413 std r10,PACA_EXGEN+EX_DAR(r13)
415 stw r10,PACA_EXGEN+EX_DSISR(r13)
416 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
417 ld r3,PACA_EXGEN+EX_DAR(r13)
418 lwz r4,PACA_EXGEN+EX_DSISR(r13)
420 b .do_hash_page /* Try to handle as hpte fault */
423 .globl instruction_access_common
424 instruction_access_common:
425 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
429 b .do_hash_page /* Try to handle as hpte fault */
432 * Here is the common SLB miss user that is used when going to virtual
433 * mode for SLB misses, that is currently not used
437 .globl slb_miss_user_common
438 slb_miss_user_common:
440 std r3,PACA_EXGEN+EX_DAR(r13)
441 stw r9,PACA_EXGEN+EX_CCR(r13)
442 std r10,PACA_EXGEN+EX_LR(r13)
443 std r11,PACA_EXGEN+EX_SRR0(r13)
444 bl .slb_allocate_user
446 ld r10,PACA_EXGEN+EX_LR(r13)
447 ld r3,PACA_EXGEN+EX_R3(r13)
448 lwz r9,PACA_EXGEN+EX_CCR(r13)
449 ld r11,PACA_EXGEN+EX_SRR0(r13)
453 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
454 beq- unrecov_user_slb
462 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
468 ld r9,PACA_EXGEN+EX_R9(r13)
469 ld r10,PACA_EXGEN+EX_R10(r13)
470 ld r11,PACA_EXGEN+EX_R11(r13)
471 ld r12,PACA_EXGEN+EX_R12(r13)
472 ld r13,PACA_EXGEN+EX_R13(r13)
477 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
478 ld r4,PACA_EXGEN+EX_DAR(r13)
485 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
488 1: addi r3,r1,STACK_FRAME_OVERHEAD
489 bl .unrecoverable_exception
492 #endif /* __DISABLED__ */
496 * r13 points to the PACA, r9 contains the saved CR,
497 * r12 contain the saved SRR1, SRR0 is still ready for return
498 * r3 has the faulting address
499 * r9 - r13 are saved in paca->exslb.
500 * r3 is saved in paca->slb_r3
501 * We assume we aren't going to take any exceptions during this procedure.
503 _GLOBAL(slb_miss_realmode)
505 #ifdef CONFIG_RELOCATABLE
509 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
510 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
512 bl .slb_allocate_realmode
514 /* All done -- return from exception. */
516 ld r10,PACA_EXSLB+EX_LR(r13)
517 ld r3,PACA_EXSLB+EX_R3(r13)
518 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
519 #ifdef CONFIG_PPC_ISERIES
521 ld r11,PACALPPACAPTR(r13)
522 ld r11,LPPACASRR0(r11) /* get SRR0 value */
523 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
524 #endif /* CONFIG_PPC_ISERIES */
528 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
534 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
537 #ifdef CONFIG_PPC_ISERIES
541 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
542 #endif /* CONFIG_PPC_ISERIES */
543 ld r9,PACA_EXSLB+EX_R9(r13)
544 ld r10,PACA_EXSLB+EX_R10(r13)
545 ld r11,PACA_EXSLB+EX_R11(r13)
546 ld r12,PACA_EXSLB+EX_R12(r13)
547 ld r13,PACA_EXSLB+EX_R13(r13)
549 b . /* prevent speculative execution */
552 #ifdef CONFIG_PPC_ISERIES
555 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
556 #endif /* CONFIG_PPC_ISERIES */
558 ld r10,PACAKBASE(r13)
559 LOAD_HANDLER(r10,unrecov_slb)
567 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
570 1: addi r3,r1,STACK_FRAME_OVERHEAD
571 bl .unrecoverable_exception
575 .globl hardware_interrupt_common
576 .globl hardware_interrupt_entry
577 hardware_interrupt_common:
578 EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN)
580 hardware_interrupt_entry:
583 bl .ppc64_runlatch_on
584 END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
585 addi r3,r1,STACK_FRAME_OVERHEAD
587 b .ret_from_except_lite
589 #ifdef CONFIG_PPC_970_NAP
592 std r9,TI_LOCAL_FLAGS(r11)
593 ld r10,_LINK(r1) /* make idle task do the */
594 std r10,_NIP(r1) /* equivalent of a blr */
599 .globl alignment_common
602 std r10,PACA_EXGEN+EX_DAR(r13)
604 stw r10,PACA_EXGEN+EX_DSISR(r13)
605 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
606 ld r3,PACA_EXGEN+EX_DAR(r13)
607 lwz r4,PACA_EXGEN+EX_DSISR(r13)
611 addi r3,r1,STACK_FRAME_OVERHEAD
613 bl .alignment_exception
617 .globl program_check_common
618 program_check_common:
619 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
621 addi r3,r1,STACK_FRAME_OVERHEAD
623 bl .program_check_exception
627 .globl fp_unavailable_common
628 fp_unavailable_common:
629 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
630 bne 1f /* if from user, just load it up */
632 addi r3,r1,STACK_FRAME_OVERHEAD
634 bl .kernel_fp_unavailable_exception
637 b fast_exception_return
640 .globl altivec_unavailable_common
641 altivec_unavailable_common:
642 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
643 #ifdef CONFIG_ALTIVEC
647 b fast_exception_return
649 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
652 addi r3,r1,STACK_FRAME_OVERHEAD
654 bl .altivec_unavailable_exception
658 .globl vsx_unavailable_common
659 vsx_unavailable_common:
660 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
665 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
668 addi r3,r1,STACK_FRAME_OVERHEAD
670 bl .vsx_unavailable_exception
674 .globl __end_handlers
678 * Return from an exception with minimal checks.
679 * The caller is assumed to have done EXCEPTION_PROLOG_COMMON.
680 * If interrupts have been enabled, or anything has been
681 * done that might have changed the scheduling status of
682 * any task or sent any task a signal, you should use
683 * ret_from_except or ret_from_except_lite instead of this.
685 fast_exc_return_irq: /* restores irq state too */
687 TRACE_AND_RESTORE_IRQ(r3);
689 rldicl r4,r12,49,63 /* get MSR_EE to LSB */
690 stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */
693 .globl fast_exception_return
694 fast_exception_return:
697 andi. r3,r12,MSR_RI /* check if RI is set */
700 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
703 ACCOUNT_CPU_USER_EXIT(r3, r4)
719 rldicl r10,r10,48,1 /* clear EE */
720 rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */
728 b . /* prevent speculative execution */
732 1: addi r3,r1,STACK_FRAME_OVERHEAD
733 bl .unrecoverable_exception
741 _STATIC(do_hash_page)
745 andis. r0,r4,0xa410 /* weird error? */
746 bne- handle_page_fault /* if not, try to insert a HPTE */
747 andis. r0,r4,DSISR_DABRMATCH@h
748 bne- handle_dabr_fault
751 andis. r0,r4,0x0020 /* Is it a segment table fault? */
752 bne- do_ste_alloc /* If so handle it */
753 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
755 clrrdi r11,r1,THREAD_SHIFT
756 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
757 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
758 bne 77f /* then don't call hash_page now */
761 * On iSeries, we soft-disable interrupts here, then
762 * hard-enable interrupts so that the hash_page code can spin on
763 * the hash_table_lock without problems on a shared processor.
768 * Currently, trace_hardirqs_off() will be called by DISABLE_INTS
769 * and will clobber volatile registers when irq tracing is enabled
770 * so we need to reload them. It may be possible to be smarter here
771 * and move the irq tracing elsewhere but let's keep it simple for
774 #ifdef CONFIG_TRACE_IRQFLAGS
780 #endif /* CONFIG_TRACE_IRQFLAGS */
782 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
783 * accessing a userspace segment (even from the kernel). We assume
784 * kernel addresses always have the high bit set.
786 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
787 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
788 orc r0,r12,r0 /* MSR_PR | ~high_bit */
789 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
790 ori r4,r4,1 /* add _PAGE_PRESENT */
791 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
794 * r3 contains the faulting address
795 * r4 contains the required access permissions
796 * r5 contains the trap number
798 * at return r3 = 0 for success
800 bl .hash_page /* build HPTE if possible */
801 cmpdi r3,0 /* see if hash_page succeeded */
805 * If we had interrupts soft-enabled at the point where the
806 * DSI/ISI occurred, and an interrupt came in during hash_page,
808 * We jump to ret_from_except_lite rather than fast_exception_return
809 * because ret_from_except_lite will check for and handle pending
810 * interrupts if necessary.
813 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
817 * Here we have interrupts hard-disabled, so it is sufficient
818 * to restore paca->{soft,hard}_enable and get out.
820 beq fast_exc_return_irq /* Return from exception on success */
821 END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
823 /* For a hash failure, we don't bother re-enabling interrupts */
827 * hash_page couldn't handle it, set soft interrupt enable back
828 * to what it was before the trap. Note that .arch_local_irq_restore
829 * handles any interrupts pending at this point.
832 TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f)
833 bl .arch_local_irq_restore
836 /* We have a data breakpoint exception - handle it */
841 addi r3,r1,STACK_FRAME_OVERHEAD
843 b .ret_from_except_lite
845 /* Here we have a page fault that hash_page can't handle. */
850 addi r3,r1,STACK_FRAME_OVERHEAD
856 addi r3,r1,STACK_FRAME_OVERHEAD
861 13: b .ret_from_except_lite
863 /* We have a page fault that hash_page could handle but HV refused
868 addi r3,r1,STACK_FRAME_OVERHEAD
874 * We come here as a result of a DSI at a point where we don't want
875 * to call hash_page, such as when we are accessing memory (possibly
876 * user memory) inside a PMU interrupt that occurred while interrupts
877 * were soft-disabled. We want to invoke the exception handler for
878 * the access, or panic if there isn't a handler.
882 addi r3,r1,STACK_FRAME_OVERHEAD
887 /* here we have a segment miss */
889 bl .ste_allocate /* try to insert stab entry */
891 bne- handle_page_fault
892 b fast_exception_return
895 * r13 points to the PACA, r9 contains the saved CR,
896 * r11 and r12 contain the saved SRR0 and SRR1.
897 * r9 - r13 are saved in paca->exslb.
898 * We assume we aren't going to take any exceptions during this procedure.
899 * We assume (DAR >> 60) == 0xc.
902 _GLOBAL(do_stab_bolted)
903 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
904 std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
906 /* Hash to the primary group */
907 ld r10,PACASTABVIRT(r13)
910 rldimi r10,r11,7,52 /* r10 = first ste of the group */
913 /* This is a kernel address, so protovsid = ESID */
914 ASM_VSID_SCRAMBLE(r11, r9, 256M)
915 rldic r9,r11,12,16 /* r9 = vsid << 12 */
917 /* Search the primary group for a free entry */
918 1: ld r11,0(r10) /* Test valid bit of the current ste */
925 /* Stick for only searching the primary group for now. */
926 /* At least for now, we use a very simple random castout scheme */
927 /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
929 rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
932 /* r10 currently points to an ste one past the group of interest */
933 /* make it point to the randomly selected entry */
935 or r10,r10,r11 /* r10 is the entry to invalidate */
937 isync /* mark the entry invalid */
939 rldicl r11,r11,56,1 /* clear the valid bit */
944 clrrdi r11,r11,28 /* Get the esid part of the ste */
947 2: std r9,8(r10) /* Store the vsid part of the ste */
950 mfspr r11,SPRN_DAR /* Get the new esid */
951 clrrdi r11,r11,28 /* Permits a full 32b of ESID */
952 ori r11,r11,0x90 /* Turn on valid and kp */
953 std r11,0(r10) /* Put new entry back into the stab */
957 /* All done -- return from exception. */
958 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
959 ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
964 mtcrf 0x80,r9 /* restore CR */
972 ld r9,PACA_EXSLB+EX_R9(r13)
973 ld r10,PACA_EXSLB+EX_R10(r13)
974 ld r11,PACA_EXSLB+EX_R11(r13)
975 ld r12,PACA_EXSLB+EX_R12(r13)
976 ld r13,PACA_EXSLB+EX_R13(r13)
978 b . /* prevent speculative execution */
981 * Space for CPU0's segment table.
983 * On iSeries, the hypervisor must fill in at least one entry before
984 * we get control (with relocate on). The address is given to the hv
985 * as a page number (see xLparMap below), so this must be at a
986 * fixed address (the linker can't compute (u64)&initial_stab >>
989 . = STAB0_OFFSET /* 0x6000 */
994 #ifdef CONFIG_PPC_PSERIES
996 * Data area reserved for FWNMI option.
997 * This address (0x7000) is fixed by the RPA.
1000 .globl fwnmi_data_area
1002 #endif /* CONFIG_PPC_PSERIES */
1004 /* iSeries does not use the FWNMI stuff, so it is safe to put
1005 * this here, even if we later allow kernels that will boot on
1006 * both pSeries and iSeries */
1007 #ifdef CONFIG_PPC_ISERIES
1011 .quad HvEsidsToMap /* xNumberEsids */
1012 .quad HvRangesToMap /* xNumberRanges */
1013 .quad STAB0_PAGE /* xSegmentTableOffs */
1014 .zero 40 /* xRsvd */
1015 /* xEsids (HvEsidsToMap entries of 2 quads) */
1016 .quad PAGE_OFFSET_ESID /* xKernelEsid */
1017 .quad PAGE_OFFSET_VSID /* xKernelVsid */
1018 .quad VMALLOC_START_ESID /* xKernelEsid */
1019 .quad VMALLOC_START_VSID /* xKernelVsid */
1020 /* xRanges (HvRangesToMap entries of 3 quads) */
1021 .quad HvPagesToMap /* xPages */
1022 .quad 0 /* xOffset */
1023 .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */
1025 #endif /* CONFIG_PPC_ISERIES */
1027 #ifdef CONFIG_PPC_PSERIES
1029 #endif /* CONFIG_PPC_PSERIES */