Changeset 560b81c in mainline for kernel/generic/src


Ignore:
Timestamp:
2016-09-17T15:09:40Z (9 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/generic/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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.