Changeset a35b458 in mainline for kernel/genarch/src/mm/page_pt.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/mm/page_pt.c
r3061bc1 ra35b458 83 83 84 84 assert(page_table_locked(as)); 85 85 86 86 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 87 87 pte_t *newpt = (pte_t *) … … 100 100 SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page)); 101 101 } 102 102 103 103 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 104 104 105 105 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 106 106 pte_t *newpt = (pte_t *) … … 117 117 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 118 118 } 119 119 120 120 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 121 121 122 122 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 123 123 pte_t *newpt = (pte_t *) … … 134 134 SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page)); 135 135 } 136 136 137 137 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 138 138 139 139 SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); 140 140 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT); … … 165 165 * First, remove the mapping, if it exists. 166 166 */ 167 167 168 168 pte_t *ptl0 = (pte_t *) PA2KA((uintptr_t) as->genarch.page_table); 169 169 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) 170 170 return; 171 171 172 172 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 173 173 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) 174 174 return; 175 175 176 176 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 177 177 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) 178 178 return; 179 179 180 180 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 181 181 182 182 /* 183 183 * Destroy the mapping. … … 189 189 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), PAGE_NOT_PRESENT); 190 190 memsetb(&ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); 191 191 192 192 /* 193 193 * Second, free all empty tables along the way from PTL3 down to PTL0 194 194 * except those needed for sharing the kernel non-identity mappings. 195 195 */ 196 196 197 197 /* Check PTL3 */ 198 198 bool empty = true; 199 199 200 200 unsigned int i; 201 201 for (i = 0; i < PTL3_ENTRIES; i++) { … … 205 205 } 206 206 } 207 207 208 208 if (empty) { 209 209 /* … … 232 232 return; 233 233 } 234 234 235 235 /* Check PTL2, empty is still true */ 236 236 #if (PTL2_ENTRIES != 0) … … 241 241 } 242 242 } 243 243 244 244 if (empty) { 245 245 /* … … 267 267 } 268 268 #endif /* PTL2_ENTRIES != 0 */ 269 269 270 270 /* check PTL1, empty is still true */ 271 271 #if (PTL1_ENTRIES != 0) … … 276 276 } 277 277 } 278 278 279 279 if (empty) { 280 280 /* … … 301 301 302 302 read_barrier(); 303 303 304 304 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 305 305 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) … … 312 312 read_barrier(); 313 313 #endif 314 314 315 315 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 316 316 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) … … 323 323 read_barrier(); 324 324 #endif 325 325 326 326 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 327 327 328 328 return &ptl3[PTL3_INDEX(page)]; 329 329 } … … 400 400 { 401 401 assert(size > 0); 402 402 403 403 uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table); 404 404 uintptr_t ptl0_step = ptl0_step_get(); 405 405 size_t frames; 406 406 407 407 #if (PTL1_ENTRIES != 0) 408 408 frames = PTL1_FRAMES; … … 412 412 frames = PTL3_FRAMES; 413 413 #endif 414 414 415 415 for (uintptr_t addr = ALIGN_DOWN(base, ptl0_step); 416 416 addr - 1 < base + size - 1;
Note:
See TracChangeset
for help on using the changeset viewer.