···9191 * (the "original") TLB miss, which may either be caused by an instruction9292 * fetch or a data access (or non-access).9393 *9494- * What we do here is normal TLB miss handing for the _original_ miss, followed9595- * by inserting the TLB entry for the virtual page table page that the VHPT9696- * walker was attempting to access. The latter gets inserted as long9797- * as both L1 and L2 have valid mappings for the faulting address.9898- * The TLB entry for the original miss gets inserted only if9999- * the L3 entry indicates that the page is present.9494+ * What we do here is normal TLB miss handing for the _original_ miss,9595+ * followed by inserting the TLB entry for the virtual page table page9696+ * that the VHPT walker was attempting to access. The latter gets9797+ * inserted as long as page table entry above pte level have valid9898+ * mappings for the faulting address. The TLB entry for the original9999+ * miss gets inserted only if the pte entry indicates that the page is100100+ * present.100101 *101102 * do_page_fault gets invoked in the following cases:102103 * - the faulting virtual address uses unimplemented address bits103103- * - the faulting virtual address has no L1, L2, or L3 mapping104104+ * - the faulting virtual address has no valid page table mapping104105 */105106 mov r16=cr.ifa // get address that caused the TLB miss106107#ifdef CONFIG_HUGETLB_PAGE···127126#endif128127 ;;129128 cmp.eq p6,p7=5,r17 // is IFA pointing into to region 5?130130- shr.u r18=r22,PGDIR_SHIFT // get bits 33-63 of the faulting address129129+ shr.u r18=r22,PGDIR_SHIFT // get bottom portion of pgd index bit131130 ;;132131(p7) dep r17=r17,r19,(PAGE_SHIFT-3),3 // put region number bits in place133132···138137(p6) shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT139138(p7) shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3140139 ;;141141-(p6) dep r17=r18,r19,3,(PAGE_SHIFT-3) // r17=PTA + IFA(33,42)*8142142-(p7) dep r17=r18,r17,3,(PAGE_SHIFT-6) // r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)140140+(p6) dep r17=r18,r19,3,(PAGE_SHIFT-3) // r17=pgd_offset for region 5141141+(p7) dep r17=r18,r17,3,(PAGE_SHIFT-6) // r17=pgd_offset for region[0-4]143142 cmp.eq p7,p6=0,r21 // unused address bits all zeroes?144143#ifdef CONFIG_PGTABLE_4145145- shr.u r28=r22,PUD_SHIFT // shift L2 index into position144144+ shr.u r28=r22,PUD_SHIFT // shift pud index into position146145#else147147- shr.u r18=r22,PMD_SHIFT // shift L3 index into position146146+ shr.u r18=r22,PMD_SHIFT // shift pmd index into position148147#endif149148 ;;150150- ld8 r17=[r17] // fetch the L1 entry (may be 0)149149+ ld8 r17=[r17] // get *pgd (may be 0)151150 ;;152152-(p7) cmp.eq p6,p7=r17,r0 // was L1 entry NULL?151151+(p7) cmp.eq p6,p7=r17,r0 // was pgd_present(*pgd) == NULL?153152#ifdef CONFIG_PGTABLE_4154154- dep r28=r28,r17,3,(PAGE_SHIFT-3) // compute address of L2 page table entry153153+ dep r28=r28,r17,3,(PAGE_SHIFT-3) // r28=pud_offset(pgd,addr)155154 ;;156156- shr.u r18=r22,PMD_SHIFT // shift L3 index into position157157-(p7) ld8 r29=[r28] // fetch the L2 entry (may be 0)155155+ shr.u r18=r22,PMD_SHIFT // shift pmd index into position156156+(p7) ld8 r29=[r28] // get *pud (may be 0)158157 ;;159159-(p7) cmp.eq.or.andcm p6,p7=r29,r0 // was L2 entry NULL?160160- dep r17=r18,r29,3,(PAGE_SHIFT-3) // compute address of L3 page table entry158158+(p7) cmp.eq.or.andcm p6,p7=r29,r0 // was pud_present(*pud) == NULL?159159+ dep r17=r18,r29,3,(PAGE_SHIFT-3) // r17=pmd_offset(pud,addr)161160#else162162- dep r17=r18,r17,3,(PAGE_SHIFT-3) // compute address of L3 page table entry161161+ dep r17=r18,r17,3,(PAGE_SHIFT-3) // r17=pmd_offset(pgd,addr)163162#endif164163 ;;165165-(p7) ld8 r20=[r17] // fetch the L3 entry (may be 0)166166- shr.u r19=r22,PAGE_SHIFT // shift L4 index into position164164+(p7) ld8 r20=[r17] // get *pmd (may be 0)165165+ shr.u r19=r22,PAGE_SHIFT // shift pte index into position167166 ;;168168-(p7) cmp.eq.or.andcm p6,p7=r20,r0 // was L3 entry NULL?169169- dep r21=r19,r20,3,(PAGE_SHIFT-3) // compute address of L4 page table entry167167+(p7) cmp.eq.or.andcm p6,p7=r20,r0 // was pmd_present(*pmd) == NULL?168168+ dep r21=r19,r20,3,(PAGE_SHIFT-3) // r21=pte_offset(pmd,addr)170169 ;;171171-(p7) ld8 r18=[r21] // read the L4 PTE172172- mov r19=cr.isr // cr.isr bit 0 tells us if this is an insn miss170170+(p7) ld8 r18=[r21] // read *pte171171+ mov r19=cr.isr // cr.isr bit 32 tells us if this is an insn miss173172 ;;174173(p7) tbit.z p6,p7=r18,_PAGE_P_BIT // page present bit cleared?175174 mov r22=cr.iha // get the VHPT address that caused the TLB miss···203202 dv_serialize_data204203205204 /*206206- * Re-check L2 and L3 pagetable. If they changed, we may have received a ptc.g205205+ * Re-check pagetable entry. If they changed, we may have received a ptc.g207206 * between reading the pagetable and the "itc". If so, flush the entry we208208- * inserted and retry.207207+ * inserted and retry. At this point, we have:208208+ *209209+ * r28 = equivalent of pud_offset(pgd, ifa)210210+ * r17 = equivalent of pmd_offset(pud, ifa)211211+ * r21 = equivalent of pte_offset(pmd, ifa)212212+ *213213+ * r29 = *pud214214+ * r20 = *pmd215215+ * r18 = *pte209216 */210210- ld8 r25=[r21] // read L4 entry again211211- ld8 r26=[r17] // read L3 PTE again217217+ ld8 r25=[r21] // read *pte again218218+ ld8 r26=[r17] // read *pmd again212219#ifdef CONFIG_PGTABLE_4213213- ld8 r18=[r28] // read L2 entry again220220+ ld8 r19=[r28] // read *pud again214221#endif215222 cmp.ne p6,p7=r0,r0216223 ;;217217- cmp.ne.or.andcm p6,p7=r26,r20 // did L3 entry change224224+ cmp.ne.or.andcm p6,p7=r26,r20 // did *pmd change218225#ifdef CONFIG_PGTABLE_4219219- cmp.ne.or.andcm p6,p7=r29,r18 // did L4 PTE change226226+ cmp.ne.or.andcm p6,p7=r19,r29 // did *pud change220227#endif221228 mov r27=PAGE_SHIFT<<2222229 ;;223230(p6) ptc.l r22,r27 // purge PTE page translation224224-(p7) cmp.ne.or.andcm p6,p7=r25,r18 // did L4 PTE change231231+(p7) cmp.ne.or.andcm p6,p7=r25,r18 // did *pte change225232 ;;226233(p6) ptc.l r16,r27 // purge translation227234#endif···244235ENTRY(itlb_miss)245236 DBG_FAULT(1)246237 /*247247- * The ITLB handler accesses the L3 PTE via the virtually mapped linear238238+ * The ITLB handler accesses the PTE via the virtually mapped linear248239 * page table. If a nested TLB miss occurs, we switch into physical249249- * mode, walk the page table, and then re-execute the L3 PTE read250250- * and go on normally after that.240240+ * mode, walk the page table, and then re-execute the PTE read and241241+ * go on normally after that.251242 */252243 mov r16=cr.ifa // get virtual address253244 mov r29=b0 // save b0254245 mov r31=pr // save predicates255246.itlb_fault:256256- mov r17=cr.iha // get virtual address of L3 PTE247247+ mov r17=cr.iha // get virtual address of PTE257248 movl r30=1f // load nested fault continuation point258249 ;;259259-1: ld8 r18=[r17] // read L3 PTE250250+1: ld8 r18=[r17] // read *pte260251 ;;261252 mov b0=r29262253 tbit.z p6,p0=r18,_PAGE_P_BIT // page present bit cleared?···271262 */272263 dv_serialize_data273264274274- ld8 r19=[r17] // read L3 PTE again and see if same265265+ ld8 r19=[r17] // read *pte again and see if same275266 mov r20=PAGE_SHIFT<<2 // setup page size for purge276267 ;;277268 cmp.ne p7,p0=r18,r19···288279ENTRY(dtlb_miss)289280 DBG_FAULT(2)290281 /*291291- * The DTLB handler accesses the L3 PTE via the virtually mapped linear282282+ * The DTLB handler accesses the PTE via the virtually mapped linear292283 * page table. If a nested TLB miss occurs, we switch into physical293293- * mode, walk the page table, and then re-execute the L3 PTE read294294- * and go on normally after that.284284+ * mode, walk the page table, and then re-execute the PTE read and285285+ * go on normally after that.295286 */296287 mov r16=cr.ifa // get virtual address297288 mov r29=b0 // save b0298289 mov r31=pr // save predicates299290dtlb_fault:300300- mov r17=cr.iha // get virtual address of L3 PTE291291+ mov r17=cr.iha // get virtual address of PTE301292 movl r30=1f // load nested fault continuation point302293 ;;303303-1: ld8 r18=[r17] // read L3 PTE294294+1: ld8 r18=[r17] // read *pte304295 ;;305296 mov b0=r29306297 tbit.z p6,p0=r18,_PAGE_P_BIT // page present bit cleared?···315306 */316307 dv_serialize_data317308318318- ld8 r19=[r17] // read L3 PTE again and see if same309309+ ld8 r19=[r17] // read *pte again and see if same319310 mov r20=PAGE_SHIFT<<2 // setup page size for purge320311 ;;321312 cmp.ne p7,p0=r18,r19···429420 * r30: continuation address430421 * r31: saved pr431422 *432432- * Output: r17: physical address of L3 PTE of faulting address423423+ * Output: r17: physical address of PTE of faulting address433424 * r29: saved b0434425 * r30: continuation address435426 * r31: saved pr···459450(p6) shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT460451(p7) shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3461452 ;;462462-(p6) dep r17=r18,r19,3,(PAGE_SHIFT-3) // r17=PTA + IFA(33,42)*8463463-(p7) dep r17=r18,r17,3,(PAGE_SHIFT-6) // r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)453453+(p6) dep r17=r18,r19,3,(PAGE_SHIFT-3) // r17=pgd_offset for region 5454454+(p7) dep r17=r18,r17,3,(PAGE_SHIFT-6) // r17=pgd_offset for region[0-4]464455 cmp.eq p7,p6=0,r21 // unused address bits all zeroes?465456#ifdef CONFIG_PGTABLE_4466466- shr.u r18=r22,PUD_SHIFT // shift L2 index into position457457+ shr.u r18=r22,PUD_SHIFT // shift pud index into position467458#else468468- shr.u r18=r22,PMD_SHIFT // shift L3 index into position459459+ shr.u r18=r22,PMD_SHIFT // shift pmd index into position469460#endif470461 ;;471471- ld8 r17=[r17] // fetch the L1 entry (may be 0)462462+ ld8 r17=[r17] // get *pgd (may be 0)472463 ;;473473-(p7) cmp.eq p6,p7=r17,r0 // was L1 entry NULL?474474- dep r17=r18,r17,3,(PAGE_SHIFT-3) // compute address of L2 page table entry464464+(p7) cmp.eq p6,p7=r17,r0 // was pgd_present(*pgd) == NULL?465465+ dep r17=r18,r17,3,(PAGE_SHIFT-3) // r17=p[u|m]d_offset(pgd,addr)475466 ;;476467#ifdef CONFIG_PGTABLE_4477477-(p7) ld8 r17=[r17] // fetch the L2 entry (may be 0)478478- shr.u r18=r22,PMD_SHIFT // shift L3 index into position468468+(p7) ld8 r17=[r17] // get *pud (may be 0)469469+ shr.u r18=r22,PMD_SHIFT // shift pmd index into position479470 ;;480480-(p7) cmp.eq.or.andcm p6,p7=r17,r0 // was L2 entry NULL?481481- dep r17=r18,r17,3,(PAGE_SHIFT-3) // compute address of L2 page table entry471471+(p7) cmp.eq.or.andcm p6,p7=r17,r0 // was pud_present(*pud) == NULL?472472+ dep r17=r18,r17,3,(PAGE_SHIFT-3) // r17=pmd_offset(pud,addr)482473 ;;483474#endif484484-(p7) ld8 r17=[r17] // fetch the L3 entry (may be 0)485485- shr.u r19=r22,PAGE_SHIFT // shift L4 index into position475475+(p7) ld8 r17=[r17] // get *pmd (may be 0)476476+ shr.u r19=r22,PAGE_SHIFT // shift pte index into position486477 ;;487487-(p7) cmp.eq.or.andcm p6,p7=r17,r0 // was L3 entry NULL?488488- dep r17=r19,r17,3,(PAGE_SHIFT-3) // compute address of L4 page table entry478478+(p7) cmp.eq.or.andcm p6,p7=r17,r0 // was pmd_present(*pmd) == NULL?479479+ dep r17=r19,r17,3,(PAGE_SHIFT-3) // r17=pte_offset(pmd,addr);489480(p6) br.cond.spnt page_fault490481 mov b0=r30491482 br.sptk.many b0 // return to continuation point