Changeset 560b81c in mainline


Ignore:
Timestamp:
2016-09-17T15:09:40Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ae66564
Parents:
97b8ca9
Message:

Make sure to test the present bit of the found PTE

By design, page_mapping_find() can return true and a copy of a PTE
which is not present. It is therefore necessary to test the found PTE
by PTE_PRESENT() macro.

Location:
kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/mm/tlb.c

    r97b8ca9 r560b81c  
    492492        bool found = page_mapping_find(AS, va, true, &t);
    493493        if (found) {
     494                ASSERT(t.p);
     495
    494496                /*
    495497                 * The mapping was found in software page hash table.
     
    603605        bool found = page_mapping_find(as, va, true, &t);
    604606        if (found) {
     607                ASSERT(t.p);
     608
    605609                /*
    606610                 * The mapping was found in the software page hash table.
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    r97b8ca9 r560b81c  
    201201        bool found = page_mapping_find(AS, istate->tpc, true, &t);
    202202        if (found && PTE_EXECUTABLE(&t)) {
     203                ASSERT(t.p);
     204
    203205                /*
    204206                 * The mapping was found in the software page hash table.
     
    256258        bool found = page_mapping_find(as, page_16k, true, &t);
    257259        if (found) {
     260                ASSERT(t.p);
     261
    258262                /*
    259263                 * The mapping was found in the software page hash table.
     
    297301        bool found = page_mapping_find(as, page_16k, true, &t);
    298302        if (found && PTE_WRITABLE(&t)) {
     303                ASSERT(t.p);
     304
    299305                /*
    300306                 * The mapping was found in the software page hash table and is
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    r97b8ca9 r560b81c  
    215215        bool found = page_mapping_find(AS, va, true, &t);
    216216        if (found && PTE_EXECUTABLE(&t)) {
     217                ASSERT(t.p);
     218
    217219                /*
    218220                 * The mapping was found in the software page hash table.
     
    263265        bool found = page_mapping_find(as, va, true, &t);
    264266        if (found) {
     267                ASSERT(t.p);
     268
    265269                /*
    266270                 * The mapping was found in the software page hash table.
     
    299303        bool found = page_mapping_find(as, va, true, &t);
    300304        if (found && PTE_WRITABLE(&t)) {
     305                ASSERT(t.p);
     306
    301307                /*
    302308                 * The mapping was found in the software page hash table and is
  • kernel/generic/src/ipc/ops/pagein.c

    r97b8ca9 r560b81c  
    5353                bool found = page_mapping_find(AS, IPC_GET_ARG1(answer->data),
    5454                    false, &pte);
    55                 if (found) {
     55                if (found & PTE_PRESENT(&pte)) {
    5656                        frame = PTE_GET_FRAME(&pte);
    5757                        pfn_t pfn = ADDR2PFN(frame);
  • kernel/generic/src/mm/as.c

    r97b8ca9 r560b81c  
    14571457        pte_t pte;
    14581458        bool found = page_mapping_find(AS, page, false, &pte);
    1459         if (found) {
    1460                 if (PTE_PRESENT(&pte)) {
    1461                         if (((access == PF_ACCESS_READ) && PTE_READABLE(&pte)) ||
    1462                             (access == PF_ACCESS_WRITE && PTE_WRITABLE(&pte)) ||
    1463                             (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(&pte))) {
    1464                                 page_table_unlock(AS, false);
    1465                                 mutex_unlock(&area->lock);
    1466                                 mutex_unlock(&AS->lock);
    1467                                 return AS_PF_OK;
    1468                         }
     1459        if (found && 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))) {
     1463                        page_table_unlock(AS, false);
     1464                        mutex_unlock(&area->lock);
     1465                        mutex_unlock(&AS->lock);
     1466                        return AS_PF_OK;
    14691467                }
    14701468        }
  • kernel/generic/src/mm/page.c

    r97b8ca9 r560b81c  
    142142 * @param[out] pte Structure that will receive a copy of the found PTE.
    143143 *
    144  * @return True if the mapping was found, false otherwise.
     144 * @return True if a valid PTE is returned, false otherwise. Note that
     145 *         the PTE is not guaranteed to be present.
    145146 */
    146147NO_TRACE bool page_mapping_find(as_t *as, uintptr_t page, bool nolock,
Note: See TracChangeset for help on using the changeset viewer.