1
2
3
4
5
6
7
8
9 #include <asm/processor.h>
10 #include <asm/reg.h>
11 #include <asm/page.h>
12 #include <asm/mmu.h>
13 #include <asm/ppc_asm.h>
14 #include <asm/asm-offsets.h>
15 #include <asm/cputable.h>
16 #include <asm/pgtable.h>
17 #include <asm/exception-64e.h>
18 #include <asm/ppc-opcode.h>
19 #include <asm/kvm_asm.h>
20 #include <asm/kvm_booke_hv_asm.h>
21 #include <asm/feature-fixups.h>
22
23 #define VPTE_PMD_SHIFT (PTE_INDEX_SIZE)
24 #define VPTE_PUD_SHIFT (VPTE_PMD_SHIFT + PMD_INDEX_SIZE)
25 #define VPTE_PGD_SHIFT (VPTE_PUD_SHIFT + PUD_INDEX_SIZE)
26 #define VPTE_INDEX_SIZE (VPTE_PGD_SHIFT + PGD_INDEX_SIZE)
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 .macro tlb_prolog_bolted intnum addr
44 mtspr SPRN_SPRG_GEN_SCRATCH,r12
45 mfspr r12,SPRN_SPRG_TLB_EXFRAME
46 std r13,EX_TLB_R13(r12)
47 std r10,EX_TLB_R10(r12)
48 mfspr r13,SPRN_SPRG_PACA
49
50 mfcr r10
51 std r11,EX_TLB_R11(r12)
52 #ifdef CONFIG_KVM_BOOKE_HV
53 BEGIN_FTR_SECTION
54 mfspr r11, SPRN_SRR1
55 END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
56 #endif
57 DO_KVM \intnum, SPRN_SRR1
58 std r16,EX_TLB_R16(r12)
59 mfspr r16,\addr
60 std r14,EX_TLB_R14(r12)
61 ld r14,PACAPGD(r13)
62 std r15,EX_TLB_R15(r12)
63 std r10,EX_TLB_CR(r12)
64 #ifdef CONFIG_PPC_FSL_BOOK3E
65 START_BTB_FLUSH_SECTION
66 mfspr r11, SPRN_SRR1
67 andi. r10,r11,MSR_PR
68 beq 1f
69 BTB_FLUSH(r10)
70 1:
71 END_BTB_FLUSH_SECTION
72 std r7,EX_TLB_R7(r12)
73 #endif
74 TLB_MISS_PROLOG_STATS
75 .endm
76
77 .macro tlb_epilog_bolted
78 ld r14,EX_TLB_CR(r12)
79 #ifdef CONFIG_PPC_FSL_BOOK3E
80 ld r7,EX_TLB_R7(r12)
81 #endif
82 ld r10,EX_TLB_R10(r12)
83 ld r11,EX_TLB_R11(r12)
84 ld r13,EX_TLB_R13(r12)
85 mtcr r14
86 ld r14,EX_TLB_R14(r12)
87 ld r15,EX_TLB_R15(r12)
88 TLB_MISS_RESTORE_STATS
89 ld r16,EX_TLB_R16(r12)
90 mfspr r12,SPRN_SPRG_GEN_SCRATCH
91 .endm
92
93
94 START_EXCEPTION(data_tlb_miss_bolted)
95 tlb_prolog_bolted BOOKE_INTERRUPT_DTLB_MISS SPRN_DEAR
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 mfspr r11,SPRN_ESR
120
121 srdi r15,r16,60
122 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
123 bne- dtlb_miss_fault_bolted
124
125 rlwinm r10,r11,32-19,27,27
126 rlwimi r10,r11,32-16,19,19
127 cmpwi r15,0
128 ori r10,r10,_PAGE_PRESENT
129 oris r11,r10,_PAGE_ACCESSED@h
130
131 TLB_MISS_STATS_SAVE_INFO_BOLTED
132 bne tlb_miss_kernel_bolted
133
134 tlb_miss_common_bolted:
135
136
137
138
139
140
141
142
143
144
145
146 rldicl r15,r16,64-PGDIR_SHIFT+3,64-PGD_INDEX_SIZE-3
147 cmpldi cr0,r14,0
148 clrrdi r15,r15,3
149 beq tlb_miss_fault_bolted
150
151 BEGIN_MMU_FTR_SECTION
152
153
154
155 PPC_TLBSRX_DOT(0,R16)
156 ldx r14,r14,r15
157 beq tlb_miss_done_bolted
158 MMU_FTR_SECTION_ELSE
159 ldx r14,r14,r15
160 ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_USE_TLBRSRV)
161
162 rldicl r15,r16,64-PUD_SHIFT+3,64-PUD_INDEX_SIZE-3
163 clrrdi r15,r15,3
164 cmpdi cr0,r14,0
165 bge tlb_miss_fault_bolted
166 ldx r14,r14,r15
167
168 rldicl r15,r16,64-PMD_SHIFT+3,64-PMD_INDEX_SIZE-3
169 clrrdi r15,r15,3
170 cmpdi cr0,r14,0
171 bge tlb_miss_fault_bolted
172 ldx r14,r14,r15
173
174 rldicl r15,r16,64-PAGE_SHIFT+3,64-PTE_INDEX_SIZE-3
175 clrrdi r15,r15,3
176 cmpdi cr0,r14,0
177 bge tlb_miss_fault_bolted
178 ldx r14,r14,r15
179
180
181 andc. r15,r11,r14
182 rldicr r15,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
183 bne- tlb_miss_fault_bolted
184
185
186
187
188
189
190
191
192
193
194
195 clrrdi r11,r16,12
196 clrldi r15,r15,12
197 rlwimi r11,r14,32-19,27,31
198 rlwimi r15,r14,32-8,22,25
199 mtspr SPRN_MAS2,r11
200 andi. r11,r14,_PAGE_DIRTY
201 rlwimi r15,r14,32-2,26,31
202
203
204 bne 1f
205 li r11,MAS3_SW|MAS3_UW
206 andc r15,r15,r11
207 1:
208 mtspr SPRN_MAS7_MAS3,r15
209 tlbwe
210
211 tlb_miss_done_bolted:
212 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_NORM_OK)
213 tlb_epilog_bolted
214 rfi
215
216 itlb_miss_kernel_bolted:
217 li r11,_PAGE_PRESENT|_PAGE_BAP_SX
218 oris r11,r11,_PAGE_ACCESSED@h
219 tlb_miss_kernel_bolted:
220 mfspr r10,SPRN_MAS1
221 ld r14,PACA_KERNELPGD(r13)
222 cmpldi cr0,r15,8
223 rlwinm r10,r10,0,16,1
224 mtspr SPRN_MAS1,r10
225 beq+ tlb_miss_common_bolted
226
227 tlb_miss_fault_bolted:
228
229 andi. r10,r11,_PAGE_EXEC|_PAGE_BAP_SX
230 bne itlb_miss_fault_bolted
231 dtlb_miss_fault_bolted:
232 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
233 tlb_epilog_bolted
234 b exc_data_storage_book3e
235 itlb_miss_fault_bolted:
236 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
237 tlb_epilog_bolted
238 b exc_instruction_storage_book3e
239
240
241 START_EXCEPTION(instruction_tlb_miss_bolted)
242 tlb_prolog_bolted BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR0
243
244 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
245 srdi r15,r16,60
246 TLB_MISS_STATS_SAVE_INFO_BOLTED
247 bne- itlb_miss_fault_bolted
248
249 li r11,_PAGE_PRESENT|_PAGE_EXEC
250
251
252
253
254 cmpldi cr0,r15,0
255 oris r11,r11,_PAGE_ACCESSED@h
256 beq tlb_miss_common_bolted
257 b itlb_miss_kernel_bolted
258
259 #ifdef CONFIG_PPC_FSL_BOOK3E
260
261
262
263
264
265
266
267
268
269
270
271
272 START_EXCEPTION(instruction_tlb_miss_e6500)
273 tlb_prolog_bolted BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR0
274
275 ld r11,PACA_TCD_PTR(r13)
276 srdi. r15,r16,60
277 ori r16,r16,1
278
279 TLB_MISS_STATS_SAVE_INFO_BOLTED
280 bne tlb_miss_kernel_e6500
281
282 b tlb_miss_common_e6500
283
284 START_EXCEPTION(data_tlb_miss_e6500)
285 tlb_prolog_bolted BOOKE_INTERRUPT_DTLB_MISS SPRN_DEAR
286
287 ld r11,PACA_TCD_PTR(r13)
288 srdi. r15,r16,60
289 rldicr r16,r16,0,62
290
291 TLB_MISS_STATS_SAVE_INFO_BOLTED
292 bne tlb_miss_kernel_e6500
293
294
295
296
297
298
299
300
301
302
303
304
305
306 tlb_miss_common_e6500:
307 crmove cr2*4+2,cr0*4+2
308
309 BEGIN_FTR_SECTION
310
311
312
313
314
315
316 lhz r10,PACAPACAINDEX(r13)
317 addi r10,r10,1
318 crclr cr1*4+eq
319 1: lbarx r15,0,r11
320 cmpdi r15,0
321 bne 2f
322 stbcx. r10,0,r11
323 bne 1b
324 3:
325 .subsection 1
326 2: cmpd cr1,r15,r10
327 beq cr1,3b
328 10: lbz r15,0(r11)
329 cmpdi r15,0
330 bne 10b
331 b 1b
332 .previous
333 END_FTR_SECTION_IFSET(CPU_FTR_SMT)
334
335 lbz r7,TCD_ESEL_NEXT(r11)
336
337 BEGIN_FTR_SECTION
338
339
340
341
342
343
344
345
346 rlwinm r10,r7,16,0xff0000
347 oris r10,r10,MAS0_TLBSEL(1)@h
348 mtspr SPRN_MAS0,r10
349 isync
350 tlbre
351 mfspr r15,SPRN_MAS1
352 andis. r15,r15,MAS1_VALID@h
353 beq 5f
354
355 BEGIN_FTR_SECTION_NESTED(532)
356 mfspr r10,SPRN_MAS8
357 rlwinm r10,r10,0,0x80000fff
358 mtspr SPRN_MAS5,r10
359 END_FTR_SECTION_NESTED(CPU_FTR_EMB_HV,CPU_FTR_EMB_HV,532)
360
361 mfspr r10,SPRN_MAS1
362 rlwinm r15,r10,0,0x3fff0000
363 rlwimi r15,r10,20,0x00000003
364 mfspr r10,SPRN_MAS6
365 mtspr SPRN_MAS6,r15
366
367 mfspr r15,SPRN_MAS2
368 isync
369 tlbilxva 0,r15
370 isync
371
372 mtspr SPRN_MAS6,r10
373
374 5:
375 BEGIN_FTR_SECTION_NESTED(532)
376 li r10,0
377 mtspr SPRN_MAS8,r10
378 mtspr SPRN_MAS5,r10
379 END_FTR_SECTION_NESTED(CPU_FTR_EMB_HV,CPU_FTR_EMB_HV,532)
380
381 tlbsx 0,r16
382 mfspr r10,SPRN_MAS1
383 andis. r15,r10,MAS1_VALID@h
384 bne tlb_miss_done_e6500
385 FTR_SECTION_ELSE
386 mfspr r10,SPRN_MAS1
387 ALT_FTR_SECTION_END_IFSET(CPU_FTR_SMT)
388
389 oris r10,r10,MAS1_VALID@h
390 beq cr2,4f
391 rlwinm r10,r10,0,16,1
392 4: mtspr SPRN_MAS1,r10
393
394
395
396
397 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
398 bne- tlb_miss_fault_e6500
399
400 rldicl r15,r16,64-PGDIR_SHIFT+3,64-PGD_INDEX_SIZE-3
401 cmpldi cr0,r14,0
402 clrrdi r15,r15,3
403 beq- tlb_miss_fault_e6500
404 ldx r14,r14,r15
405
406 rldicl r15,r16,64-PUD_SHIFT+3,64-PUD_INDEX_SIZE-3
407 clrrdi r15,r15,3
408 cmpdi cr0,r14,0
409 bge tlb_miss_huge_e6500
410 ldx r14,r14,r15
411
412 rldicl r15,r16,64-PMD_SHIFT+3,64-PMD_INDEX_SIZE-3
413 clrrdi r15,r15,3
414 cmpdi cr0,r14,0
415 bge tlb_miss_huge_e6500
416 ldx r14,r14,r15
417
418 mfspr r10,SPRN_MAS0
419 cmpdi cr0,r14,0
420 bge tlb_miss_huge_e6500
421
422
423
424
425
426
427
428
429
430
431
432
433 ori r14,r14,(BOOK3E_PAGESZ_4K << MAS3_SPSIZE_SHIFT)
434 mtspr SPRN_MAS7_MAS3,r14
435
436 clrrdi r15,r16,21
437 mtspr SPRN_MAS2,r15
438
439 tlb_miss_huge_done_e6500:
440 lbz r16,TCD_ESEL_MAX(r11)
441 lbz r14,TCD_ESEL_FIRST(r11)
442 rlwimi r10,r7,16,0x00ff0000
443 addi r7,r7,1
444 mtspr SPRN_MAS0,r10
445 cmpw r7,r16
446 iseleq r7,r14,r7
447 stb r7,TCD_ESEL_NEXT(r11)
448
449 tlbwe
450
451 tlb_miss_done_e6500:
452 .macro tlb_unlock_e6500
453 BEGIN_FTR_SECTION
454 beq cr1,1f
455 li r15,0
456 isync
457 stb r15,0(r11)
458 1:
459 END_FTR_SECTION_IFSET(CPU_FTR_SMT)
460 .endm
461
462 tlb_unlock_e6500
463 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_NORM_OK)
464 tlb_epilog_bolted
465 rfi
466
467 tlb_miss_huge_e6500:
468 beq tlb_miss_fault_e6500
469 li r10,1
470 andi. r15,r14,HUGEPD_SHIFT_MASK@l
471 rldimi r14,r10,63,0
472 xor r14,r14,r15
473 ldx r14,0,r14
474
475
476
477
478
479
480
481
482
483
484 subi r15,r15,10
485 mfspr r10,SPRN_MAS1
486 rlwinm r10,r10,0,~MAS1_IND
487 rlwimi r10,r15,MAS1_TSIZE_SHIFT,MAS1_TSIZE_MASK
488 mtspr SPRN_MAS1,r10
489
490 li r10,-0x400
491 sld r15,r10,r15
492 and r10,r16,r15
493 rldicr r15,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
494 rlwimi r10,r14,32-19,27,31
495 clrldi r15,r15,PAGE_SHIFT
496 rlwimi r15,r14,32-8,22,25
497 mtspr SPRN_MAS2,r10
498 andi. r10,r14,_PAGE_DIRTY
499 rlwimi r15,r14,32-2,26,31
500
501
502 bne 1f
503 li r10,MAS3_SW|MAS3_UW
504 andc r15,r15,r10
505 1:
506 mtspr SPRN_MAS7_MAS3,r15
507
508 mfspr r10,SPRN_MAS0
509 b tlb_miss_huge_done_e6500
510
511 tlb_miss_kernel_e6500:
512 ld r14,PACA_KERNELPGD(r13)
513 cmpldi cr1,r15,8
514 beq+ cr1,tlb_miss_common_e6500
515
516 tlb_miss_fault_e6500:
517 tlb_unlock_e6500
518
519 andi. r16,r16,1
520 bne itlb_miss_fault_e6500
521 dtlb_miss_fault_e6500:
522 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
523 tlb_epilog_bolted
524 b exc_data_storage_book3e
525 itlb_miss_fault_e6500:
526 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
527 tlb_epilog_bolted
528 b exc_instruction_storage_book3e
529 #endif
530
531
532
533
534
535
536
537
538
539 START_EXCEPTION(data_tlb_miss)
540 TLB_MISS_PROLOG
541
542
543
544
545
546
547 mfspr r14,SPRN_ESR
548 mfspr r16,SPRN_DEAR
549 srdi r15,r16,60
550 cmpldi cr0,r15,0xc
551 TLB_MISS_STATS_SAVE_INFO
552 beq tlb_load_linear
553
554
555
556
557
558
559 andi. r10,r15,0x1
560 bne- virt_page_table_tlb_miss
561
562 std r14,EX_TLB_ESR(r12);
563 std r16,EX_TLB_DEAR(r12);
564
565
566 li r11,_PAGE_PRESENT
567 oris r11,r11,_PAGE_ACCESSED@h
568
569
570
571 cmpldi cr0,r15,0
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590 rlwimi r11,r14,32-19,27,27
591 rlwimi r11,r14,32-16,19,19
592 beq normal_tlb_miss
593
594 1: mfspr r10,SPRN_MAS1
595 cmpldi cr0,r15,8
596 rlwinm r10,r10,0,16,1
597 mtspr SPRN_MAS1,r10
598 beq+ normal_tlb_miss
599
600
601
602
603 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
604 TLB_MISS_EPILOG_ERROR
605 b exc_data_storage_book3e
606
607
608 START_EXCEPTION(instruction_tlb_miss)
609 TLB_MISS_PROLOG
610
611
612
613
614
615
616 li r14,-1
617
618
619
620
621
622
623
624
625 srdi r15,r16,60
626 cmpldi cr0,r15,0xc
627 TLB_MISS_STATS_SAVE_INFO
628 beq tlb_load_linear
629
630
631
632 li r11,_PAGE_PRESENT|_PAGE_EXEC
633 oris r11,r11,_PAGE_ACCESSED@h
634
635 cmpldi cr0,r15,0
636 std r14,EX_TLB_ESR(r12)
637 beq normal_tlb_miss
638
639 li r11,_PAGE_PRESENT|_PAGE_BAP_SX
640 oris r11,r11,_PAGE_ACCESSED@h
641
642 mfspr r10,SPRN_MAS1
643 cmpldi cr0,r15,8
644 rlwinm r10,r10,0,16,1
645 mtspr SPRN_MAS1,r10
646 beq+ normal_tlb_miss
647
648
649 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
650 TLB_MISS_EPILOG_ERROR
651 b exc_instruction_storage_book3e
652
653
654
655
656
657
658
659
660
661
662
663
664
665 normal_tlb_miss:
666
667
668
669
670
671
672
673
674 ori r10,r15,0x1
675 rldicl r14,r16,64-(PAGE_SHIFT-3),PAGE_SHIFT-3+4
676 sldi r15,r10,60
677 clrrdi r14,r14,3
678 or r10,r15,r14
679
680 BEGIN_MMU_FTR_SECTION
681
682
683
684 PPC_TLBSRX_DOT(0,R16)
685 ld r14,0(r10)
686 beq normal_tlb_miss_done
687 MMU_FTR_SECTION_ELSE
688 ld r14,0(r10)
689 ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_USE_TLBRSRV)
690
691 finish_normal_tlb_miss:
692
693 andc. r15,r11,r14
694 bne- normal_tlb_miss_access_fault
695
696
697
698
699
700
701
702
703
704
705
706
707
708 clrrdi r11,r16,12
709 rlwimi r11,r14,32-19,27,31
710 mtspr SPRN_MAS2,r11
711
712
713 rldicl r11,r14,64-8,64-8
714 cmpldi cr0,r11,BOOK3E_PAGESZ_4K
715 beq- 1f
716 mfspr r11,SPRN_MAS1
717 rlwimi r11,r14,31,21,24
718 rlwinm r11,r11,0,21,19
719 mtspr SPRN_MAS1,r11
720 1:
721
722 rldicr r11,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
723 clrldi r15,r11,12
724 rlwimi r15,r14,32-8,22,25
725 rlwimi r15,r14,32-2,26,31
726
727
728 andi. r11,r14,_PAGE_DIRTY
729 bne 1f
730 li r11,MAS3_SW|MAS3_UW
731 andc r15,r15,r11
732 1:
733 BEGIN_MMU_FTR_SECTION
734 srdi r16,r15,32
735 mtspr SPRN_MAS3,r15
736 mtspr SPRN_MAS7,r16
737 MMU_FTR_SECTION_ELSE
738 mtspr SPRN_MAS7_MAS3,r15
739 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
740
741 tlbwe
742
743 normal_tlb_miss_done:
744
745
746
747
748 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_NORM_OK)
749 TLB_MISS_EPILOG_SUCCESS
750 rfi
751
752 normal_tlb_miss_access_fault:
753
754 andi. r10,r11,_PAGE_EXEC
755 bne 1f
756 ld r14,EX_TLB_DEAR(r12)
757 ld r15,EX_TLB_ESR(r12)
758 mtspr SPRN_DEAR,r14
759 mtspr SPRN_ESR,r15
760 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
761 TLB_MISS_EPILOG_ERROR
762 b exc_data_storage_book3e
763 1: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
764 TLB_MISS_EPILOG_ERROR
765 b exc_instruction_storage_book3e
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792 virt_page_table_tlb_miss:
793
794 andi. r10,r15,0x8
795
796
797
798
799
800 add r11,r10,r13
801
802
803 beq 1f
804
805 mfspr r10,SPRN_MAS1
806 rlwinm r10,r10,0,16,1
807 mtspr SPRN_MAS1,r10
808 1:
809 BEGIN_MMU_FTR_SECTION
810
811
812
813 PPC_TLBSRX_DOT(0,R16)
814 beq virt_page_table_tlb_miss_done
815 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV)
816
817
818
819
820 rldicl. r10,r16,64-(VPTE_INDEX_SIZE+3),VPTE_INDEX_SIZE+3+4
821 bne- virt_page_table_tlb_miss_fault
822
823
824 ld r15,PACAPGD(r11)
825 cmpldi cr0,r15,0
826 beq- virt_page_table_tlb_miss_fault
827
828
829 rldicl r11,r16,64-VPTE_PGD_SHIFT,64-PGD_INDEX_SIZE-3
830 clrrdi r10,r11,3
831 ldx r15,r10,r15
832 cmpdi cr0,r15,0
833 bge virt_page_table_tlb_miss_fault
834
835
836 rldicl r11,r16,64-VPTE_PUD_SHIFT,64-PUD_INDEX_SIZE-3
837 clrrdi r10,r11,3
838 ldx r15,r10,r15
839 cmpdi cr0,r15,0
840 bge virt_page_table_tlb_miss_fault
841
842
843 rldicl r11,r16,64-VPTE_PMD_SHIFT,64-PMD_INDEX_SIZE-3
844 clrrdi r10,r11,3
845 ldx r15,r10,r15
846 cmpdi cr0,r15,0
847 bge virt_page_table_tlb_miss_fault
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863 clrldi r11,r15,4
864 ori r10,r11,1
865
866 BEGIN_MMU_FTR_SECTION
867 srdi r16,r10,32
868 mtspr SPRN_MAS3,r10
869 mtspr SPRN_MAS7,r16
870 MMU_FTR_SECTION_ELSE
871 mtspr SPRN_MAS7_MAS3,r10
872 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
873
874 tlbwe
875
876 BEGIN_MMU_FTR_SECTION
877 virt_page_table_tlb_miss_done:
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893 subf r10,r13,r12
894 cmpldi cr0,r10,PACA_EXTLB+EX_TLB_SIZE
895 bne- 1f
896 ld r11,PACA_EXTLB+EX_TLB_SIZE+EX_TLB_SRR0(r13)
897 addi r10,r11,-4
898 std r10,PACA_EXTLB+EX_TLB_SIZE+EX_TLB_SRR0(r13)
899 1:
900 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV)
901
902 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_OK);
903 TLB_MISS_EPILOG_SUCCESS
904 rfi
905
906 virt_page_table_tlb_miss_fault:
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925 subf r10,r13,r12
926 cmpldi cr0,r10,PACA_EXTLB+EX_TLB_SIZE
927 bne- virt_page_table_tlb_miss_whacko_fault
928
929
930 ld r15,EX_TLB_DEAR+PACA_EXTLB(r13)
931 ld r16,EX_TLB_ESR+PACA_EXTLB(r13)
932
933
934 cmpdi cr0,r16,-1
935 beq 1f
936 mtspr SPRN_DEAR,r15
937 mtspr SPRN_ESR,r16
938 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_PT_FAULT);
939 TLB_MISS_EPILOG_ERROR
940 b exc_data_storage_book3e
941 1: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_PT_FAULT);
942 TLB_MISS_EPILOG_ERROR
943 b exc_instruction_storage_book3e
944
945 virt_page_table_tlb_miss_whacko_fault:
946
947
948
949 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_FAULT);
950 TLB_MISS_EPILOG_ERROR
951 b exc_data_storage_book3e
952
953
954
955
956
957
958
959
960
961
962 START_EXCEPTION(data_tlb_miss_htw)
963 TLB_MISS_PROLOG
964
965
966
967
968
969
970 mfspr r14,SPRN_ESR
971 mfspr r16,SPRN_DEAR
972 srdi r11,r16,60
973 cmpldi cr0,r11,0xc
974 TLB_MISS_STATS_SAVE_INFO
975 beq tlb_load_linear
976
977
978
979 cmpldi cr0,r11,0
980 ld r15,PACAPGD(r13)
981 beq htw_tlb_miss
982
983
984 1: mfspr r10,SPRN_MAS1
985 cmpldi cr0,r11,8
986 rlwinm r10,r10,0,16,1
987 mtspr SPRN_MAS1,r10
988 ld r15,PACA_KERNELPGD(r13)
989 beq+ htw_tlb_miss
990
991
992
993
994 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
995 TLB_MISS_EPILOG_ERROR
996 b exc_data_storage_book3e
997
998
999 START_EXCEPTION(instruction_tlb_miss_htw)
1000 TLB_MISS_PROLOG
1001
1002
1003
1004
1005
1006
1007 li r14,-1
1008
1009
1010
1011
1012
1013
1014
1015
1016 srdi r11,r16,60
1017 cmpldi cr0,r11,0xc
1018 TLB_MISS_STATS_SAVE_INFO
1019 beq tlb_load_linear
1020
1021
1022
1023 cmpldi cr0,r11,0
1024 ld r15,PACAPGD(r13)
1025 beq htw_tlb_miss
1026
1027
1028 1: mfspr r10,SPRN_MAS1
1029 cmpldi cr0,r11,8
1030 rlwinm r10,r10,0,16,1
1031 mtspr SPRN_MAS1,r10
1032 ld r15,PACA_KERNELPGD(r13)
1033 beq+ htw_tlb_miss
1034
1035
1036 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
1037 TLB_MISS_EPILOG_ERROR
1038 b exc_instruction_storage_book3e
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056 htw_tlb_miss:
1057
1058
1059
1060
1061
1062 PPC_TLBSRX_DOT(0,R16)
1063 beq htw_tlb_miss_done
1064
1065
1066
1067
1068 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
1069 bne- htw_tlb_miss_fault
1070
1071
1072 cmpldi cr0,r15,0
1073 beq- htw_tlb_miss_fault
1074
1075
1076 rldicl r11,r16,64-(PGDIR_SHIFT-3),64-PGD_INDEX_SIZE-3
1077 clrrdi r10,r11,3
1078 ldx r15,r10,r15
1079 cmpdi cr0,r15,0
1080 bge htw_tlb_miss_fault
1081
1082
1083 rldicl r11,r16,64-(PUD_SHIFT-3),64-PUD_INDEX_SIZE-3
1084 clrrdi r10,r11,3
1085 ldx r15,r10,r15
1086 cmpdi cr0,r15,0
1087 bge htw_tlb_miss_fault
1088
1089
1090 rldicl r11,r16,64-(PMD_SHIFT-3),64-PMD_INDEX_SIZE-3
1091 clrrdi r10,r11,3
1092 ldx r15,r10,r15
1093 cmpdi cr0,r15,0
1094 bge htw_tlb_miss_fault
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106 rlwimi r15,r16,32-9,20,20
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116 ori r10,r15,(BOOK3E_PAGESZ_4K << MAS3_SPSIZE_SHIFT)
1117
1118 BEGIN_MMU_FTR_SECTION
1119 srdi r16,r10,32
1120 mtspr SPRN_MAS3,r10
1121 mtspr SPRN_MAS7,r16
1122 MMU_FTR_SECTION_ELSE
1123 mtspr SPRN_MAS7_MAS3,r10
1124 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
1125
1126 tlbwe
1127
1128 htw_tlb_miss_done:
1129
1130
1131
1132
1133 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_OK)
1134 TLB_MISS_EPILOG_SUCCESS
1135 rfi
1136
1137 htw_tlb_miss_fault:
1138
1139
1140
1141 cmpdi cr0,r14,-1
1142 beq 1f
1143 mtspr SPRN_DEAR,r16
1144 mtspr SPRN_ESR,r14
1145 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_PT_FAULT)
1146 TLB_MISS_EPILOG_ERROR
1147 b exc_data_storage_book3e
1148 1: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_PT_FAULT)
1149 TLB_MISS_EPILOG_ERROR
1150 b exc_instruction_storage_book3e
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176 tlb_load_linear:
1177
1178
1179
1180
1181
1182 ld r11,PACATOC(r13)
1183 ld r11,linear_map_top@got(r11)
1184 ld r10,0(r11)
1185 tovirt(10,10)
1186 cmpld cr0,r16,r10
1187 bge tlb_load_linear_fault
1188
1189
1190 li r15,(BOOK3E_PAGESZ_1GB<<MAS1_TSIZE_SHIFT)
1191 oris r15,r15,MAS1_VALID@h
1192 mtspr SPRN_MAS1,r15
1193
1194
1195 PPC_TLBSRX_DOT(0,R16)
1196 beq tlb_load_linear_done
1197
1198
1199
1200
1201
1202
1203
1204 clrrdi r10,r16,30
1205 clrldi r10,r10,4
1206 ori r10,r10,MAS3_SR|MAS3_SW|MAS3_SX
1207
1208 BEGIN_MMU_FTR_SECTION
1209 srdi r16,r10,32
1210 mtspr SPRN_MAS3,r10
1211 mtspr SPRN_MAS7,r16
1212 MMU_FTR_SECTION_ELSE
1213 mtspr SPRN_MAS7_MAS3,r10
1214 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
1215
1216 tlbwe
1217
1218 tlb_load_linear_done:
1219
1220
1221
1222
1223
1224 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_LINEAR)
1225 TLB_MISS_EPILOG_ERROR
1226 rfi
1227
1228 tlb_load_linear_fault:
1229
1230 cmpdi cr0,r14,-1
1231 beq 1f
1232 TLB_MISS_EPILOG_ERROR_SPECIAL
1233 b exc_data_storage_book3e
1234 1: TLB_MISS_EPILOG_ERROR_SPECIAL
1235 b exc_instruction_storage_book3e
1236
1237
1238 #ifdef CONFIG_BOOK3E_MMU_TLB_STATS
1239 .tlb_stat_inc:
1240 1: ldarx r8,0,r9
1241 addi r8,r8,1
1242 stdcx. r8,0,r9
1243 bne- 1b
1244 blr
1245 #endif