Changeset 38dc82d in mainline
- Timestamp:
- 2016-08-31T14:16:45Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 346b12a2
- Parents:
- dc05a9a
- Location:
- kernel
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/mm/tlb.c
rdc05a9a r38dc82d 484 484 { 485 485 uintptr_t va; 486 pte_t *t;486 pte_t t; 487 487 488 488 va = istate->cr_ifa; /* faulting address */ … … 490 490 ASSERT(!is_kernel_fault(va)); 491 491 492 t = page_mapping_find(AS, va, true);493 if ( t) {492 bool found = page_mapping_find(AS, va, true, &t); 493 if (found) { 494 494 /* 495 495 * The mapping was found in software page hash table. 496 496 * Insert it into data translation cache. 497 497 */ 498 itc_pte_copy( t);498 itc_pte_copy(&t); 499 499 } else { 500 500 /* … … 600 600 601 601 602 pte_t *entry = page_mapping_find(as, va, true); 603 if (entry) { 602 pte_t t; 603 bool found = page_mapping_find(as, va, true, &t); 604 if (found) { 604 605 /* 605 606 * The mapping was found in the software page hash table. 606 607 * Insert it into data translation cache. 607 608 */ 608 dtc_pte_copy( entry);609 dtc_pte_copy(&t); 609 610 } else { 610 611 if (try_memmap_io_insertion(va, istate)) … … 641 642 { 642 643 uintptr_t va; 643 pte_t *t;644 pte_t t; 644 645 as_t *as = AS; 645 646 … … 649 650 as = AS_KERNEL; 650 651 651 t = page_mapping_find(as, va, true); 652 ASSERT((t) && (t->p)); 653 if ((t) && (t->p) && (t->w)) { 652 bool found = page_mapping_find(as, va, true, &t); 653 654 ASSERT(found); 655 ASSERT(t.p); 656 657 if (found && t.p && t.w) { 654 658 /* 655 659 * Update the Dirty bit in page tables and reinsert 656 660 * the mapping into DTC. 657 661 */ 658 t ->d = true;659 dtc_pte_copy( t);662 t.d = true; 663 dtc_pte_copy(&t); 660 664 } else { 661 665 as_page_fault(va, PF_ACCESS_WRITE, istate); … … 672 676 { 673 677 uintptr_t va; 674 pte_t *t;678 pte_t t; 675 679 676 680 va = istate->cr_ifa; /* faulting address */ … … 678 682 ASSERT(!is_kernel_fault(va)); 679 683 680 t = page_mapping_find(AS, va, true); 681 ASSERT((t) && (t->p)); 682 if ((t) && (t->p) && (t->x)) { 684 bool found = page_mapping_find(AS, va, true, &t); 685 686 ASSERT(found); 687 ASSERT(t.p); 688 689 if (found && t.p && t.x) { 683 690 /* 684 691 * Update the Accessed bit in page tables and reinsert 685 692 * the mapping into ITC. 686 693 */ 687 t ->a = true;688 itc_pte_copy( t);694 t.a = true; 695 itc_pte_copy(&t); 689 696 } else { 690 697 as_page_fault(va, PF_ACCESS_EXEC, istate); … … 701 708 { 702 709 uintptr_t va; 703 pte_t *t;710 pte_t t; 704 711 as_t *as = AS; 705 712 … … 709 716 as = AS_KERNEL; 710 717 711 t = page_mapping_find(as, va, true); 712 ASSERT((t) && (t->p)); 713 if ((t) && (t->p)) { 718 bool found = page_mapping_find(as, va, true, &t); 719 720 ASSERT(found); 721 ASSERT(t.p); 722 723 if (found && t.p) { 714 724 /* 715 725 * Update the Accessed bit in page tables and reinsert 716 726 * the mapping into DTC. 717 727 */ 718 t ->a = true;719 dtc_pte_copy( t);728 t.a = true; 729 dtc_pte_copy(&t); 720 730 } else { 721 731 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { … … 736 746 { 737 747 uintptr_t va; 738 pte_t *t;748 pte_t t; 739 749 740 750 va = istate->cr_ifa; /* faulting address */ … … 745 755 * Assume a write to a read-only page. 746 756 */ 747 t = page_mapping_find(AS, va, true); 748 ASSERT((t) && (t->p)); 749 ASSERT(!t->w); 757 bool found = page_mapping_find(AS, va, true, &t); 758 759 ASSERT(found); 760 ASSERT(t.p); 761 ASSERT(!t.w); 762 750 763 as_page_fault(va, PF_ACCESS_WRITE, istate); 751 764 } … … 760 773 { 761 774 uintptr_t va; 762 pte_t *t;775 pte_t t; 763 776 764 777 va = istate->cr_ifa; /* faulting address */ … … 766 779 ASSERT(!is_kernel_fault(va)); 767 780 768 t = page_mapping_find(AS, va, true); 769 ASSERT(t); 770 771 if (t->p) { 781 bool found = page_mapping_find(AS, va, true, &t); 782 783 ASSERT(found); 784 785 if (t.p) { 772 786 /* 773 787 * If the Present bit is set in page hash table, just copy it 774 788 * and update ITC/DTC. 775 789 */ 776 if (t ->x)777 itc_pte_copy( t);790 if (t.x) 791 itc_pte_copy(&t); 778 792 else 779 dtc_pte_copy( t);793 dtc_pte_copy(&t); 780 794 } else { 781 795 as_page_fault(va, PF_ACCESS_READ, istate); -
kernel/arch/mips32/src/mm/tlb.c
rdc05a9a r38dc82d 97 97 entry_lo_t lo; 98 98 uintptr_t badvaddr; 99 pte_t *pte;99 pte_t pte; 100 100 101 101 badvaddr = cp0_badvaddr_read(); 102 102 103 pte = page_mapping_find(AS, badvaddr, true);104 if ( pte && pte->p) {103 bool found = page_mapping_find(AS, badvaddr, true, &pte); 104 if (found && pte.p) { 105 105 /* 106 106 * Record access to PTE. 107 107 */ 108 pte ->a = 1;109 110 tlb_prepare_entry_lo(&lo, pte ->g, pte->p, pte->d,111 pte ->cacheable, pte->pfn);108 pte.a = 1; 109 110 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.d, 111 pte.cacheable, pte.pfn); 112 112 113 113 /* … … 138 138 tlb_index_t index; 139 139 uintptr_t badvaddr; 140 pte_t *pte;140 pte_t pte; 141 141 142 142 /* … … 162 162 badvaddr = cp0_badvaddr_read(); 163 163 164 pte = page_mapping_find(AS, badvaddr, true);165 if ( pte && pte->p) {164 bool found = page_mapping_find(AS, badvaddr, true, &pte); 165 if (found && pte.p) { 166 166 /* 167 167 * Read the faulting TLB entry. … … 172 172 * Record access to PTE. 173 173 */ 174 pte ->a = 1;175 176 tlb_prepare_entry_lo(&lo, pte ->g, pte->p, pte->d,177 pte ->cacheable, pte->pfn);174 pte.a = 1; 175 176 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.d, 177 pte.cacheable, pte.pfn); 178 178 179 179 /* … … 200 200 tlb_index_t index; 201 201 uintptr_t badvaddr; 202 pte_t *pte;202 pte_t pte; 203 203 204 204 badvaddr = cp0_badvaddr_read(); … … 224 224 } 225 225 226 pte = page_mapping_find(AS, badvaddr, true);227 if ( pte && pte->p && pte->w) {226 bool found = page_mapping_find(AS, badvaddr, true, &pte); 227 if (found && pte.p && pte.w) { 228 228 /* 229 229 * Read the faulting TLB entry. … … 234 234 * Record access and write to PTE. 235 235 */ 236 pte ->a = 1;237 pte ->d = 1;238 239 tlb_prepare_entry_lo(&lo, pte ->g, pte->p, pte->w,240 pte ->cacheable, pte->pfn);236 pte.a = 1; 237 pte.d = 1; 238 239 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.w, 240 pte.cacheable, pte.pfn); 241 241 242 242 /* -
kernel/arch/ppc32/src/mm/pht.c
rdc05a9a r38dc82d 49 49 * @param access Access mode that caused the fault. 50 50 * @param istate Pointer to interrupted state. 51 * 52 * @return PTE on success, NULL otherwise. 53 * 54 */ 55 static pte_t *find_mapping_and_check(as_t *as, uintptr_t badvaddr, int access, 56 istate_t *istate) 51 * @param[out] pte Structure that will receive a copy of the found PTE. 52 * 53 * @return True if the mapping was found, false otherwise. 54 * 55 */ 56 static bool find_mapping_and_check(as_t *as, uintptr_t badvaddr, int access, 57 istate_t *istate, pte_t *pte) 57 58 { 58 59 /* 59 60 * Check if the mapping exists in page tables. 60 61 */ 61 pte_t *pte = page_mapping_find(as, badvaddr, true);62 if ( (pte) && (pte->present)) {62 bool found = page_mapping_find(as, badvaddr, true, pte); 63 if (found && pte->present) { 63 64 /* 64 65 * Mapping found in page tables. 65 66 * Immediately succeed. 66 67 */ 67 return pte;68 return true; 68 69 } 69 70 /* … … 76 77 * The mapping ought to be in place. 77 78 */ 78 pte = page_mapping_find(as, badvaddr, true); 79 ASSERT((pte) && (pte->present)); 80 return pte; 81 } 82 83 return NULL; 79 found = page_mapping_find(as, badvaddr, true, pte); 80 81 ASSERT(found); 82 ASSERT(pte->present); 83 84 return found; 85 } 86 87 return false; 84 88 } 85 89 … … 182 186 badvaddr = istate->pc; 183 187 184 pte_t *pte = find_mapping_and_check(AS, badvaddr, 185 PF_ACCESS_READ /* FIXME */, istate); 186 187 if (pte) { 188 pte_t pte; 189 bool found = find_mapping_and_check(AS, badvaddr, 190 PF_ACCESS_READ /* FIXME */, istate, &pte); 191 192 if (found) { 188 193 /* Record access to PTE */ 189 pte ->accessed = 1;190 pht_insert(badvaddr, pte);194 pte.accessed = 1; 195 pht_insert(badvaddr, &pte); 191 196 } 192 197 } -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
rdc05a9a r38dc82d 197 197 { 198 198 size_t index = (istate->tpc >> MMU_PAGE_WIDTH) % MMU_PAGES_PER_PAGE; 199 pte_t *t;200 201 t = page_mapping_find(AS, istate->tpc, true);202 if ( t && PTE_EXECUTABLE(t)) {199 pte_t t; 200 201 bool found = page_mapping_find(AS, istate->tpc, true, &t); 202 if (found && PTE_EXECUTABLE(&t)) { 203 203 /* 204 204 * The mapping was found in the software page hash table. 205 205 * Insert it into ITLB. 206 206 */ 207 t ->a = true;208 itlb_pte_copy( t, index);207 t.a = true; 208 itlb_pte_copy(&t, index); 209 209 #ifdef CONFIG_TSB 210 itsb_pte_copy( t, index);210 itsb_pte_copy(&t, index); 211 211 #endif 212 212 } else { … … 233 233 uintptr_t page_16k; 234 234 size_t index; 235 pte_t *t;235 pte_t t; 236 236 as_t *as = AS; 237 237 … … 253 253 } 254 254 255 t = page_mapping_find(as, page_16k, true);256 if ( t) {255 bool found = page_mapping_find(as, page_16k, true, &t); 256 if (found) { 257 257 /* 258 258 * The mapping was found in the software page hash table. 259 259 * Insert it into DTLB. 260 260 */ 261 t ->a = true;262 dtlb_pte_copy( t, index, true);261 t.a = true; 262 dtlb_pte_copy(&t, index, true); 263 263 #ifdef CONFIG_TSB 264 dtsb_pte_copy( t, index, true);264 dtsb_pte_copy(&t, index, true); 265 265 #endif 266 266 } else { … … 283 283 uintptr_t page_16k; 284 284 size_t index; 285 pte_t *t;285 pte_t t; 286 286 as_t *as = AS; 287 287 … … 293 293 as = AS_KERNEL; 294 294 295 t = page_mapping_find(as, page_16k, true);296 if ( t && PTE_WRITABLE(t)) {295 bool found = page_mapping_find(as, page_16k, true, &t); 296 if (found && PTE_WRITABLE(&t)) { 297 297 /* 298 298 * The mapping was found in the software page hash table and is … … 300 300 * into DTLB. 301 301 */ 302 t ->a = true;303 t ->d = true;302 t.a = true; 303 t.d = true; 304 304 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, 305 305 page_16k + index * MMU_PAGE_SIZE); 306 dtlb_pte_copy( t, index, false);306 dtlb_pte_copy(&t, index, false); 307 307 #ifdef CONFIG_TSB 308 dtsb_pte_copy( t, index, false);308 dtsb_pte_copy(&t, index, false); 309 309 #endif 310 310 } else { -
kernel/arch/sparc64/src/mm/sun4v/tlb.c
rdc05a9a r38dc82d 211 211 { 212 212 uintptr_t va = ALIGN_DOWN(istate->tpc, PAGE_SIZE); 213 pte_t *t; 214 215 t = page_mapping_find(AS, va, true); 216 217 if (t && PTE_EXECUTABLE(t)) { 213 pte_t t; 214 215 bool found = page_mapping_find(AS, va, true, &t); 216 if (found && PTE_EXECUTABLE(&t)) { 218 217 /* 219 218 * The mapping was found in the software page hash table. 220 219 * Insert it into ITLB. 221 220 */ 222 t ->a = true;223 itlb_pte_copy( t);221 t.a = true; 222 itlb_pte_copy(&t); 224 223 #ifdef CONFIG_TSB 225 itsb_pte_copy( t);224 itsb_pte_copy(&t); 226 225 #endif 227 226 } else { … … 244 243 void fast_data_access_mmu_miss(unsigned int tt, istate_t *istate) 245 244 { 246 pte_t *t;245 pte_t t; 247 246 uintptr_t va = DMISS_ADDRESS(istate->tlb_tag_access); 248 247 uint16_t ctx = DMISS_CONTEXT(istate->tlb_tag_access); … … 261 260 } 262 261 263 t = page_mapping_find(as, va, true);264 if ( t) {262 bool found = page_mapping_find(as, va, true, &t); 263 if (found) { 265 264 /* 266 265 * The mapping was found in the software page hash table. 267 266 * Insert it into DTLB. 268 267 */ 269 t ->a = true;270 dtlb_pte_copy( t, true);268 t.a = true; 269 dtlb_pte_copy(&t, true); 271 270 #ifdef CONFIG_TSB 272 dtsb_pte_copy( t, true);271 dtsb_pte_copy(&t, true); 273 272 #endif 274 273 } else { … … 288 287 void fast_data_access_protection(unsigned int tt, istate_t *istate) 289 288 { 290 pte_t *t;289 pte_t t; 291 290 uintptr_t va = DMISS_ADDRESS(istate->tlb_tag_access); 292 291 uint16_t ctx = DMISS_CONTEXT(istate->tlb_tag_access); … … 296 295 as = AS_KERNEL; 297 296 298 t = page_mapping_find(as, va, true);299 if ( t && PTE_WRITABLE(t)) {297 bool found = page_mapping_find(as, va, true, &t); 298 if (found && PTE_WRITABLE(&t)) { 300 299 /* 301 300 * The mapping was found in the software page hash table and is … … 303 302 * into DTLB. 304 303 */ 305 t ->a = true;306 t ->d = true;304 t.a = true; 305 t.d = true; 307 306 mmu_demap_page(va, ctx, MMU_FLAG_DTLB); 308 dtlb_pte_copy( t, false);307 dtlb_pte_copy(&t, false); 309 308 #ifdef CONFIG_TSB 310 dtsb_pte_copy( t, false);309 dtsb_pte_copy(&t, false); 311 310 #endif 312 311 } else { -
kernel/genarch/src/mm/page_ht.c
rdc05a9a r38dc82d 59 59 static void ht_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 60 60 static void ht_mapping_remove(as_t *, uintptr_t); 61 static pte_t *ht_mapping_find(as_t *, uintptr_t, bool);61 static bool ht_mapping_find(as_t *, uintptr_t, bool, pte_t *); 62 62 static void ht_mapping_make_global(uintptr_t, size_t); 63 63 … … 248 248 /** Find mapping for virtual page in page hash table. 249 249 * 250 * @param as Address space to which page belongs.251 * @param page Virtual page.252 * @param nolock True if the page tables need not be locked.253 * 254 * @return NULL if there is no such mapping; requested mapping otherwise.255 * 256 */ 257 pte_t *ht_mapping_find(as_t *as, uintptr_t page, bool nolock)250 * @param as Address space to which page belongs. 251 * @param page Virtual page. 252 * @param nolock True if the page tables need not be locked. 253 * @param[out] pte Structure that will receive a copy of the found PTE. 254 * 255 * @return True if the mapping was found, false otherwise. 256 */ 257 bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 258 258 { 259 259 sysarg_t key[2] = { … … 266 266 link_t *cur = hash_table_find(&page_ht, key); 267 267 if (cur) 268 returnhash_table_get_instance(cur, pte_t, link);269 270 return NULL;268 *pte = *hash_table_get_instance(cur, pte_t, link); 269 270 return cur != NULL; 271 271 } 272 272 -
kernel/genarch/src/mm/page_pt.c
rdc05a9a r38dc82d 53 53 static void pt_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 54 54 static void pt_mapping_remove(as_t *, uintptr_t); 55 static pte_t *pt_mapping_find(as_t *, uintptr_t, bool);55 static bool pt_mapping_find(as_t *, uintptr_t, bool, pte_t *pte); 56 56 static void pt_mapping_make_global(uintptr_t, size_t); 57 57 … … 291 291 /** Find mapping for virtual page in hierarchical page tables. 292 292 * 293 * @param as Address space to which page belongs. 294 * @param page Virtual page. 295 * @param nolock True if the page tables need not be locked. 296 * 297 * @return NULL if there is no such mapping; entry from PTL3 describing 298 * the mapping otherwise. 299 * 300 */ 301 pte_t *pt_mapping_find(as_t *as, uintptr_t page, bool nolock) 293 * @param as Address space to which page belongs. 294 * @param page Virtual page. 295 * @param nolock True if the page tables need not be locked. 296 * @param[out] pte Structure that will receive a copy of the found PTE. 297 * 298 * @return True if the mapping was found, false otherwise. 299 */ 300 bool pt_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 302 301 { 303 302 ASSERT(nolock || page_table_locked(as)); … … 305 304 pte_t *ptl0 = (pte_t *) PA2KA((uintptr_t) as->genarch.page_table); 306 305 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) 307 return NULL;306 return false; 308 307 309 308 read_barrier(); … … 311 310 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 312 311 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) 313 return NULL;312 return false; 314 313 315 314 #if (PTL1_ENTRIES != 0) … … 322 321 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 323 322 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) 324 return NULL;323 return false; 325 324 326 325 #if (PTL2_ENTRIES != 0) … … 333 332 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 334 333 335 return &ptl3[PTL3_INDEX(page)]; 334 *pte = ptl3[PTL3_INDEX(page)]; 335 return true; 336 336 } 337 337 -
kernel/generic/include/mm/page.h
rdc05a9a r38dc82d 48 48 void (* mapping_insert)(as_t *, uintptr_t, uintptr_t, unsigned int); 49 49 void (* mapping_remove)(as_t *, uintptr_t); 50 pte_t *(* mapping_find)(as_t *, uintptr_t, bool);50 bool (* mapping_find)(as_t *, uintptr_t, bool, pte_t *); 51 51 void (* mapping_make_global)(uintptr_t, size_t); 52 52 } page_mapping_operations_t; … … 60 60 extern void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 61 61 extern void page_mapping_remove(as_t *, uintptr_t); 62 extern pte_t *page_mapping_find(as_t *, uintptr_t, bool);62 extern bool page_mapping_find(as_t *, uintptr_t, bool, pte_t *); 63 63 extern void page_mapping_make_global(uintptr_t, size_t); 64 64 extern pte_t *page_table_create(unsigned int); -
kernel/generic/src/mm/as.c
rdc05a9a r38dc82d 888 888 889 889 for (; i < node_size; i++) { 890 pte_t *pte = page_mapping_find(as, 891 ptr + P2SZ(i), false); 890 pte_t pte; 891 bool found = page_mapping_find(as, 892 ptr + P2SZ(i), false, &pte); 892 893 893 ASSERT( pte);894 ASSERT(PTE_VALID( pte));895 ASSERT(PTE_PRESENT( pte));894 ASSERT(found); 895 ASSERT(PTE_VALID(&pte)); 896 ASSERT(PTE_PRESENT(&pte)); 896 897 897 898 if ((area->backend) && … … 899 900 area->backend->frame_free(area, 900 901 ptr + P2SZ(i), 901 PTE_GET_FRAME( pte));902 PTE_GET_FRAME(&pte)); 902 903 } 903 904 … … 1002 1003 1003 1004 for (size = 0; size < (size_t) node->value[i]; size++) { 1004 pte_t *pte = page_mapping_find(as, 1005 ptr + P2SZ(size), false); 1005 pte_t pte; 1006 bool found = page_mapping_find(as, 1007 ptr + P2SZ(size), false, &pte); 1006 1008 1007 ASSERT( pte);1008 ASSERT(PTE_VALID( pte));1009 ASSERT(PTE_PRESENT( pte));1009 ASSERT(found); 1010 ASSERT(PTE_VALID(&pte)); 1011 ASSERT(PTE_PRESENT(&pte)); 1010 1012 1011 1013 if ((area->backend) && … … 1013 1015 area->backend->frame_free(area, 1014 1016 ptr + P2SZ(size), 1015 PTE_GET_FRAME( pte));1017 PTE_GET_FRAME(&pte)); 1016 1018 } 1017 1019 … … 1314 1316 1315 1317 for (size = 0; size < (size_t) node->value[i]; size++) { 1316 pte_t *pte = page_mapping_find(as, 1317 ptr + P2SZ(size), false); 1318 pte_t pte; 1319 bool found = page_mapping_find(as, 1320 ptr + P2SZ(size), false, &pte); 1318 1321 1319 ASSERT( pte);1320 ASSERT(PTE_VALID( pte));1321 ASSERT(PTE_PRESENT( pte));1322 ASSERT(found); 1323 ASSERT(PTE_VALID(&pte)); 1324 ASSERT(PTE_PRESENT(&pte)); 1322 1325 1323 old_frame[frame_idx++] = PTE_GET_FRAME( pte);1326 old_frame[frame_idx++] = PTE_GET_FRAME(&pte); 1324 1327 1325 1328 /* Remove old mapping */ … … 1451 1454 * we need to make sure the mapping has not been already inserted. 1452 1455 */ 1453 pte_t *pte; 1454 if ((pte = page_mapping_find(AS, page, false))) { 1455 if (PTE_PRESENT(pte)) { 1456 if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) || 1457 (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) || 1458 (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) { 1456 pte_t pte; 1457 bool found = page_mapping_find(AS, page, false, &pte); 1458 if (found) { 1459 if (PTE_PRESENT(&pte)) { 1460 if (((access == PF_ACCESS_READ) && PTE_READABLE(&pte)) || 1461 (access == PF_ACCESS_WRITE && PTE_WRITABLE(&pte)) || 1462 (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(&pte))) { 1459 1463 page_table_unlock(AS, false); 1460 1464 mutex_unlock(&area->lock); -
kernel/generic/src/mm/backend_anon.c
rdc05a9a r38dc82d 131 131 132 132 for (j = 0; j < count; j++) { 133 pte_t *pte; 133 pte_t pte; 134 bool found; 134 135 135 136 page_table_lock(area->as, false); 136 pte = page_mapping_find(area->as, 137 base + P2SZ(j), false); 138 ASSERT(pte && PTE_VALID(pte) && 139 PTE_PRESENT(pte)); 137 found = page_mapping_find(area->as, 138 base + P2SZ(j), false, &pte); 139 140 ASSERT(found); 141 ASSERT(PTE_VALID(&pte)); 142 ASSERT(PTE_PRESENT(&pte)); 143 140 144 btree_insert(&area->sh_info->pagemap, 141 145 (base + P2SZ(j)) - area->base, 142 (void *) PTE_GET_FRAME( pte), NULL);146 (void *) PTE_GET_FRAME(&pte), NULL); 143 147 page_table_unlock(area->as, false); 144 148 145 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME( pte));149 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte)); 146 150 frame_reference_add(pfn); 147 151 } -
kernel/generic/src/mm/backend_elf.c
rdc05a9a r38dc82d 184 184 185 185 for (j = 0; j < count; j++) { 186 pte_t *pte; 186 pte_t pte; 187 bool found; 187 188 188 189 /* … … 196 197 197 198 page_table_lock(area->as, false); 198 pte = page_mapping_find(area->as, 199 base + P2SZ(j), false); 200 ASSERT(pte && PTE_VALID(pte) && 201 PTE_PRESENT(pte)); 199 found = page_mapping_find(area->as, 200 base + P2SZ(j), false, &pte); 201 202 ASSERT(found); 203 ASSERT(PTE_VALID(&pte)); 204 ASSERT(PTE_PRESENT(&pte)); 205 202 206 btree_insert(&area->sh_info->pagemap, 203 207 (base + P2SZ(j)) - area->base, 204 (void *) PTE_GET_FRAME( pte), NULL);208 (void *) PTE_GET_FRAME(&pte), NULL); 205 209 page_table_unlock(area->as, false); 206 210 207 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME( pte));211 pfn_t pfn = ADDR2PFN(PTE_GET_FRAME(&pte)); 208 212 frame_reference_add(pfn); 209 213 } … … 335 339 dirty = true; 336 340 } else { 337 pte_t *pte = page_mapping_find(AS_KERNEL, 338 base + i * FRAME_SIZE, true); 339 340 ASSERT(pte); 341 ASSERT(PTE_PRESENT(pte)); 342 343 frame = PTE_GET_FRAME(pte); 341 pte_t pte; 342 bool found; 343 344 found = page_mapping_find(AS_KERNEL, 345 base + i * FRAME_SIZE, true, &pte); 346 347 ASSERT(found); 348 ASSERT(PTE_PRESENT(&pte)); 349 350 frame = PTE_GET_FRAME(&pte); 344 351 } 345 352 } else if (upage >= start_anon) { -
kernel/generic/src/mm/page.c
rdc05a9a r38dc82d 137 137 /** Find mapping for virtual page. 138 138 * 139 * @param as Address space to which page belongs.140 * @param page Virtual page.141 * @param nolock True if the page tables need not be locked.142 * 143 * @return NULL if there is no such mapping; requested mapping144 * 145 * 146 */ 147 NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page, bool nolock)139 * @param as Address space to which page belongs. 140 * @param page Virtual page. 141 * @param nolock True if the page tables need not be locked. 142 * @param[out] pte Structure that will receive a copy of the found PTE. 143 * 144 * @return True if the mapping was found, false otherwise. 145 */ 146 NO_TRACE bool page_mapping_find(as_t *as, uintptr_t page, bool nolock, 147 pte_t *pte) 148 148 { 149 149 ASSERT(nolock || page_table_locked(as)); … … 153 153 154 154 return page_mapping_operations->mapping_find(as, 155 ALIGN_DOWN(page, PAGE_SIZE), nolock );155 ALIGN_DOWN(page, PAGE_SIZE), nolock, pte); 156 156 } 157 157 … … 173 173 page_table_lock(AS, true); 174 174 175 pte_t *pte = page_mapping_find(AS, virt, false); 176 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 175 pte_t pte; 176 bool found = page_mapping_find(AS, virt, false, &pte); 177 if (!found || !PTE_VALID(&pte) || !PTE_PRESENT(&pte)) { 177 178 page_table_unlock(AS, true); 178 179 return ENOENT; 179 180 } 180 181 181 *phys = PTE_GET_FRAME( pte) +182 *phys = PTE_GET_FRAME(&pte) + 182 183 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 183 184 -
kernel/generic/src/synch/futex.c
rdc05a9a r38dc82d 291 291 spinlock_lock(&futex_ht_lock); 292 292 293 bool found = false; 294 pte_t *t = page_mapping_find(AS, ALIGN_DOWN(uaddr, PAGE_SIZE), true); 295 296 if (t && PTE_VALID(t) && PTE_PRESENT(t)) { 297 found = true; 298 *paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE)); 293 bool success = false; 294 295 pte_t t; 296 bool found; 297 298 found = page_mapping_find(AS, ALIGN_DOWN(uaddr, PAGE_SIZE), true, &t); 299 if (found && PTE_VALID(&t) && PTE_PRESENT(&t)) { 300 success = true; 301 *paddr = PTE_GET_FRAME(&t) + 302 (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE)); 299 303 } 300 304 … … 302 306 page_table_unlock(AS, false); 303 307 304 return found;308 return success; 305 309 } 306 310
Note:
See TracChangeset
for help on using the changeset viewer.