Changeset 2fc3b2d in mainline for kernel/generic/src/mm/backend_elf.c
- Timestamp:
- 2018-12-10T11:15:10Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 247fdea
- Parents:
- de9a18e
- git-author:
- Jiri Svoboda <jiri@…> (2018-12-05 18:39:06)
- git-committer:
- jxsvoboda <5887334+jxsvoboda@…> (2018-12-10 11:15:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_elf.c
rde9a18e r2fc3b2d 153 153 { 154 154 elf_segment_header_t *entry = area->backend_data.segment; 155 link_t *cur;156 btree_node_t *leaf, *node;155 used_space_ival_t *start; 156 used_space_ival_t *cur; 157 157 uintptr_t start_anon = entry->p_vaddr + entry->p_filesz; 158 158 … … 164 164 */ 165 165 if (area->flags & AS_AREA_WRITE) { 166 node = list_get_instance(list_first(&area->used_space.leaf_list), 167 btree_node_t, leaf_link); 166 start = used_space_first(&area->used_space); 168 167 } else { 169 (void) btree_search(&area->used_space, start_anon, &leaf); 170 node = btree_leaf_node_left_neighbour(&area->used_space, leaf); 171 if (!node) 172 node = leaf; 168 /* Find first interval containing addresses >= start_anon */ 169 start = used_space_find_gteq(&area->used_space, start_anon); 173 170 } 174 171 … … 177 174 */ 178 175 mutex_lock(&area->sh_info->lock); 179 for (cur = &node->leaf_link; cur != &area->used_space.leaf_list.head; 180 cur = cur->next) { 176 cur = start; 177 while (cur != NULL) { 178 uintptr_t base = cur->page; 179 size_t count = cur->count; 181 180 unsigned int i; 182 181 183 node = list_get_instance(cur, btree_node_t, leaf_link); 184 185 for (i = 0; i < node->keys; i++) { 186 uintptr_t base = node->key[i]; 187 size_t count = (size_t) node->value[i]; 188 unsigned int j; 182 /* 183 * Skip read-only areas of used space that are backed 184 * by the ELF image. 185 */ 186 if (!(area->flags & AS_AREA_WRITE)) 187 if (base >= entry->p_vaddr && 188 base + P2SZ(count) <= start_anon) 189 continue; 190 191 for (i = 0; i < count; i++) { 192 pte_t pte; 193 bool found; 189 194 190 195 /* 191 * Skip read-only areas of used space that are backed192 * by theELF image.196 * Skip read-only pages that are backed by the 197 * ELF image. 193 198 */ 194 199 if (!(area->flags & AS_AREA_WRITE)) 195 200 if (base >= entry->p_vaddr && 196 base + P2SZ( count) <= start_anon)201 base + P2SZ(i + 1) <= start_anon) 197 202 continue; 198 203 199 for (j = 0; j < count; j++) { 200 pte_t pte; 201 bool found; 202 203 /* 204 * Skip read-only pages that are backed by the 205 * ELF image. 206 */ 207 if (!(area->flags & AS_AREA_WRITE)) 208 if (base >= entry->p_vaddr && 209 base + P2SZ(j + 1) <= start_anon) 210 continue; 211 212 page_table_lock(area->as, false); 213 found = page_mapping_find(area->as, 214 base + P2SZ(j), false, &pte); 215 216 (void) found; 217 assert(found); 218 assert(PTE_VALID(&pte)); 219 assert(PTE_PRESENT(&pte)); 220 221 as_pagemap_insert(&area->sh_info->pagemap, 222 (base + P2SZ(j)) - area->base, 223 PTE_GET_FRAME(&pte)); 224 page_table_unlock(area->as, false); 225 226 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte)); 227 frame_reference_add(pfn); 228 } 229 204 page_table_lock(area->as, false); 205 found = page_mapping_find(area->as, 206 base + P2SZ(i), false, &pte); 207 208 (void) found; 209 assert(found); 210 assert(PTE_VALID(&pte)); 211 assert(PTE_PRESENT(&pte)); 212 213 as_pagemap_insert(&area->sh_info->pagemap, 214 (base + P2SZ(i)) - area->base, 215 PTE_GET_FRAME(&pte)); 216 page_table_unlock(area->as, false); 217 218 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte)); 219 frame_reference_add(pfn); 230 220 } 231 } 221 222 cur = used_space_next(cur); 223 } 224 232 225 mutex_unlock(&area->sh_info->lock); 233 226 } … … 310 303 page_mapping_insert(AS, upage, frame, 311 304 as_area_get_flags(area)); 312 if (!used_space_insert( area, upage, 1))305 if (!used_space_insert(&area->used_space, upage, 1)) 313 306 panic("Cannot insert used space."); 314 307 mutex_unlock(&area->sh_info->lock); … … 405 398 406 399 page_mapping_insert(AS, upage, frame, as_area_get_flags(area)); 407 if (!used_space_insert( area, upage, 1))400 if (!used_space_insert(&area->used_space, upage, 1)) 408 401 panic("Cannot insert used space."); 409 402
Note:
See TracChangeset
for help on using the changeset viewer.