Changes in kernel/generic/src/mm/page.c [8cbf1c3:346b12a2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
r8cbf1c3 r346b12a2 137 137 /** Find mapping for virtual page. 138 138 * 139 * @param as Address space to which page belongs.140 * @param page Virtual page.141 * @param nolock True if the page tables need not be locked.142 * 143 * @return NULL if there is no such mapping; requested mapping144 * 145 * 146 */ 147 NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page, bool nolock)139 * @param as Address space to which page belongs. 140 * @param page Virtual page. 141 * @param nolock True if the page tables need not be locked. 142 * @param[out] pte Structure that will receive a copy of the found PTE. 143 * 144 * @return True if the mapping was found, false otherwise. 145 */ 146 NO_TRACE bool page_mapping_find(as_t *as, uintptr_t page, bool nolock, 147 pte_t *pte) 148 148 { 149 149 ASSERT(nolock || page_table_locked(as)); … … 153 153 154 154 return page_mapping_operations->mapping_find(as, 155 ALIGN_DOWN(page, PAGE_SIZE), nolock); 155 ALIGN_DOWN(page, PAGE_SIZE), nolock, pte); 156 } 157 158 /** Update mapping for virtual page. 159 * 160 * Use only to update accessed and modified/dirty bits. 161 * 162 * @param as Address space to which page belongs. 163 * @param page Virtual page. 164 * @param nolock True if the page tables need not be locked. 165 * @param pte New PTE. 166 */ 167 NO_TRACE void page_mapping_update(as_t *as, uintptr_t page, bool nolock, 168 pte_t *pte) 169 { 170 ASSERT(nolock || page_table_locked(as)); 171 172 ASSERT(page_mapping_operations); 173 ASSERT(page_mapping_operations->mapping_find); 174 175 page_mapping_operations->mapping_update(as, 176 ALIGN_DOWN(page, PAGE_SIZE), nolock, pte); 156 177 } 157 178 … … 173 194 page_table_lock(AS, true); 174 195 175 pte_t *pte = page_mapping_find(AS, virt, false); 176 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 196 pte_t pte; 197 bool found = page_mapping_find(AS, virt, false, &pte); 198 if (!found || !PTE_VALID(&pte) || !PTE_PRESENT(&pte)) { 177 199 page_table_unlock(AS, true); 178 200 return ENOENT; 179 201 } 180 202 181 *phys = PTE_GET_FRAME( pte) +203 *phys = PTE_GET_FRAME(&pte) + 182 204 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 183 205
Note:
See TracChangeset
for help on using the changeset viewer.