Changeset d91488d in mainline for kernel/generic/src/mm/backend_elf.c
- Timestamp:
- 2018-11-21T09:16:16Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a91c555f
- Parents:
- 0705fc5
- git-author:
- Jiri Svoboda <jiri@…> (2018-11-20 20:14:06)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-11-21 09:16:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_elf.c
r0705fc5 rd91488d 96 96 } 97 97 98 /** Get page number in the task where the ELF page originates from. 99 * 100 * The ELF page can be shared to a different address than it originated from, 101 * but we need the originating address since that corresponds to the ELF's 102 * virtual addesses. 103 * 104 * @param area Area in which the page resides 105 * @param page Virtual address of the page in @a area 106 * @return Virtual address of the page in the origin address space 107 */ 108 static uintptr_t elf_orig_page(as_area_t *area, uintptr_t page) 109 { 110 return page - area->base + area->backend_data.elf_base; 111 } 112 98 113 bool elf_create(as_area_t *area) 99 114 { … … 152 167 btree_node_t, leaf_link); 153 168 } else { 154 (void) btree_search(&area->sh_info->pagemap, start_anon, &leaf); 155 node = btree_leaf_node_left_neighbour(&area->sh_info->pagemap, 156 leaf); 169 (void) btree_search(&area->used_space, start_anon, &leaf); 170 node = btree_leaf_node_left_neighbour(&area->used_space, leaf); 157 171 if (!node) 158 172 node = leaf; … … 258 272 uintptr_t kpage; 259 273 uintptr_t start_anon; 274 uintptr_t elfpage; 260 275 size_t i; 261 276 bool dirty = false; … … 265 280 assert(IS_ALIGNED(upage, PAGE_SIZE)); 266 281 282 elfpage = elf_orig_page(area, upage); 283 267 284 if (!as_area_check_access(area, access)) 268 285 return AS_PF_FAULT; 269 286 270 if ( upage < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE))287 if (elfpage < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) 271 288 return AS_PF_FAULT; 272 289 273 if ( upage >= entry->p_vaddr + entry->p_memsz)290 if (elfpage >= entry->p_vaddr + entry->p_memsz) 274 291 return AS_PF_FAULT; 275 292 276 i = (upage - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH; 293 i = (elfpage - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> 294 PAGE_WIDTH; 277 295 base = (uintptr_t) 278 296 (((void *) elf) + ALIGN_DOWN(entry->p_offset, PAGE_SIZE)); … … 320 338 * mapping. 321 339 */ 322 if ( upage >= entry->p_vaddr && upage + PAGE_SIZE <= start_anon) {340 if (elfpage >= entry->p_vaddr && elfpage + PAGE_SIZE <= start_anon) { 323 341 /* 324 342 * Initialized portion of the segment. The memory is backed 325 343 * directly by the content of the ELF image. Pages are 326 344 * only copied if the segment is writable so that there 327 * can be more instan tions of the same memory ELF image345 * can be more instances of the same memory ELF image 328 346 * used at a time. Note that this could be later done 329 347 * as COW. … … 351 369 frame = PTE_GET_FRAME(&pte); 352 370 } 353 } else if ( upage >= start_anon) {371 } else if (elfpage >= start_anon) { 354 372 /* 355 373 * This is the uninitialized portion of the segment. … … 424 442 elf_segment_header_t *entry = area->backend_data.segment; 425 443 uintptr_t start_anon; 444 uintptr_t elfpage; 426 445 427 446 assert(page_table_locked(area->as)); 428 447 assert(mutex_locked(&area->lock)); 429 448 430 assert(page >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)); 431 assert(page < entry->p_vaddr + entry->p_memsz); 449 elfpage = elf_orig_page(area, page); 450 451 assert(elfpage >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)); 452 assert(elfpage < entry->p_vaddr + entry->p_memsz); 432 453 433 454 start_anon = entry->p_vaddr + entry->p_filesz; 434 455 435 if ( page >= entry->p_vaddr &&page + PAGE_SIZE <= start_anon) {456 if (elfpage >= entry->p_vaddr && elfpage + PAGE_SIZE <= start_anon) { 436 457 if (entry->p_flags & PF_W) { 437 458 /*
Note:
See TracChangeset
for help on using the changeset viewer.