Changeset 00aece0 in mainline for kernel/generic/src/mm/backend_elf.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_elf.c
rbd5f3b7 r00aece0 44 44 #include <mm/page.h> 45 45 #include <mm/reserve.h> 46 #include <mm/km.h> 46 47 #include <genarch/mm/page_pt.h> 47 48 #include <genarch/mm/page_ht.h> … … 229 230 elf_segment_header_t *entry = area->backend_data.segment; 230 231 btree_node_t *leaf; 231 uintptr_t base, frame, page, start_anon; 232 uintptr_t base; 233 uintptr_t frame; 234 uintptr_t kpage; 235 uintptr_t upage; 236 uintptr_t start_anon; 232 237 size_t i; 233 238 bool dirty = false; … … 249 254 (((void *) elf) + ALIGN_DOWN(entry->p_offset, PAGE_SIZE)); 250 255 251 /* Virtual address of faulting page */252 page = ALIGN_DOWN(addr, PAGE_SIZE);256 /* Virtual address of faulting page */ 257 upage = ALIGN_DOWN(addr, PAGE_SIZE); 253 258 254 259 /* Virtual address of the end of initialized part of segment */ … … 264 269 mutex_lock(&area->sh_info->lock); 265 270 frame = (uintptr_t) btree_search(&area->sh_info->pagemap, 266 page - area->base, &leaf);271 upage - area->base, &leaf); 267 272 if (!frame) { 268 273 unsigned int i; … … 273 278 274 279 for (i = 0; i < leaf->keys; i++) { 275 if (leaf->key[i] == page - area->base) {280 if (leaf->key[i] == upage - area->base) { 276 281 found = true; 277 282 break; … … 281 286 if (frame || found) { 282 287 frame_reference_add(ADDR2PFN(frame)); 283 page_mapping_insert(AS, addr, frame,288 page_mapping_insert(AS, upage, frame, 284 289 as_area_get_flags(area)); 285 if (!used_space_insert(area, page, 1))290 if (!used_space_insert(area, upage, 1)) 286 291 panic("Cannot insert used space."); 287 292 mutex_unlock(&area->sh_info->lock); … … 294 299 * mapping. 295 300 */ 296 if ( page >= entry->p_vaddr &&page + PAGE_SIZE <= start_anon) {301 if (upage >= entry->p_vaddr && upage + PAGE_SIZE <= start_anon) { 297 302 /* 298 303 * Initialized portion of the segment. The memory is backed … … 304 309 */ 305 310 if (entry->p_flags & PF_W) { 306 frame = (uintptr_t)frame_alloc_noreserve(ONE_FRAME, 0);307 memcpy((void *) PA2KA(frame),308 (void *) (base + i * FRAME_SIZE), FRAME_SIZE);311 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 312 memcpy((void *) kpage, (void *) (base + i * PAGE_SIZE), 313 PAGE_SIZE); 309 314 if (entry->p_flags & PF_X) { 310 smc_coherence_block((void *) PA2KA(frame), 311 FRAME_SIZE); 315 smc_coherence_block((void *) kpage, PAGE_SIZE); 312 316 } 317 km_temporary_page_put(kpage); 313 318 dirty = true; 314 319 } else { 315 frame = KA2PA(base + i * FRAME_SIZE); 320 pte_t *pte = page_mapping_find(AS_KERNEL, 321 base + i * FRAME_SIZE, true); 322 323 ASSERT(pte); 324 ASSERT(PTE_PRESENT(pte)); 325 326 frame = PTE_GET_FRAME(pte); 316 327 } 317 } else if ( page >= start_anon) {328 } else if (upage >= start_anon) { 318 329 /* 319 330 * This is the uninitialized portion of the segment. … … 322 333 * and cleared. 323 334 */ 324 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0); 325 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0); 335 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 336 memsetb((void *) kpage, PAGE_SIZE, 0); 337 km_temporary_page_put(kpage); 326 338 dirty = true; 327 339 } else { … … 334 346 * (The segment can be and often is shorter than 1 page). 335 347 */ 336 if ( page < entry->p_vaddr)337 pad_lo = entry->p_vaddr - page;348 if (upage < entry->p_vaddr) 349 pad_lo = entry->p_vaddr - upage; 338 350 else 339 351 pad_lo = 0; 340 352 341 if (start_anon < page + PAGE_SIZE)342 pad_hi = page + PAGE_SIZE - start_anon;353 if (start_anon < upage + PAGE_SIZE) 354 pad_hi = upage + PAGE_SIZE - start_anon; 343 355 else 344 356 pad_hi = 0; 345 357 346 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0);347 memcpy((void *) ( PA2KA(frame)+ pad_lo),348 (void *) (base + i * FRAME_SIZE + pad_lo),349 FRAME_SIZE - pad_lo - pad_hi);358 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 359 memcpy((void *) (kpage + pad_lo), 360 (void *) (base + i * PAGE_SIZE + pad_lo), 361 PAGE_SIZE - pad_lo - pad_hi); 350 362 if (entry->p_flags & PF_X) { 351 smc_coherence_block((void *) ( PA2KA(frame)+ pad_lo),352 FRAME_SIZE - pad_lo - pad_hi);363 smc_coherence_block((void *) (kpage + pad_lo), 364 PAGE_SIZE - pad_lo - pad_hi); 353 365 } 354 memsetb((void *) PA2KA(frame), pad_lo, 0);355 memsetb((void *) ( PA2KA(frame) + FRAME_SIZE - pad_hi), pad_hi,356 0);366 memsetb((void *) kpage, pad_lo, 0); 367 memsetb((void *) (kpage + PAGE_SIZE - pad_hi), pad_hi, 0); 368 km_temporary_page_put(kpage); 357 369 dirty = true; 358 370 } … … 360 372 if (dirty && area->sh_info) { 361 373 frame_reference_add(ADDR2PFN(frame)); 362 btree_insert(&area->sh_info->pagemap, page - area->base,374 btree_insert(&area->sh_info->pagemap, upage - area->base, 363 375 (void *) frame, leaf); 364 376 } … … 367 379 mutex_unlock(&area->sh_info->lock); 368 380 369 page_mapping_insert(AS, addr, frame, as_area_get_flags(area));370 if (!used_space_insert(area, page, 1))381 page_mapping_insert(AS, upage, frame, as_area_get_flags(area)); 382 if (!used_space_insert(area, upage, 1)) 371 383 panic("Cannot insert used space."); 372 384
Note:
See TracChangeset
for help on using the changeset viewer.