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 */ \
58 2: mfspr r12,SPRN_SRR1 ; \
59 andi. r12,r12,MSR_PR ; \
61 mtspr SPRN_SRR0,r3 ; \
62 mtspr SPRN_SRR1,r4 ; \
63 mtspr SPRN_SDR1,r5 ; \
65 b . ; /* prevent speculative execution */
67 #if defined(CONFIG_RELOCATABLE)
69 * We can't branch directly; in the direct case we use LR
70 * and system_call_entry restores LR. (We thus need to move
71 * LR to r10 in the RFID case too.)
73 #define SYSCALL_PSERIES_2_DIRECT \
75 ld r12,PACAKBASE(r13) ; \
76 LOAD_HANDLER(r12, system_call_entry_direct) ; \
78 mfspr r12,SPRN_SRR1 ; \
79 /* Re-use of r13... No spare regs to do this */ \
82 GET_PACA(r13) ; /* get r13 back */ \
85 /* We can branch directly */
86 #define SYSCALL_PSERIES_2_DIRECT \
87 mfspr r12,SPRN_SRR1 ; \
89 mtmsrd r10,1 ; /* Set RI (EE=0) */ \
90 b system_call_entry_direct ;
94 * This is the start of the interrupt handlers for pSeries
95 * This code runs with relocation off.
96 * Code from here to __end_interrupts gets copied down to real
97 * address 0x100 when we are running a relocatable kernel.
98 * Therefore any relative branches in this section must only
99 * branch to labels in this section.
102 .globl __start_interrupts
105 .globl system_reset_pSeries;
106 system_reset_pSeries:
107 HMT_MEDIUM_PPR_DISCARD
109 #ifdef CONFIG_PPC_P7_NAP
111 /* Running native on arch 2.06 or later, check if we are
112 * waking up from nap. We only handle no state loss and
113 * supervisor state loss. We do -not- handle hypervisor
114 * state loss at this time.
117 rlwinm. r13,r13,47-31,30,31
120 /* waking up from powersave (nap) state */
122 /* Total loss of HV state is fatal, we could try to use the
123 * PIR to locate a PACA, then use an emergency stack etc...
124 * but for now, let's just stay stuck here
129 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
130 li r0,KVM_HWTHREAD_IN_KERNEL
131 stb r0,HSTATE_HWTHREAD_STATE(r13)
132 /* Order setting hwthread_state vs. testing hwthread_req */
134 lbz r0,HSTATE_HWTHREAD_REQ(r13)
142 b .power7_wakeup_noloss
143 2: b .power7_wakeup_loss
145 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
146 #endif /* CONFIG_PPC_P7_NAP */
147 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
151 machine_check_pSeries_1:
152 /* This is moved out of line as it can be patched by FW, but
153 * some code path might still want to branch into the original
156 HMT_MEDIUM_PPR_DISCARD
157 SET_SCRATCH0(r13) /* save r13 */
158 EXCEPTION_PROLOG_0(PACA_EXMC)
159 b machine_check_pSeries_0
162 .globl data_access_pSeries
164 HMT_MEDIUM_PPR_DISCARD
167 b data_access_check_stab
168 data_access_not_stab:
169 END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
170 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
174 .globl data_access_slb_pSeries
175 data_access_slb_pSeries:
176 HMT_MEDIUM_PPR_DISCARD
178 EXCEPTION_PROLOG_0(PACA_EXSLB)
179 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
180 std r3,PACA_EXSLB+EX_R3(r13)
183 /* Keep that around for when we re-implement dynamic VSIDs */
185 bge slb_miss_user_pseries
186 #endif /* __DISABLED__ */
188 #ifndef CONFIG_RELOCATABLE
192 * We can't just use a direct branch to .slb_miss_realmode
193 * because the distance from here to there depends on where
194 * the kernel ends up being put.
197 ld r10,PACAKBASE(r13)
198 LOAD_HANDLER(r10, .slb_miss_realmode)
203 STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access)
206 .globl instruction_access_slb_pSeries
207 instruction_access_slb_pSeries:
208 HMT_MEDIUM_PPR_DISCARD
210 EXCEPTION_PROLOG_0(PACA_EXSLB)
211 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
212 std r3,PACA_EXSLB+EX_R3(r13)
213 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
215 /* Keep that around for when we re-implement dynamic VSIDs */
217 bge slb_miss_user_pseries
218 #endif /* __DISABLED__ */
220 #ifndef CONFIG_RELOCATABLE
224 ld r10,PACAKBASE(r13)
225 LOAD_HANDLER(r10, .slb_miss_realmode)
230 /* We open code these as we can't have a ". = x" (even with
231 * x = "." within a feature section
234 .globl hardware_interrupt_pSeries;
235 .globl hardware_interrupt_hv;
236 hardware_interrupt_pSeries:
237 hardware_interrupt_hv:
238 HMT_MEDIUM_PPR_DISCARD
240 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
241 EXC_HV, SOFTEN_TEST_HV)
242 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
244 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
245 EXC_STD, SOFTEN_TEST_HV_201)
246 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
247 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
249 STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
250 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
252 STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
253 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
255 STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
256 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
259 .globl decrementer_pSeries
261 _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR)
263 STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
265 MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super)
266 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
268 STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
269 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
272 .globl system_call_pSeries
275 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
278 std r9,PACA_EXGEN+EX_R9(r13)
279 std r10,PACA_EXGEN+EX_R10(r13)
285 SYSCALL_PSERIES_2_RFID
287 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
289 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
290 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
292 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
293 * out of line to handle them
296 hv_data_storage_trampoline:
298 EXCEPTION_PROLOG_0(PACA_EXGEN)
302 hv_instr_storage_trampoline:
304 EXCEPTION_PROLOG_0(PACA_EXGEN)
308 emulation_assist_trampoline:
310 EXCEPTION_PROLOG_0(PACA_EXGEN)
311 b emulation_assist_hv
314 hv_exception_trampoline:
316 EXCEPTION_PROLOG_0(PACA_EXGEN)
320 hv_doorbell_trampoline:
322 EXCEPTION_PROLOG_0(PACA_EXGEN)
325 /* We need to deal with the Altivec unavailable exception
326 * here which is at 0xf20, thus in the middle of the
327 * prolog code of the PerformanceMonitor one. A little
328 * trickery is thus necessary
331 performance_monitor_pseries_trampoline:
333 EXCEPTION_PROLOG_0(PACA_EXGEN)
334 b performance_monitor_pSeries
337 altivec_unavailable_pseries_trampoline:
339 EXCEPTION_PROLOG_0(PACA_EXGEN)
340 b altivec_unavailable_pSeries
343 vsx_unavailable_pseries_trampoline:
345 EXCEPTION_PROLOG_0(PACA_EXGEN)
346 b vsx_unavailable_pSeries
349 facility_unavailable_trampoline:
351 EXCEPTION_PROLOG_0(PACA_EXGEN)
352 b facility_unavailable_pSeries
355 hv_facility_unavailable_trampoline:
357 EXCEPTION_PROLOG_0(PACA_EXGEN)
358 b facility_unavailable_hv
360 #ifdef CONFIG_CBE_RAS
361 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
362 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
363 #endif /* CONFIG_CBE_RAS */
365 STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
366 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
369 .global denorm_exception_hv
371 HMT_MEDIUM_PPR_DISCARD
372 mtspr SPRN_SPRG_HSCRATCH0,r13
373 EXCEPTION_PROLOG_0(PACA_EXGEN)
374 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
376 #ifdef CONFIG_PPC_DENORMALISATION
378 mfspr r11,SPRN_HSRR0 /* save HSRR0 */
379 andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */
380 addi r11,r11,-4 /* HSRR0 is next instruction */
385 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
386 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500)
388 #ifdef CONFIG_CBE_RAS
389 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
390 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
391 #endif /* CONFIG_CBE_RAS */
393 STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
394 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
396 #ifdef CONFIG_CBE_RAS
397 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
398 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
401 #endif /* CONFIG_CBE_RAS */
404 /*** Out of line interrupts support ***/
407 /* moved from 0x200 */
408 machine_check_pSeries:
409 .globl machine_check_fwnmi
411 HMT_MEDIUM_PPR_DISCARD
412 SET_SCRATCH0(r13) /* save r13 */
413 EXCEPTION_PROLOG_0(PACA_EXMC)
414 machine_check_pSeries_0:
415 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200)
416 EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD)
417 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
419 /* moved from 0x300 */
420 data_access_check_stab:
422 std r9,PACA_EXSLB+EX_R9(r13)
423 std r10,PACA_EXSLB+EX_R10(r13)
427 rlwimi r10,r9,16,0x20
428 #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
429 lbz r9,HSTATE_IN_GUEST(r13)
430 rlwimi r10,r9,8,0x300
434 beq do_stab_bolted_pSeries
436 ld r9,PACA_EXSLB+EX_R9(r13)
437 ld r10,PACA_EXSLB+EX_R10(r13)
438 b data_access_not_stab
439 do_stab_bolted_pSeries:
440 std r11,PACA_EXSLB+EX_R11(r13)
441 std r12,PACA_EXSLB+EX_R12(r13)
443 std r10,PACA_EXSLB+EX_R13(r13)
444 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
446 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
447 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
448 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
449 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
450 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
451 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
453 #ifdef CONFIG_PPC_DENORMALISATION
457 * To denormalise we need to move a copy of the register to itself.
458 * For POWER6 do that here for all FP regs.
461 ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1)
462 xori r10,r10,(MSR_FE0|MSR_FE1)
466 #define FMR2(n) fmr (n), (n) ; fmr n+1, n+1
467 #define FMR4(n) FMR2(n) ; FMR2(n+2)
468 #define FMR8(n) FMR4(n) ; FMR4(n+4)
469 #define FMR16(n) FMR8(n) ; FMR8(n+8)
470 #define FMR32(n) FMR16(n) ; FMR16(n+16)
475 * To denormalise we need to move a copy of the register to itself.
476 * For POWER7 do that here for the first 32 VSX registers only.
479 oris r10,r10,MSR_VSX@h
483 #define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1)
484 #define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2)
485 #define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4)
486 #define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8)
487 #define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16)
490 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206)
494 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
496 * To denormalise we need to move a copy of the register to itself.
497 * For POWER8 we need to do that for all 64 VSX registers
503 ld r9,PACA_EXGEN+EX_R9(r13)
504 RESTORE_PPR_PACA(PACA_EXGEN, r10)
506 ld r10,PACA_EXGEN+EX_CFAR(r13)
508 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
509 ld r10,PACA_EXGEN+EX_R10(r13)
510 ld r11,PACA_EXGEN+EX_R11(r13)
511 ld r12,PACA_EXGEN+EX_R12(r13)
512 ld r13,PACA_EXGEN+EX_R13(r13)
518 /* moved from 0xe00 */
519 STD_EXCEPTION_HV_OOL(0xe02, h_data_storage)
520 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
521 STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage)
522 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
523 STD_EXCEPTION_HV_OOL(0xe42, emulation_assist)
524 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
525 STD_EXCEPTION_HV_OOL(0xe62, hmi_exception) /* need to flush cache ? */
526 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
527 MASKABLE_EXCEPTION_HV_OOL(0xe82, h_doorbell)
528 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe82)
530 /* moved from 0xf00 */
531 STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
532 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
533 STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
534 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
535 STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
536 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
537 STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
538 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf60)
539 STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable)
540 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82)
543 * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
544 * - If it was a decrementer interrupt, we bump the dec to max and and return.
545 * - If it was a doorbell we return immediately since doorbells are edge
546 * triggered and won't automatically refire.
547 * - else we hard disable and return.
548 * This is called with r10 containing the value to OR to the paca field.
550 #define MASKED_INTERRUPT(_H) \
551 masked_##_H##interrupt: \
552 std r11,PACA_EXGEN+EX_R11(r13); \
553 lbz r11,PACAIRQHAPPENED(r13); \
555 stb r11,PACAIRQHAPPENED(r13); \
556 cmpwi r10,PACA_IRQ_DEC; \
559 ori r10,r10,0xffff; \
560 mtspr SPRN_DEC,r10; \
562 1: cmpwi r10,PACA_IRQ_DBELL; \
564 mfspr r10,SPRN_##_H##SRR1; \
565 rldicl r10,r10,48,1; /* clear MSR_EE */ \
567 mtspr SPRN_##_H##SRR1,r10; \
569 ld r9,PACA_EXGEN+EX_R9(r13); \
570 ld r10,PACA_EXGEN+EX_R10(r13); \
571 ld r11,PACA_EXGEN+EX_R11(r13); \
580 * Called from arch_local_irq_enable when an interrupt needs
581 * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate
582 * which kind of interrupt. MSR:EE is already off. We generate a
583 * stackframe like if a real interrupt had happened.
585 * Note: While MSR:EE is off, we need to make sure that _MSR
586 * in the generated frame has EE set to 1 or the exception
587 * handler will not properly re-enable them.
589 _GLOBAL(__replay_interrupt)
590 /* We are going to jump to the exception common code which
591 * will retrieve various register values from the PACA which
592 * we don't give a damn about, so we don't bother storing them.
599 beq decrementer_common
601 beq hardware_interrupt_common
604 beq h_doorbell_common
607 beq doorbell_super_common
608 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
611 #ifdef CONFIG_PPC_PSERIES
613 * Vectors for the FWNMI option. Share common code.
615 .globl system_reset_fwnmi
618 HMT_MEDIUM_PPR_DISCARD
619 SET_SCRATCH0(r13) /* save r13 */
620 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
623 #endif /* CONFIG_PPC_PSERIES */
627 * This is used for when the SLB miss handler has to go virtual,
628 * which doesn't happen for now anymore but will once we re-implement
629 * dynamic VSIDs for shared page tables
631 slb_miss_user_pseries:
632 std r10,PACA_EXGEN+EX_R10(r13)
633 std r11,PACA_EXGEN+EX_R11(r13)
634 std r12,PACA_EXGEN+EX_R12(r13)
636 ld r11,PACA_EXSLB+EX_R9(r13)
637 ld r12,PACA_EXSLB+EX_R3(r13)
638 std r10,PACA_EXGEN+EX_R13(r13)
639 std r11,PACA_EXGEN+EX_R9(r13)
640 std r12,PACA_EXGEN+EX_R3(r13)
643 mfspr r11,SRR0 /* save SRR0 */
644 ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
645 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
647 mfspr r12,SRR1 /* and SRR1 */
650 b . /* prevent spec. execution */
651 #endif /* __DISABLED__ */
653 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
654 kvmppc_skip_interrupt:
656 * Here all GPRs are unchanged from when the interrupt happened
657 * except for r13, which is saved in SPRG_SCRATCH0.
666 kvmppc_skip_Hinterrupt:
668 * Here all GPRs are unchanged from when the interrupt happened
669 * except for r13, which is saved in SPRG_SCRATCH0.
671 mfspr r13, SPRN_HSRR0
673 mtspr SPRN_HSRR0, r13
680 * Code from here down to __end_handlers is invoked from the
681 * exception prologs above. Because the prologs assemble the
682 * addresses of these handlers using the LOAD_HANDLER macro,
683 * which uses an ori instruction, these handlers must be in
684 * the first 64k of the kernel image.
687 /*** Common interrupt handlers ***/
689 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
692 * Machine check is different because we use a different
693 * save area: PACA_EXMC instead of PACA_EXGEN.
696 .globl machine_check_common
697 machine_check_common:
700 std r10,PACA_EXGEN+EX_DAR(r13)
702 stw r10,PACA_EXGEN+EX_DSISR(r13)
703 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
706 ld r3,PACA_EXGEN+EX_DAR(r13)
707 lwz r4,PACA_EXGEN+EX_DSISR(r13)
711 addi r3,r1,STACK_FRAME_OVERHEAD
712 bl .machine_check_exception
715 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
716 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt)
717 STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt)
718 #ifdef CONFIG_PPC_DOORBELL
719 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, .doorbell_exception)
721 STD_EXCEPTION_COMMON_ASYNC(0xa00, doorbell_super, .unknown_exception)
723 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
724 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
725 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
726 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .emulation_assist_interrupt)
727 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception)
728 #ifdef CONFIG_PPC_DOORBELL
729 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .doorbell_exception)
731 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .unknown_exception)
733 STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception)
734 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
735 STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception)
736 #ifdef CONFIG_ALTIVEC
737 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
739 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
741 #ifdef CONFIG_CBE_RAS
742 STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
743 STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
744 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
745 #endif /* CONFIG_CBE_RAS */
748 * Relocation-on interrupts: A subset of the interrupts can be delivered
749 * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering
750 * it. Addresses are the same as the original interrupt addresses, but
751 * offset by 0xc000000000004000.
752 * It's impossible to receive interrupts below 0x300 via this mechanism.
753 * KVM: None of these traps are from the guest ; anything that escalated
754 * to HV=1 from HV=0 is delivered via real mode handlers.
758 * This uses the standard macro, since the original 0x300 vector
759 * only has extra guff for STAB-based processors -- which never
762 STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access)
764 .globl data_access_slb_relon_pSeries
765 data_access_slb_relon_pSeries:
767 EXCEPTION_PROLOG_0(PACA_EXSLB)
768 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
769 std r3,PACA_EXSLB+EX_R3(r13)
772 #ifndef CONFIG_RELOCATABLE
776 * We can't just use a direct branch to .slb_miss_realmode
777 * because the distance from here to there depends on where
778 * the kernel ends up being put.
781 ld r10,PACAKBASE(r13)
782 LOAD_HANDLER(r10, .slb_miss_realmode)
787 STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access)
789 .globl instruction_access_slb_relon_pSeries
790 instruction_access_slb_relon_pSeries:
792 EXCEPTION_PROLOG_0(PACA_EXSLB)
793 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
794 std r3,PACA_EXSLB+EX_R3(r13)
795 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
797 #ifndef CONFIG_RELOCATABLE
801 ld r10,PACAKBASE(r13)
802 LOAD_HANDLER(r10, .slb_miss_realmode)
808 .globl hardware_interrupt_relon_pSeries;
809 .globl hardware_interrupt_relon_hv;
810 hardware_interrupt_relon_pSeries:
811 hardware_interrupt_relon_hv:
813 _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
815 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
816 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
817 STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment)
818 STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check)
819 STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable)
820 MASKABLE_RELON_EXCEPTION_PSERIES(0x4900, 0x900, decrementer)
821 STD_RELON_EXCEPTION_HV(0x4980, 0x982, hdecrementer)
822 MASKABLE_RELON_EXCEPTION_PSERIES(0x4a00, 0xa00, doorbell_super)
823 STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b)
826 .globl system_call_relon_pSeries
827 system_call_relon_pSeries:
830 SYSCALL_PSERIES_2_DIRECT
833 STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step)
836 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
839 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
842 emulation_assist_relon_trampoline:
844 EXCEPTION_PROLOG_0(PACA_EXGEN)
845 b emulation_assist_relon_hv
848 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
851 h_doorbell_relon_trampoline:
853 EXCEPTION_PROLOG_0(PACA_EXGEN)
854 b h_doorbell_relon_hv
857 performance_monitor_relon_pseries_trampoline:
859 EXCEPTION_PROLOG_0(PACA_EXGEN)
860 b performance_monitor_relon_pSeries
863 altivec_unavailable_relon_pseries_trampoline:
865 EXCEPTION_PROLOG_0(PACA_EXGEN)
866 b altivec_unavailable_relon_pSeries
869 vsx_unavailable_relon_pseries_trampoline:
871 EXCEPTION_PROLOG_0(PACA_EXGEN)
872 b vsx_unavailable_relon_pSeries
875 facility_unavailable_relon_trampoline:
877 EXCEPTION_PROLOG_0(PACA_EXGEN)
878 b facility_unavailable_relon_pSeries
881 hv_facility_unavailable_relon_trampoline:
883 EXCEPTION_PROLOG_0(PACA_EXGEN)
884 b hv_facility_unavailable_relon_hv
886 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
887 #ifdef CONFIG_PPC_DENORMALISATION
889 b denorm_exception_hv
891 STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
893 /* Other future vectors */
895 .globl __end_interrupts
899 system_call_entry_direct:
900 #if defined(CONFIG_RELOCATABLE)
901 /* The first level prologue may have used LR to get here, saving
902 * orig in r10. To save hacking/ifdeffing common code, restore here.
909 ppc64_runlatch_on_trampoline:
910 b .__ppc64_runlatch_on
913 * Here we have detected that the kernel stack pointer is bad.
914 * R9 contains the saved CR, r13 points to the paca,
915 * r10 contains the (bad) kernel stack pointer,
916 * r11 and r12 contain the saved SRR0 and SRR1.
917 * We switch to using an emergency stack, save the registers there,
918 * and call kernel_bad_stack(), which panics.
921 ld r1,PACAEMERGSP(r13)
922 subi r1,r1,64+INT_FRAME_SIZE
954 std r10,ORIG_GPR3(r1)
955 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
958 lhz r12,PACA_TRAP_SAVE(r13)
960 addi r11,r1,INT_FRAME_SIZE
965 ld r11,exception_marker@toc(r2)
967 std r11,STACK_FRAME_OVERHEAD-16(r1)
968 1: addi r3,r1,STACK_FRAME_OVERHEAD
973 * Here r13 points to the paca, r9 contains the saved CR,
974 * SRR0 and SRR1 are saved in r11 and r12,
975 * r9 - r13 are saved in paca->exgen.
978 .globl data_access_common
981 std r10,PACA_EXGEN+EX_DAR(r13)
983 stw r10,PACA_EXGEN+EX_DSISR(r13)
984 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
987 ld r3,PACA_EXGEN+EX_DAR(r13)
988 lwz r4,PACA_EXGEN+EX_DSISR(r13)
990 b .do_hash_page /* Try to handle as hpte fault */
993 .globl h_data_storage_common
994 h_data_storage_common:
996 std r10,PACA_EXGEN+EX_DAR(r13)
997 mfspr r10,SPRN_HDSISR
998 stw r10,PACA_EXGEN+EX_DSISR(r13)
999 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
1002 addi r3,r1,STACK_FRAME_OVERHEAD
1003 bl .unknown_exception
1007 .globl instruction_access_common
1008 instruction_access_common:
1009 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
1013 andis. r4,r12,0x5820
1015 b .do_hash_page /* Try to handle as hpte fault */
1017 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception)
1020 * Here is the common SLB miss user that is used when going to virtual
1021 * mode for SLB misses, that is currently not used
1025 .globl slb_miss_user_common
1026 slb_miss_user_common:
1028 std r3,PACA_EXGEN+EX_DAR(r13)
1029 stw r9,PACA_EXGEN+EX_CCR(r13)
1030 std r10,PACA_EXGEN+EX_LR(r13)
1031 std r11,PACA_EXGEN+EX_SRR0(r13)
1032 bl .slb_allocate_user
1034 ld r10,PACA_EXGEN+EX_LR(r13)
1035 ld r3,PACA_EXGEN+EX_R3(r13)
1036 lwz r9,PACA_EXGEN+EX_CCR(r13)
1037 ld r11,PACA_EXGEN+EX_SRR0(r13)
1041 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1042 beq- unrecov_user_slb
1050 clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
1056 ld r9,PACA_EXGEN+EX_R9(r13)
1057 ld r10,PACA_EXGEN+EX_R10(r13)
1058 ld r11,PACA_EXGEN+EX_R11(r13)
1059 ld r12,PACA_EXGEN+EX_R12(r13)
1060 ld r13,PACA_EXGEN+EX_R13(r13)
1065 EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
1066 ld r4,PACA_EXGEN+EX_DAR(r13)
1073 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
1076 1: addi r3,r1,STACK_FRAME_OVERHEAD
1077 bl .unrecoverable_exception
1080 #endif /* __DISABLED__ */
1084 .globl alignment_common
1087 std r10,PACA_EXGEN+EX_DAR(r13)
1088 mfspr r10,SPRN_DSISR
1089 stw r10,PACA_EXGEN+EX_DSISR(r13)
1090 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
1091 ld r3,PACA_EXGEN+EX_DAR(r13)
1092 lwz r4,PACA_EXGEN+EX_DSISR(r13)
1097 addi r3,r1,STACK_FRAME_OVERHEAD
1098 bl .alignment_exception
1102 .globl program_check_common
1103 program_check_common:
1104 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
1107 addi r3,r1,STACK_FRAME_OVERHEAD
1108 bl .program_check_exception
1112 .globl fp_unavailable_common
1113 fp_unavailable_common:
1114 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
1115 bne 1f /* if from user, just load it up */
1118 addi r3,r1,STACK_FRAME_OVERHEAD
1119 bl .kernel_fp_unavailable_exception
1122 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1124 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1125 * transaction), go do TM stuff
1127 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1129 END_FTR_SECTION_IFSET(CPU_FTR_TM)
1132 b fast_exception_return
1133 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1134 2: /* User process was in a transaction */
1137 addi r3,r1,STACK_FRAME_OVERHEAD
1138 bl .fp_unavailable_tm
1142 .globl altivec_unavailable_common
1143 altivec_unavailable_common:
1144 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
1145 #ifdef CONFIG_ALTIVEC
1148 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1149 BEGIN_FTR_SECTION_NESTED(69)
1150 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1151 * transaction), go do TM stuff
1153 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1155 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1158 b fast_exception_return
1159 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1160 2: /* User process was in a transaction */
1163 addi r3,r1,STACK_FRAME_OVERHEAD
1164 bl .altivec_unavailable_tm
1168 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
1172 addi r3,r1,STACK_FRAME_OVERHEAD
1173 bl .altivec_unavailable_exception
1177 .globl vsx_unavailable_common
1178 vsx_unavailable_common:
1179 EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
1183 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1184 BEGIN_FTR_SECTION_NESTED(69)
1185 /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
1186 * transaction), go do TM stuff
1188 rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
1190 END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
1193 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1194 2: /* User process was in a transaction */
1197 addi r3,r1,STACK_FRAME_OVERHEAD
1198 bl .vsx_unavailable_tm
1202 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1206 addi r3,r1,STACK_FRAME_OVERHEAD
1207 bl .vsx_unavailable_exception
1210 STD_EXCEPTION_COMMON(0xf60, facility_unavailable, .facility_unavailable_exception)
1211 STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, .facility_unavailable_exception)
1214 .globl __end_handlers
1217 /* Equivalents to the above handlers for relocation-on interrupt vectors */
1218 STD_RELON_EXCEPTION_HV_OOL(0xe40, emulation_assist)
1219 MASKABLE_RELON_EXCEPTION_HV_OOL(0xe80, h_doorbell)
1221 STD_RELON_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
1222 STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
1223 STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
1224 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1225 STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1227 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1229 * Data area reserved for FWNMI option.
1230 * This address (0x7000) is fixed by the RPA.
1233 .globl fwnmi_data_area
1236 /* pseries and powernv need to keep the whole page from
1237 * 0x7000 to 0x8000 free for use by the firmware
1240 #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
1242 /* Space for CPU0's segment table */
1248 #ifdef CONFIG_PPC_POWERNV
1249 _GLOBAL(opal_mc_secondary_handler)
1250 HMT_MEDIUM_PPR_DISCARD
1255 std r3,PACA_OPAL_MC_EVT(r13)
1256 ld r13,OPAL_MC_SRR0(r3)
1258 ld r13,OPAL_MC_SRR1(r3)
1260 ld r3,OPAL_MC_GPR3(r3)
1262 b machine_check_pSeries
1263 #endif /* CONFIG_PPC_POWERNV */
1267 * r13 points to the PACA, r9 contains the saved CR,
1268 * r12 contain the saved SRR1, SRR0 is still ready for return
1269 * r3 has the faulting address
1270 * r9 - r13 are saved in paca->exslb.
1271 * r3 is saved in paca->slb_r3
1272 * We assume we aren't going to take any exceptions during this procedure.
1274 _GLOBAL(slb_miss_realmode)
1276 #ifdef CONFIG_RELOCATABLE
1280 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1281 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
1283 bl .slb_allocate_realmode
1285 /* All done -- return from exception. */
1287 ld r10,PACA_EXSLB+EX_LR(r13)
1288 ld r3,PACA_EXSLB+EX_R3(r13)
1289 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1293 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1299 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
1302 RESTORE_PPR_PACA(PACA_EXSLB, r9)
1303 ld r9,PACA_EXSLB+EX_R9(r13)
1304 ld r10,PACA_EXSLB+EX_R10(r13)
1305 ld r11,PACA_EXSLB+EX_R11(r13)
1306 ld r12,PACA_EXSLB+EX_R12(r13)
1307 ld r13,PACA_EXSLB+EX_R13(r13)
1309 b . /* prevent speculative execution */
1311 2: mfspr r11,SPRN_SRR0
1312 ld r10,PACAKBASE(r13)
1313 LOAD_HANDLER(r10,unrecov_slb)
1315 ld r10,PACAKMSR(r13)
1321 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
1324 1: addi r3,r1,STACK_FRAME_OVERHEAD
1325 bl .unrecoverable_exception
1329 #ifdef CONFIG_PPC_970_NAP
1332 std r9,TI_LOCAL_FLAGS(r11)
1333 ld r10,_LINK(r1) /* make idle task do the */
1334 std r10,_NIP(r1) /* equivalent of a blr */
1342 _STATIC(do_hash_page)
1346 andis. r0,r4,0xa410 /* weird error? */
1347 bne- handle_page_fault /* if not, try to insert a HPTE */
1348 andis. r0,r4,DSISR_DABRMATCH@h
1349 bne- handle_dabr_fault
1352 andis. r0,r4,0x0020 /* Is it a segment table fault? */
1353 bne- do_ste_alloc /* If so handle it */
1354 END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
1356 CURRENT_THREAD_INFO(r11, r1)
1357 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
1358 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
1359 bne 77f /* then don't call hash_page now */
1361 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
1362 * accessing a userspace segment (even from the kernel). We assume
1363 * kernel addresses always have the high bit set.
1365 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
1366 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
1367 orc r0,r12,r0 /* MSR_PR | ~high_bit */
1368 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
1369 ori r4,r4,1 /* add _PAGE_PRESENT */
1370 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
1373 * r3 contains the faulting address
1374 * r4 contains the required access permissions
1375 * r5 contains the trap number
1377 * at return r3 = 0 for success, 1 for page fault, negative for error
1379 bl .hash_page /* build HPTE if possible */
1380 cmpdi r3,0 /* see if hash_page succeeded */
1383 beq fast_exc_return_irq /* Return from exception on success */
1388 /* Here we have a page fault that hash_page can't handle. */
1392 addi r3,r1,STACK_FRAME_OVERHEAD
1398 addi r3,r1,STACK_FRAME_OVERHEAD
1403 /* We have a data breakpoint exception - handle it */
1408 addi r3,r1,STACK_FRAME_OVERHEAD
1410 12: b .ret_from_except_lite
1413 /* We have a page fault that hash_page could handle but HV refused
1418 addi r3,r1,STACK_FRAME_OVERHEAD
1424 * We come here as a result of a DSI at a point where we don't want
1425 * to call hash_page, such as when we are accessing memory (possibly
1426 * user memory) inside a PMU interrupt that occurred while interrupts
1427 * were soft-disabled. We want to invoke the exception handler for
1428 * the access, or panic if there isn't a handler.
1432 addi r3,r1,STACK_FRAME_OVERHEAD
1437 /* here we have a segment miss */
1439 bl .ste_allocate /* try to insert stab entry */
1441 bne- handle_page_fault
1442 b fast_exception_return
1445 * r13 points to the PACA, r9 contains the saved CR,
1446 * r11 and r12 contain the saved SRR0 and SRR1.
1447 * r9 - r13 are saved in paca->exslb.
1448 * We assume we aren't going to take any exceptions during this procedure.
1449 * We assume (DAR >> 60) == 0xc.
1452 _GLOBAL(do_stab_bolted)
1453 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1454 std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
1455 mfspr r11,SPRN_DAR /* ea */
1458 * check for bad kernel/user address
1459 * (ea & ~REGION_MASK) >= PGTABLE_RANGE
1461 rldicr. r9,r11,4,(63 - 46 - 4)
1462 li r9,0 /* VSID = 0 for bad address */
1467 * This is the kernel vsid, we take the top for context from
1468 * the range. context = (MAX_USER_CONTEXT) + ((ea >> 60) - 0xc) + 1
1469 * Here we know that (ea >> 60) == 0xc
1471 lis r9,(MAX_USER_CONTEXT + 1)@ha
1472 addi r9,r9,(MAX_USER_CONTEXT + 1)@l
1474 srdi r10,r11,SID_SHIFT
1475 rldimi r10,r9,ESID_BITS,0 /* proto vsid */
1476 ASM_VSID_SCRAMBLE(r10, r9, 256M)
1477 rldic r9,r10,12,16 /* r9 = vsid << 12 */
1480 /* Hash to the primary group */
1481 ld r10,PACASTABVIRT(r13)
1482 srdi r11,r11,SID_SHIFT
1483 rldimi r10,r11,7,52 /* r10 = first ste of the group */
1485 /* Search the primary group for a free entry */
1486 1: ld r11,0(r10) /* Test valid bit of the current ste */
1493 /* Stick for only searching the primary group for now. */
1494 /* At least for now, we use a very simple random castout scheme */
1495 /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
1497 rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
1500 /* r10 currently points to an ste one past the group of interest */
1501 /* make it point to the randomly selected entry */
1503 or r10,r10,r11 /* r10 is the entry to invalidate */
1505 isync /* mark the entry invalid */
1507 rldicl r11,r11,56,1 /* clear the valid bit */
1512 clrrdi r11,r11,28 /* Get the esid part of the ste */
1515 2: std r9,8(r10) /* Store the vsid part of the ste */
1518 mfspr r11,SPRN_DAR /* Get the new esid */
1519 clrrdi r11,r11,28 /* Permits a full 32b of ESID */
1520 ori r11,r11,0x90 /* Turn on valid and kp */
1521 std r11,0(r10) /* Put new entry back into the stab */
1525 /* All done -- return from exception. */
1526 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1527 ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
1529 andi. r10,r12,MSR_RI
1532 mtcrf 0x80,r9 /* restore CR */
1540 ld r9,PACA_EXSLB+EX_R9(r13)
1541 ld r10,PACA_EXSLB+EX_R10(r13)
1542 ld r11,PACA_EXSLB+EX_R11(r13)
1543 ld r12,PACA_EXSLB+EX_R12(r13)
1544 ld r13,PACA_EXSLB+EX_R13(r13)
1546 b . /* prevent speculative execution */