/* Data TLB miss */
START_EXCEPTION(data_tlb_miss_bolted)
tlb_prolog_bolted BOOKE_INTERRUPT_DTLB_MISS SPRN_DEAR
/* We need _PAGE_PRESENT and _PAGE_ACCESSED set */
/* We do the user/kernel test for the PID here along with the RW test
*/ /* We pre-test some combination of permissions to avoid double *faults: * *WemovetheESR:STbitintothepositionof_PAGE_BAP_SWinthePTE *ESR_STis0x00800000 *_PAGE_BAP_SWis0x00000010 *Sotheshiftis>>19.Thistestsforsupervisorwriteability. *Ifthepagehappenstobesupervisorwriteableandnotuser *writeable,wewilltakeanewfaultlater,butthatshouldbe *arareenoughcase. * *WealsomoveESR_STin_PAGE_DIRTYposition *_PAGE_DIRTYis0x00001000sotheshiftis>>11 * *MAS1ispresetforallweneedexceptforTIDthatneedsto *beclearedforkerneltranslations
*/
mfspr r11,SPRN_ESR
srdi r15,r16,60/* get region */
rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
bne- dtlb_miss_fault_bolted /* Bail if fault addr is invalid */
rlwinm r10,r11,32-19,27,27
rlwimi r10,r11,32-16,19,19
cmpwi r15,0/* user vs kernel check */
ori r10,r10,_PAGE_PRESENT
oris r11,r10,_PAGE_ACCESSED@h
/* Check if required permissions are met */
andc. r15,r11,r14
rldicr r15,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
bne- tlb_miss_fault_bolted
/* Now we build the MAS: * *MAS0:FullysetupwithdefaultsinMAS4andTLBnCFG *MAS1:Almostfullysetup *-PIDalreadyupdatedbycallerifnecessary *-TSIZEneedchangeif!base page size, not *yetimplementedfornow *MAS2:Defaultsnotuseful,needtoberedone *MAS3+7:Needstobedone
*/
clrrdi r11,r16,12/* Clear low crap in EA */
clrldi r15,r15,12/* Clear crap at the top */
rlwimi r11,r14,32-19,27,31/* Insert WIMGE */
rlwimi r15,r14,32-8,22,25/* Move in U bits */
mtspr SPRN_MAS2,r11
andi. r11,r14,_PAGE_DIRTY
rlwimi r15,r14,32-2,26,31/* Move in BAP bits */
/* Mask out SW and UW if !DIRTY (XXX optimize this !) */
bne 1f
li r11,MAS3_SW|MAS3_UW
andc r15,r15,r11 1:
mtspr SPRN_MAS7_MAS3,r15
tlbwe
tlb_miss_done_bolted:
tlb_epilog_bolted
rfi
itlb_miss_kernel_bolted:
li r11,_PAGE_PRESENT|_PAGE_BAP_SX /* Base perm */
oris r11,r11,_PAGE_ACCESSED@h
tlb_miss_kernel_bolted:
mfspr r10,SPRN_MAS1 ld r14,PACA_KERNELPGD(r13)
srdi r15,r16,44/* get kernel region */
andi. r15,r15,1/* Check for vmalloc region */
rlwinm r10,r10,0,16,1/* Clear TID */
mtspr SPRN_MAS1,r10
bne+ tlb_miss_common_bolted
tlb_miss_fault_bolted: /* We need to check if it was an instruction miss */
andi. r10,r11,_PAGE_BAP_UX|_PAGE_BAP_SX
bne itlb_miss_fault_bolted
dtlb_miss_fault_bolted:
tlb_epilog_bolted
b exc_data_storage_book3e
itlb_miss_fault_bolted:
tlb_epilog_bolted
b exc_instruction_storage_book3e
/* Instruction TLB miss */
START_EXCEPTION(instruction_tlb_miss_bolted)
tlb_prolog_bolted BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR0
rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
srdi r15,r16,60/* get region */
bne- itlb_miss_fault_bolted
li r11,_PAGE_PRESENT|_PAGE_BAP_UX /* Base perm */
/* We do the user/kernel test for the PID here along with the RW test
*/
cmpldi cr0,r15,0/* Check for user region */
oris r11,r11,_PAGE_ACCESSED@h
beq tlb_miss_user_bolted
b itlb_miss_kernel_bolted
/* Now, we need to walk the page tables. First check if we are in *range.
*/
rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
bne- tlb_miss_fault_e6500
/* Now we build the MAS for a 2M indirect page: * *MAS0:ESELneedstobefilledbysoftwareround-robin *MAS1:Fullysetup *-PIDalreadyupdatedbycallerifnecessary *-TSIZEfornowisbaseindpagesizealways *-TIDalreadyclearedifnecessary *MAS2:Defaultnot2M-aligned,needtoberedone *MAS3+7:Needstobedone
*/
ori r14,r14,(BOOK3E_PAGESZ_4K << MAS3_SPSIZE_SHIFT)
mtspr SPRN_MAS7_MAS3,r14
clrrdi r15,r16,21/* make EA 2M-aligned */
mtspr SPRN_MAS2,r15
tlb_miss_huge_done_e6500:
lbz r16,TCD_ESEL_MAX(r11)
lbz r14,TCD_ESEL_FIRST(r11)
rlwimi r10,r7,16,0x00ff0000 /* insert esel_next into MAS0 */
addi r7,r7,1/* increment esel_next */
mtspr SPRN_MAS0,r10
cmpw r7,r16
iseleq r7,r14,r7 /* if next == last use first */
stb r7,TCD_ESEL_NEXT(r11)
tlbwe
tlb_miss_done_e6500:
.macro tlb_unlock_e6500
BEGIN_FTR_SECTION
beq cr1,1f /* no unlock if lock was recursively grabbed */
li r15,0
isync
stb r15,0(r11) 1:
END_FTR_SECTION_IFSET(CPU_FTR_SMT)
.endm
li r10,-0x400
sld r15,r10,r15 /* Generate mask based on size */
and r10,r16,r15
rldicr r15,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
rlwimi r10,r14,32-19,27,31/* Insert WIMGE */
clrldi r15,r15,PAGE_SHIFT /* Clear crap at the top */
rlwimi r15,r14,32-8,22,25/* Move in U bits */
mtspr SPRN_MAS2,r10
andi. r10,r14,_PAGE_DIRTY
rlwimi r15,r14,32-2,26,31/* Move in BAP bits */
/* Mask out SW and UW if !DIRTY (XXX optimize this !) */
bne 1f
li r10,MAS3_SW|MAS3_UW
andc r15,r15,r10 1:
mtspr SPRN_MAS7_MAS3,r15
mfspr r10,SPRN_MAS0
b tlb_miss_huge_done_e6500
tlb_miss_kernel_e6500: ld r14,PACA_KERNELPGD(r13)
srdi r15,r16,44/* get kernel region */
xoris r15,r15,0xc /* Check for vmalloc region */
cmplwi cr1,r15,1
beq+ cr1,tlb_miss_common_e6500
tlb_miss_fault_e6500:
tlb_unlock_e6500 /* We need to check if it was an instruction miss */
andi. r16,r16,1
bne itlb_miss_fault_e6500
dtlb_miss_fault_e6500:
tlb_epilog_bolted
b exc_data_storage_book3e
itlb_miss_fault_e6500:
tlb_epilog_bolted
b exc_instruction_storage_book3e
/* The cool thing now is that r10 contains 0 for user and 8 for kernel, *andwehappentohavetheswapper_pg_diratoffset8fromtheuser *pgdirinthePACA:-).
*/
add r11,r10,r13
/* If kernel, we need to clear MAS1 TID */
beq 1f /* XXX replace the RMW cycles with immediate loads + writes */
mfspr r10,SPRN_MAS1
rlwinm r10,r10,0,16,1/* Clear TID */
mtspr SPRN_MAS1,r10
#ifdef CONFIG_PPC_KUAP
b 2f 1:
mfspr r10,SPRN_MAS1
rlwinm. r10,r10,0,0x3fff0000
beq- virt_page_table_tlb_miss_fault /* KUAP fault */ 2:
#else 1:
#endif
/* Now, we need to walk the page tables. First check if we are in *range.
*/
rldicl r10,r16,64-(VPTE_INDEX_SIZE+3),VPTE_INDEX_SIZE+3+4
cmpldi r10,0x80
bne- virt_page_table_tlb_miss_fault
/* Get the PGD pointer */ ld r15,PACAPGD(r11)
cmpldi cr0,r15,0
beq- virt_page_table_tlb_miss_fault
/* Get to PGD entry */
rldicl r11,r16,64-VPTE_PGD_SHIFT,64-PGD_INDEX_SIZE-3
clrrdi r10,r11,3 ldx r15,r10,r15
cmpdi cr0,r15,0
bge virt_page_table_tlb_miss_fault
/* Get to PUD entry */
rldicl r11,r16,64-VPTE_PUD_SHIFT,64-PUD_INDEX_SIZE-3
clrrdi r10,r11,3 ldx r15,r10,r15
cmpdi cr0,r15,0
bge virt_page_table_tlb_miss_fault
/* Get to PMD entry */
rldicl r11,r16,64-VPTE_PMD_SHIFT,64-PMD_INDEX_SIZE-3
clrrdi r10,r11,3 ldx r15,r10,r15
cmpdi cr0,r15,0
bge virt_page_table_tlb_miss_fault
/* Ok, we're all right, we can now create a kernel translation for *a4Kor64Kpagefromr16->r15.
*/ /* Now we build the MAS: * *MAS0:FullysetupwithdefaultsinMAS4andTLBnCFG *MAS1:Almostfullysetup *-PIDalreadyupdatedbycallerifnecessary *-TSIZEfornowisbasepagesizealways *MAS2:Usedefaults *MAS3+7:Needstobedone * *SoweonlydoMAS2and3fornow...
*/
clrldi r11,r15,4/* remove region ID from RPN */
ori r10,r11,1/* Or-in SR */
/* Return to caller, normal case */
TLB_MISS_EPILOG_SUCCESS
rfi
virt_page_table_tlb_miss_fault: /* If we fault here, things are a little bit tricky. We need to call *eitherdataorinstructionstorefault,andweneedtoretrieve *theoriginalfaultaddressandESR(fordata). * *Thethingis,weknowthatinnormalcircumstances,thisis *alwayscalledasasecondleveltlbmissforSWloadorasafirst *levelTLBmissforHWload,soweshouldbeabletopeekatthe *relevantinformationinthefirstexceptionframeinthePACA. * *However,wedoneedtodoublecheckthat,becausewemayjusthit *astraykernelpointerorauserlandattacktryingtohitthose *areas.Ifthatisthecase,wedoadatafault.(Wecan'tgethere *fromaninstructiontlbmissanyway). * *Notealsothatwhengoingtoafault,wemustunwindtheprevious *levelaswell.Sincewearedoingthat,wedon'tneedtoclearor *restoretheTLBreservationneither.
*/
subf r10,r13,r12
cmpldi cr0,r10,PACA_EXTLB+EX_TLB_SIZE
bne- virt_page_table_tlb_miss_whacko_fault
/* We dig the original DEAR and ESR from slot 0 */ ld r15,EX_TLB_DEAR+PACA_EXTLB(r13) ld r16,EX_TLB_ESR+PACA_EXTLB(r13)
/* We check for the "special" ESR value for instruction faults */
cmpdi cr0,r16,-1
beq 1f
mtspr SPRN_DEAR,r15
mtspr SPRN_ESR,r16
TLB_MISS_EPILOG_ERROR
b exc_data_storage_book3e 1: TLB_MISS_EPILOG_ERROR
b exc_instruction_storage_book3e
virt_page_table_tlb_miss_whacko_fault: /* The linear fault will restart everything so ESR and DEAR will *nothavebeenclobbered,let'sjustfaultwithwhatwehave
*/
TLB_MISS_EPILOG_ERROR
b exc_data_storage_book3e
/* *Thisisthegutsof"any"levelTLBmisshandlerforkernellinear *mappingmisses.Weareenteredwith: * * *r16=faultingaddress *r15=crap(freetouse) *r14=ESR(data)or-1(instruction) *r13=PACA *r12=TLBexceptionframeinPACA *r11=crap(freetouse) *r10=crap(freetouse) * *Inadditionweknowthatwewillnotre-enter,sointheory,wecould *useasimplerepilognotrestoringSRR0/1etc..butwe'lldothatlater. * *WealsoneedtobecarefulaboutMASregistershere&TLBreservation, *asweknowwe'llhaveclobberedthemifweinterruptthemainTLBmiss *handlersinwhichcaseweprobablywanttodoafullrestartatlevel *0ratherthansaving/restoringtheMAS. * *Note:Ifwecareaboutperformanceofthatcore,wecaneasilyshuffle *afewthingsaround
*/
tlb_load_linear: /* For now, we assume the linear mapping is contiguous and stops at *linear_map_top.Wealsoassumethesizeisamultipleof1G,thus *weonlyuse1Gpagesfornow.Thatmighthavetobechangedina *finalimplementation,especiallywhendealingwithhypervisors
*/
__LOAD_PACA_TOC(r11)
LOAD_REG_ADDR_ALTTOC(r11, r11, linear_map_top) ld r10,0(r11)
tovirt(10,10)
cmpld cr0,r16,r10
bge tlb_load_linear_fault
/* MAS1 need whole new setup. */
li r15,(BOOK3E_PAGESZ_1GB<<MAS1_TSIZE_SHIFT)
oris r15,r15,MAS1_VALID@h /* MAS1 needs V and TSIZE */
mtspr SPRN_MAS1,r15
/* Already somebody there ? */
PPC_TLBSRX_DOT(0,R16)
beq tlb_load_linear_done
/* Now we build the remaining MAS. MAS0 and 2 should be fine *withtheirdefaults,whichleavesuswithMAS3and7.The *mappingislinear,sowejusttaketheaddress,clearthe *regionbits,andorinthepermissionbitswhicharecurrently *hardwired
*/
clrrdi r10,r16,30/* 1G page index */
clrldi r10,r10,4/* clear region bits */
ori r10,r10,MAS3_SR|MAS3_SW|MAS3_SX
tlb_load_linear_done: /* We use the "error" epilog for success as we do want to *restoretotheinitialfaultingcontext,whateveritwas. *Wedothatbecausewecan'tresumeafaultwithinaTLB *misshandler,duetoMASandTLBreservationbeingclobbered.
*/
TLB_MISS_EPILOG_ERROR
rfi
tlb_load_linear_fault: /* We keep the DEAR and ESR around, this shouldn't have happened */
cmpdi cr0,r14,-1
beq 1f
TLB_MISS_EPILOG_ERROR_SPECIAL
b exc_data_storage_book3e 1: TLB_MISS_EPILOG_ERROR_SPECIAL
b exc_instruction_storage_book3e
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.