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>
18 * We layout physical memory as follows:
19 * 0x0000 - 0x00ff : Secondary processor spin code
20 * 0x0100 - 0x2fff : pSeries Interrupt prologs
21 * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs
22 * 0x6000 - 0x6fff : Initial (CPU0) segment table
23 * 0x7000 - 0x7fff : FWNMI data area
24 * 0x8000 - : Early init and support code
28 * This is the start of the interrupt handlers for pSeries
29 * This code runs with relocation off.
30 * Code from here to __end_interrupts gets copied down to real
31 * address 0x100 when we are running a relocatable kernel.
32 * Therefore any relative branches in this section must only
33 * branch to labels in this section.
36 .globl __start_interrupts
39 STD_EXCEPTION_PSERIES(0x100, system_reset)
42 _machine_check_pSeries:
44 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
45 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
48 .globl data_access_pSeries
51 mtspr SPRN_SPRG_SCRATCH0,r13
53 mfspr r13,SPRN_SPRG_PACA
54 std r9,PACA_EXSLB+EX_R9(r13)
55 std r10,PACA_EXSLB+EX_R10(r13)
62 beq do_stab_bolted_pSeries
63 ld r10,PACA_EXSLB+EX_R10(r13)
64 std r11,PACA_EXGEN+EX_R11(r13)
65 ld r11,PACA_EXSLB+EX_R9(r13)
66 std r12,PACA_EXGEN+EX_R12(r13)
67 mfspr r12,SPRN_SPRG_SCRATCH0
68 std r10,PACA_EXGEN+EX_R10(r13)
69 std r11,PACA_EXGEN+EX_R9(r13)
70 std r12,PACA_EXGEN+EX_R13(r13)
71 EXCEPTION_PROLOG_PSERIES_1(data_access_common)
73 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common)
74 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB)
77 .globl data_access_slb_pSeries
78 data_access_slb_pSeries:
80 mtspr SPRN_SPRG_SCRATCH0,r13
81 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
82 std r3,PACA_EXSLB+EX_R3(r13)
84 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
87 /* Keep that around for when we re-implement dynamic VSIDs */
89 bge slb_miss_user_pseries
90 #endif /* __DISABLED__ */
91 std r10,PACA_EXSLB+EX_R10(r13)
92 std r11,PACA_EXSLB+EX_R11(r13)
93 std r12,PACA_EXSLB+EX_R12(r13)
94 mfspr r10,SPRN_SPRG_SCRATCH0
95 std r10,PACA_EXSLB+EX_R13(r13)
96 mfspr r12,SPRN_SRR1 /* and SRR1 */
97 #ifndef CONFIG_RELOCATABLE
101 * We can't just use a direct branch to .slb_miss_realmode
102 * because the distance from here to there depends on where
103 * the kernel ends up being put.
106 ld r10,PACAKBASE(r13)
107 LOAD_HANDLER(r10, .slb_miss_realmode)
112 STD_EXCEPTION_PSERIES(0x400, instruction_access)
115 .globl instruction_access_slb_pSeries
116 instruction_access_slb_pSeries:
118 mtspr SPRN_SPRG_SCRATCH0,r13
119 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
120 std r3,PACA_EXSLB+EX_R3(r13)
121 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
122 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
125 /* Keep that around for when we re-implement dynamic VSIDs */
127 bge slb_miss_user_pseries
128 #endif /* __DISABLED__ */
129 std r10,PACA_EXSLB+EX_R10(r13)
130 std r11,PACA_EXSLB+EX_R11(r13)
131 std r12,PACA_EXSLB+EX_R12(r13)
132 mfspr r10,SPRN_SPRG_SCRATCH0
133 std r10,PACA_EXSLB+EX_R13(r13)
134 mfspr r12,SPRN_SRR1 /* and SRR1 */
135 #ifndef CONFIG_RELOCATABLE
139 ld r10,PACAKBASE(r13)
140 LOAD_HANDLER(r10, .slb_miss_realmode)
145 MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt)
146 STD_EXCEPTION_PSERIES(0x600, alignment)
147 STD_EXCEPTION_PSERIES(0x700, program_check)
148 STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
149 MASKABLE_EXCEPTION_PSERIES(0x900, decrementer)
150 STD_EXCEPTION_PSERIES(0xa00, trap_0a)
151 STD_EXCEPTION_PSERIES(0xb00, trap_0b)
154 .globl system_call_pSeries
160 END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
162 mfspr r13,SPRN_SPRG_PACA
164 ld r12,PACAKBASE(r13)
166 LOAD_HANDLER(r12, system_call_entry)
171 b . /* prevent speculative execution */
173 /* Fast LE/BE switch system call */
174 1: mfspr r12,SPRN_SRR1
177 rfid /* return to userspace */
180 STD_EXCEPTION_PSERIES(0xd00, single_step)
181 STD_EXCEPTION_PSERIES(0xe00, trap_0e)
183 /* We need to deal with the Altivec unavailable exception
184 * here which is at 0xf20, thus in the middle of the
185 * prolog code of the PerformanceMonitor one. A little
186 * trickery is thus necessary
189 b performance_monitor_pSeries
192 b altivec_unavailable_pSeries
195 b vsx_unavailable_pSeries
197 #ifdef CONFIG_CBE_RAS
198 HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error)
199 #endif /* CONFIG_CBE_RAS */
200 STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint)
201 #ifdef CONFIG_CBE_RAS
202 HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance)
203 #endif /* CONFIG_CBE_RAS */
204 STD_EXCEPTION_PSERIES(0x1700, altivec_assist)
205 #ifdef CONFIG_CBE_RAS
206 HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal)
207 #endif /* CONFIG_CBE_RAS */
211 /*** pSeries interrupt support ***/
213 /* moved from 0xf00 */
214 STD_EXCEPTION_PSERIES(., performance_monitor)
215 STD_EXCEPTION_PSERIES(., altivec_unavailable)
216 STD_EXCEPTION_PSERIES(., vsx_unavailable)
219 * An interrupt came in while soft-disabled; clear EE in SRR1,
220 * clear paca->hard_enabled and return.
223 stb r10,PACAHARDIRQEN(r13)
225 ld r9,PACA_EXGEN+EX_R9(r13)
227 rldicl r10,r10,48,1 /* clear MSR_EE */
230 ld r10,PACA_EXGEN+EX_R10(r13)
231 mfspr r13,SPRN_SPRG_SCRATCH0
236 do_stab_bolted_pSeries:
237 std r11,PACA_EXSLB+EX_R11(r13)
238 std r12,PACA_EXSLB+EX_R12(r13)
239 mfspr r10,SPRN_SPRG_SCRATCH0
240 std r10,PACA_EXSLB+EX_R13(r13)
241 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted)
243 #ifdef CONFIG_PPC_PSERIES
245 * Vectors for the FWNMI option. Share common code.
247 .globl system_reset_fwnmi
251 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
252 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common)
254 .globl machine_check_fwnmi
258 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
259 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
261 #endif /* CONFIG_PPC_PSERIES */
265 * This is used for when the SLB miss handler has to go virtual,
266 * which doesn't happen for now anymore but will once we re-implement
267 * dynamic VSIDs for shared page tables
269 slb_miss_user_pseries:
270 std r10,PACA_EXGEN+EX_R10(r13)
271 std r11,PACA_EXGEN+EX_R11(r13)
272 std r12,PACA_EXGEN+EX_R12(r13)
273 mfspr r10,SPRG_SCRATCH0
274 ld r11,PACA_EXSLB+EX_R9(r13)
275 ld r12,PACA_EXSLB+EX_R3(r13)
276 std r10,PACA_EXGEN+EX_R13(r13)
277 std r11,PACA_EXGEN+EX_R9(r13)
278 std r12,PACA_EXGEN+EX_R3(r13)
281 mfspr r11,SRR0 /* save SRR0 */
282 ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
283 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
285 mfspr r12,SRR1 /* and SRR1 */
288 b . /* prevent spec. execution */
289 #endif /* __DISABLED__ */
292 .globl __end_interrupts
296 * Code from here down to __end_handlers is invoked from the
297 * exception prologs above. Because the prologs assemble the
298 * addresses of these handlers using the LOAD_HANDLER macro,
299 * which uses an addi instruction, these handlers must be in
300 * the first 32k of the kernel image.
303 /*** Common interrupt handlers ***/
305 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
308 * Machine check is different because we use a different
309 * save area: PACA_EXMC instead of PACA_EXGEN.
312 .globl machine_check_common
313 machine_check_common:
314 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
318 addi r3,r1,STACK_FRAME_OVERHEAD
319 bl .machine_check_exception
322 STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt)
323 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
324 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
325 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
326 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
327 STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception)
328 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
329 #ifdef CONFIG_ALTIVEC
330 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
332 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
334 #ifdef CONFIG_CBE_RAS
335 STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
336 STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
337 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
338 #endif /* CONFIG_CBE_RAS */
345 * Here we have detected that the kernel stack pointer is bad.
346 * R9 contains the saved CR, r13 points to the paca,
347 * r10 contains the (bad) kernel stack pointer,
348 * r11 and r12 contain the saved SRR0 and SRR1.
349 * We switch to using an emergency stack, save the registers there,
350 * and call kernel_bad_stack(), which panics.
353 ld r1,PACAEMERGSP(r13)
354 subi r1,r1,64+INT_FRAME_SIZE
375 lhz r12,PACA_TRAP_SAVE(r13)
377 addi r11,r1,INT_FRAME_SIZE
382 1: addi r3,r1,STACK_FRAME_OVERHEAD
387 * Here r13 points to the paca, r9 contains the saved CR,
388 * SRR0 and SRR1 are saved in r11 and r12,
389 * r9 - r13 are saved in paca->exgen.
392 .globl data_access_common
395 std r10,PACA_EXGEN+EX_DAR(r13)
397 stw r10,PACA_EXGEN+EX_DSISR(r13)
398 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
399 ld r3,PACA_EXGEN+EX_DAR(r13)
400 lwz r4,PACA_EXGEN+EX_DSISR(r13)
402 b .do_hash_page /* Try to handle as hpte fault */
405 .globl instruction_access_common
406 instruction_access_common:
407 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
411 b .do_hash_page /* Try to handle as hpte fault */
414 * Here is the common SLB miss user that is used when going to virtual
415 * mode for SLB misses, that is currently not used
419 .globl slb_miss_user_common
420 slb_miss_user_common:
422 std r3,PACA_EXGEN+EX_DAR(r13)
423 stw r9,PACA_EXGEN+EX_CCR(r13)
424 std r10,PACA_EXGEN+EX_LR(r13)
425 std r11,PACA_EXGEN+EX_SRR0(r13)
426 bl .slb_allocate_user
428 ld r10,PACA_EXGEN+EX_LR(r13)
429 ld r3,PACA_EXGEN+EX_R3(r13)
430 lwz r9,PACA_EXGEN+EX_CCR(r13)
431 ld r11,PACA_EXGEN+EX_SRR0(r13)
435 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
436 beq- unrecov_user_slb
444 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
450 ld r9,PACA_EXGEN+EX_R9(r13)
451 ld r10,PACA_EXGEN+EX_R10(r13)
452 ld r11,PACA_EXGEN+EX_R11(r13)
453 ld r12,PACA_EXGEN+EX_R12(r13)
454 ld r13,PACA_EXGEN+EX_R13(r13)
459 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
460 ld r4,PACA_EXGEN+EX_DAR(r13)
467 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
470 1: addi r3,r1,STACK_FRAME_OVERHEAD
471 bl .unrecoverable_exception
474 #endif /* __DISABLED__ */
478 * r13 points to the PACA, r9 contains the saved CR,
479 * r12 contain the saved SRR1, SRR0 is still ready for return
480 * r3 has the faulting address
481 * r9 - r13 are saved in paca->exslb.
482 * r3 is saved in paca->slb_r3
483 * We assume we aren't going to take any exceptions during this procedure.
485 _GLOBAL(slb_miss_realmode)
487 #ifdef CONFIG_RELOCATABLE
491 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
492 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
494 bl .slb_allocate_realmode
496 /* All done -- return from exception. */
498 ld r10,PACA_EXSLB+EX_LR(r13)
499 ld r3,PACA_EXSLB+EX_R3(r13)
500 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
501 #ifdef CONFIG_PPC_ISERIES
503 ld r11,PACALPPACAPTR(r13)
504 ld r11,LPPACASRR0(r11) /* get SRR0 value */
505 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
506 #endif /* CONFIG_PPC_ISERIES */
510 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
516 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
519 #ifdef CONFIG_PPC_ISERIES
523 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
524 #endif /* CONFIG_PPC_ISERIES */
525 ld r9,PACA_EXSLB+EX_R9(r13)
526 ld r10,PACA_EXSLB+EX_R10(r13)
527 ld r11,PACA_EXSLB+EX_R11(r13)
528 ld r12,PACA_EXSLB+EX_R12(r13)
529 ld r13,PACA_EXSLB+EX_R13(r13)
531 b . /* prevent speculative execution */
534 #ifdef CONFIG_PPC_ISERIES
537 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
538 #endif /* CONFIG_PPC_ISERIES */
540 ld r10,PACAKBASE(r13)
541 LOAD_HANDLER(r10,unrecov_slb)
549 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
552 1: addi r3,r1,STACK_FRAME_OVERHEAD
553 bl .unrecoverable_exception
557 .globl hardware_interrupt_common
558 .globl hardware_interrupt_entry
559 hardware_interrupt_common:
560 EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN)
562 hardware_interrupt_entry:
565 bl .ppc64_runlatch_on
566 END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
567 addi r3,r1,STACK_FRAME_OVERHEAD
569 b .ret_from_except_lite
571 #ifdef CONFIG_PPC_970_NAP
574 std r9,TI_LOCAL_FLAGS(r11)
575 ld r10,_LINK(r1) /* make idle task do the */
576 std r10,_NIP(r1) /* equivalent of a blr */
581 .globl alignment_common
584 std r10,PACA_EXGEN+EX_DAR(r13)
586 stw r10,PACA_EXGEN+EX_DSISR(r13)
587 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
588 ld r3,PACA_EXGEN+EX_DAR(r13)
589 lwz r4,PACA_EXGEN+EX_DSISR(r13)
593 addi r3,r1,STACK_FRAME_OVERHEAD
595 bl .alignment_exception
599 .globl program_check_common
600 program_check_common:
601 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
603 addi r3,r1,STACK_FRAME_OVERHEAD
605 bl .program_check_exception
609 .globl fp_unavailable_common
610 fp_unavailable_common:
611 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
612 bne 1f /* if from user, just load it up */
614 addi r3,r1,STACK_FRAME_OVERHEAD
616 bl .kernel_fp_unavailable_exception
619 b fast_exception_return
622 .globl altivec_unavailable_common
623 altivec_unavailable_common:
624 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
625 #ifdef CONFIG_ALTIVEC
629 b fast_exception_return
631 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
634 addi r3,r1,STACK_FRAME_OVERHEAD
636 bl .altivec_unavailable_exception
640 .globl vsx_unavailable_common
641 vsx_unavailable_common:
642 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
647 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
650 addi r3,r1,STACK_FRAME_OVERHEAD
652 bl .vsx_unavailable_exception
656 .globl __end_handlers
660 * Return from an exception with minimal checks.
661 * The caller is assumed to have done EXCEPTION_PROLOG_COMMON.
662 * If interrupts have been enabled, or anything has been
663 * done that might have changed the scheduling status of
664 * any task or sent any task a signal, you should use
665 * ret_from_except or ret_from_except_lite instead of this.
667 fast_exc_return_irq: /* restores irq state too */
669 TRACE_AND_RESTORE_IRQ(r3);
671 rldicl r4,r12,49,63 /* get MSR_EE to LSB */
672 stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */
675 .globl fast_exception_return
676 fast_exception_return:
679 andi. r3,r12,MSR_RI /* check if RI is set */
682 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
685 ACCOUNT_CPU_USER_EXIT(r3, r4)
701 rldicl r10,r10,48,1 /* clear EE */
702 rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */
710 b . /* prevent speculative execution */
714 1: addi r3,r1,STACK_FRAME_OVERHEAD
715 bl .unrecoverable_exception
723 _STATIC(do_hash_page)
727 andis. r0,r4,0xa450 /* weird error? */
728 bne- handle_page_fault /* if not, try to insert a HPTE */
730 andis. r0,r4,0x0020 /* Is it a segment table fault? */
731 bne- do_ste_alloc /* If so handle it */
732 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
735 * On iSeries, we soft-disable interrupts here, then
736 * hard-enable interrupts so that the hash_page code can spin on
737 * the hash_table_lock without problems on a shared processor.
742 * Currently, trace_hardirqs_off() will be called by DISABLE_INTS
743 * and will clobber volatile registers when irq tracing is enabled
744 * so we need to reload them. It may be possible to be smarter here
745 * and move the irq tracing elsewhere but let's keep it simple for
748 #ifdef CONFIG_TRACE_IRQFLAGS
754 #endif /* CONFIG_TRACE_IRQFLAGS */
756 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
757 * accessing a userspace segment (even from the kernel). We assume
758 * kernel addresses always have the high bit set.
760 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
761 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
762 orc r0,r12,r0 /* MSR_PR | ~high_bit */
763 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
764 ori r4,r4,1 /* add _PAGE_PRESENT */
765 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
768 * r3 contains the faulting address
769 * r4 contains the required access permissions
770 * r5 contains the trap number
772 * at return r3 = 0 for success
774 bl .hash_page /* build HPTE if possible */
775 cmpdi r3,0 /* see if hash_page succeeded */
779 * If we had interrupts soft-enabled at the point where the
780 * DSI/ISI occurred, and an interrupt came in during hash_page,
782 * We jump to ret_from_except_lite rather than fast_exception_return
783 * because ret_from_except_lite will check for and handle pending
784 * interrupts if necessary.
787 END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
791 * Here we have interrupts hard-disabled, so it is sufficient
792 * to restore paca->{soft,hard}_enable and get out.
794 beq fast_exc_return_irq /* Return from exception on success */
795 END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
797 /* For a hash failure, we don't bother re-enabling interrupts */
801 * hash_page couldn't handle it, set soft interrupt enable back
802 * to what it was before the trap. Note that .raw_local_irq_restore
803 * handles any interrupts pending at this point.
806 TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f)
807 bl .raw_local_irq_restore
810 /* Here we have a page fault that hash_page can't handle. */
815 addi r3,r1,STACK_FRAME_OVERHEAD
821 addi r3,r1,STACK_FRAME_OVERHEAD
826 13: b .ret_from_except_lite
828 /* We have a page fault that hash_page could handle but HV refused
833 addi r3,r1,STACK_FRAME_OVERHEAD
838 /* here we have a segment miss */
840 bl .ste_allocate /* try to insert stab entry */
842 bne- handle_page_fault
843 b fast_exception_return
846 * r13 points to the PACA, r9 contains the saved CR,
847 * r11 and r12 contain the saved SRR0 and SRR1.
848 * r9 - r13 are saved in paca->exslb.
849 * We assume we aren't going to take any exceptions during this procedure.
850 * We assume (DAR >> 60) == 0xc.
853 _GLOBAL(do_stab_bolted)
854 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
855 std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
857 /* Hash to the primary group */
858 ld r10,PACASTABVIRT(r13)
861 rldimi r10,r11,7,52 /* r10 = first ste of the group */
864 /* This is a kernel address, so protovsid = ESID */
865 ASM_VSID_SCRAMBLE(r11, r9, 256M)
866 rldic r9,r11,12,16 /* r9 = vsid << 12 */
868 /* Search the primary group for a free entry */
869 1: ld r11,0(r10) /* Test valid bit of the current ste */
876 /* Stick for only searching the primary group for now. */
877 /* At least for now, we use a very simple random castout scheme */
878 /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
880 rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
883 /* r10 currently points to an ste one past the group of interest */
884 /* make it point to the randomly selected entry */
886 or r10,r10,r11 /* r10 is the entry to invalidate */
888 isync /* mark the entry invalid */
890 rldicl r11,r11,56,1 /* clear the valid bit */
895 clrrdi r11,r11,28 /* Get the esid part of the ste */
898 2: std r9,8(r10) /* Store the vsid part of the ste */
901 mfspr r11,SPRN_DAR /* Get the new esid */
902 clrrdi r11,r11,28 /* Permits a full 32b of ESID */
903 ori r11,r11,0x90 /* Turn on valid and kp */
904 std r11,0(r10) /* Put new entry back into the stab */
908 /* All done -- return from exception. */
909 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
910 ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
915 mtcrf 0x80,r9 /* restore CR */
923 ld r9,PACA_EXSLB+EX_R9(r13)
924 ld r10,PACA_EXSLB+EX_R10(r13)
925 ld r11,PACA_EXSLB+EX_R11(r13)
926 ld r12,PACA_EXSLB+EX_R12(r13)
927 ld r13,PACA_EXSLB+EX_R13(r13)
929 b . /* prevent speculative execution */
932 * Space for CPU0's segment table.
934 * On iSeries, the hypervisor must fill in at least one entry before
935 * we get control (with relocate on). The address is given to the hv
936 * as a page number (see xLparMap below), so this must be at a
937 * fixed address (the linker can't compute (u64)&initial_stab >>
940 . = STAB0_OFFSET /* 0x6000 */
945 #ifdef CONFIG_PPC_PSERIES
947 * Data area reserved for FWNMI option.
948 * This address (0x7000) is fixed by the RPA.
951 .globl fwnmi_data_area
953 #endif /* CONFIG_PPC_PSERIES */
955 /* iSeries does not use the FWNMI stuff, so it is safe to put
956 * this here, even if we later allow kernels that will boot on
957 * both pSeries and iSeries */
958 #ifdef CONFIG_PPC_ISERIES
962 .quad HvEsidsToMap /* xNumberEsids */
963 .quad HvRangesToMap /* xNumberRanges */
964 .quad STAB0_PAGE /* xSegmentTableOffs */
966 /* xEsids (HvEsidsToMap entries of 2 quads) */
967 .quad PAGE_OFFSET_ESID /* xKernelEsid */
968 .quad PAGE_OFFSET_VSID /* xKernelVsid */
969 .quad VMALLOC_START_ESID /* xKernelEsid */
970 .quad VMALLOC_START_VSID /* xKernelVsid */
971 /* xRanges (HvRangesToMap entries of 3 quads) */
972 .quad HvPagesToMap /* xPages */
973 .quad 0 /* xOffset */
974 .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */
976 #endif /* CONFIG_PPC_ISERIES */
978 #ifdef CONFIG_PPC_PSERIES
980 #endif /* CONFIG_PPC_PSERIES */