Changes in kernel/arch/ppc32/src/mm/pht.c [1dbc43f:1cab9972] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ppc32/src/mm/pht.c
r1dbc43f r1cab9972 49 49 * @param access Access mode that caused the fault. 50 50 * @param istate Pointer to interrupted state. 51 * @param pfrc Pointer to variable where as_page_fault() return code 52 * will be stored. 51 53 * 52 54 * @return PTE on success, NULL otherwise. … … 54 56 */ 55 57 static pte_t *find_mapping_and_check(as_t *as, uintptr_t badvaddr, int access, 56 istate_t *istate )58 istate_t *istate, int *pfrc) 57 59 { 58 60 /* … … 66 68 */ 67 69 return pte; 68 } 69 /* 70 * Mapping not found in page tables. 71 * Resort to higher-level page fault handler. 72 */ 73 if (as_page_fault(badvaddr, access, istate) == AS_PF_OK) { 70 } else { 74 71 /* 75 * The higher-level page fault handler succeeded,76 * The mapping ought to be in place.72 * Mapping not found in page tables. 73 * Resort to higher-level page fault handler. 77 74 */ 78 pte = page_mapping_find(as, badvaddr, true); 79 ASSERT((pte) && (pte->present)); 80 return pte; 81 } 82 83 return NULL; 75 int rc = as_page_fault(badvaddr, access, istate); 76 switch (rc) { 77 case AS_PF_OK: 78 /* 79 * The higher-level page fault handler succeeded, 80 * The mapping ought to be in place. 81 */ 82 pte = page_mapping_find(as, badvaddr, true); 83 ASSERT((pte) && (pte->present)); 84 *pfrc = 0; 85 return pte; 86 case AS_PF_DEFER: 87 *pfrc = rc; 88 return NULL; 89 case AS_PF_FAULT: 90 *pfrc = rc; 91 return NULL; 92 default: 93 panic("Unexpected rc (%d).", rc); 94 } 95 } 96 } 97 98 static void pht_refill_fail(uintptr_t badvaddr, istate_t *istate) 99 { 100 fault_if_from_uspace(istate, "PHT Refill Exception on %p.", 101 (void *) badvaddr); 102 panic_memtrap(istate, PF_ACCESS_UNKNOWN, badvaddr, 103 "PHT Refill Exception."); 84 104 } 85 105 … … 182 202 badvaddr = istate->pc; 183 203 204 int pfrc; 184 205 pte_t *pte = find_mapping_and_check(AS, badvaddr, 185 PF_ACCESS_READ /* FIXME */, istate); 186 187 if (pte) { 188 /* Record access to PTE */ 189 pte->accessed = 1; 190 pht_insert(badvaddr, pte); 191 } 206 PF_ACCESS_READ /* FIXME */, istate, &pfrc); 207 208 if (!pte) { 209 switch (pfrc) { 210 case AS_PF_FAULT: 211 pht_refill_fail(badvaddr, istate); 212 return; 213 case AS_PF_DEFER: 214 /* 215 * The page fault came during copy_from_uspace() 216 * or copy_to_uspace(). 217 */ 218 return; 219 default: 220 panic("Unexpected pfrc (%d).", pfrc); 221 } 222 } 223 224 /* Record access to PTE */ 225 pte->accessed = 1; 226 pht_insert(badvaddr, pte); 192 227 } 193 228
Note:
See TracChangeset
for help on using the changeset viewer.