Changes in kernel/generic/src/mm/backend_elf.c [d56382d:55b77d9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_elf.c
rd56382d r55b77d9 44 44 #include <mm/page.h> 45 45 #include <mm/reserve.h> 46 #include <mm/km.h>47 46 #include <genarch/mm/page_pt.h> 48 47 #include <genarch/mm/page_ht.h> … … 230 229 elf_segment_header_t *entry = area->backend_data.segment; 231 230 btree_node_t *leaf; 232 uintptr_t base; 233 uintptr_t frame; 234 uintptr_t kpage; 235 uintptr_t upage; 236 uintptr_t start_anon; 231 uintptr_t base, frame, page, start_anon; 237 232 size_t i; 238 233 bool dirty = false; … … 254 249 (((void *) elf) + ALIGN_DOWN(entry->p_offset, PAGE_SIZE)); 255 250 256 /* Virtual address of faulting page 257 upage = ALIGN_DOWN(addr, PAGE_SIZE);251 /* Virtual address of faulting page*/ 252 page = ALIGN_DOWN(addr, PAGE_SIZE); 258 253 259 254 /* Virtual address of the end of initialized part of segment */ … … 269 264 mutex_lock(&area->sh_info->lock); 270 265 frame = (uintptr_t) btree_search(&area->sh_info->pagemap, 271 upage - area->base, &leaf);266 page - area->base, &leaf); 272 267 if (!frame) { 273 268 unsigned int i; … … 278 273 279 274 for (i = 0; i < leaf->keys; i++) { 280 if (leaf->key[i] == upage - area->base) {275 if (leaf->key[i] == page - area->base) { 281 276 found = true; 282 277 break; … … 286 281 if (frame || found) { 287 282 frame_reference_add(ADDR2PFN(frame)); 288 page_mapping_insert(AS, upage, frame,283 page_mapping_insert(AS, addr, frame, 289 284 as_area_get_flags(area)); 290 if (!used_space_insert(area, upage, 1))285 if (!used_space_insert(area, page, 1)) 291 286 panic("Cannot insert used space."); 292 287 mutex_unlock(&area->sh_info->lock); … … 299 294 * mapping. 300 295 */ 301 if ( upage >= entry->p_vaddr && upage + PAGE_SIZE <= start_anon) {296 if (page >= entry->p_vaddr && page + PAGE_SIZE <= start_anon) { 302 297 /* 303 298 * Initialized portion of the segment. The memory is backed … … 309 304 */ 310 305 if (entry->p_flags & PF_W) { 311 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);312 memcpy((void *) kpage, (void *) (base + i * PAGE_SIZE),313 PAGE_SIZE);306 frame = (uintptr_t)frame_alloc_noreserve(ONE_FRAME, 0); 307 memcpy((void *) PA2KA(frame), 308 (void *) (base + i * FRAME_SIZE), FRAME_SIZE); 314 309 if (entry->p_flags & PF_X) { 315 smc_coherence_block((void *) kpage, PAGE_SIZE); 310 smc_coherence_block((void *) PA2KA(frame), 311 FRAME_SIZE); 316 312 } 317 km_temporary_page_put(kpage);318 313 dirty = true; 319 314 } else { 320 315 frame = KA2PA(base + i * FRAME_SIZE); 321 316 } 322 } else if ( upage >= start_anon) {317 } else if (page >= start_anon) { 323 318 /* 324 319 * This is the uninitialized portion of the segment. … … 327 322 * and cleared. 328 323 */ 329 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 330 memsetb((void *) kpage, PAGE_SIZE, 0); 331 km_temporary_page_put(kpage); 324 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0); 325 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0); 332 326 dirty = true; 333 327 } else { … … 340 334 * (The segment can be and often is shorter than 1 page). 341 335 */ 342 if ( upage < entry->p_vaddr)343 pad_lo = entry->p_vaddr - upage;336 if (page < entry->p_vaddr) 337 pad_lo = entry->p_vaddr - page; 344 338 else 345 339 pad_lo = 0; 346 340 347 if (start_anon < upage + PAGE_SIZE)348 pad_hi = upage + PAGE_SIZE - start_anon;341 if (start_anon < page + PAGE_SIZE) 342 pad_hi = page + PAGE_SIZE - start_anon; 349 343 else 350 344 pad_hi = 0; 351 345 352 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);353 memcpy((void *) ( kpage+ pad_lo),354 (void *) (base + i * PAGE_SIZE + pad_lo),355 PAGE_SIZE - pad_lo - pad_hi);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); 356 350 if (entry->p_flags & PF_X) { 357 smc_coherence_block((void *) ( kpage+ pad_lo),358 PAGE_SIZE - pad_lo - pad_hi);351 smc_coherence_block((void *) (PA2KA(frame) + pad_lo), 352 FRAME_SIZE - pad_lo - pad_hi); 359 353 } 360 memsetb((void *) kpage, pad_lo, 0);361 memsetb((void *) ( kpage + PAGE_SIZE - pad_hi), pad_hi, 0);362 km_temporary_page_put(kpage);354 memsetb((void *) PA2KA(frame), pad_lo, 0); 355 memsetb((void *) (PA2KA(frame) + FRAME_SIZE - pad_hi), pad_hi, 356 0); 363 357 dirty = true; 364 358 } … … 366 360 if (dirty && area->sh_info) { 367 361 frame_reference_add(ADDR2PFN(frame)); 368 btree_insert(&area->sh_info->pagemap, upage - area->base,362 btree_insert(&area->sh_info->pagemap, page - area->base, 369 363 (void *) frame, leaf); 370 364 } … … 373 367 mutex_unlock(&area->sh_info->lock); 374 368 375 page_mapping_insert(AS, upage, frame, as_area_get_flags(area));376 if (!used_space_insert(area, upage, 1))369 page_mapping_insert(AS, addr, frame, as_area_get_flags(area)); 370 if (!used_space_insert(area, page, 1)) 377 371 panic("Cannot insert used space."); 378 372
Note:
See TracChangeset
for help on using the changeset viewer.