Changeset 5c2af75 in mainline for kernel/generic/src/mm/backend_user.c


Ignore:
Timestamp:
2016-08-30T16:10:26Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2f6ad06
Parents:
072607b
Message:

Implement user_backend page fault handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/backend_user.c

    r072607b r5c2af75  
    3939#include <mm/as.h>
    4040#include <mm/page.h>
     41#include <abi/ipc/methods.h>
     42#include <ipc/sysipc.h>
    4143#include <synch/mutex.h>
    4244#include <typedefs.h>
    4345#include <align.h>
    4446#include <debug.h>
     47#include <errno.h>
     48#include <log.h>
    4549
    4650static bool user_create(as_area_t *);
     
    125129        ASSERT(IS_ALIGNED(upage, PAGE_SIZE));
    126130
    127         return AS_PF_FAULT;
     131        if (!as_area_check_access(area, access))
     132                return AS_PF_FAULT;
     133
     134        ipc_data_t data = {};
     135        IPC_SET_IMETHOD(data, IPC_M_PAGE_IN);
     136        IPC_SET_ARG1(data, upage - area->base);
     137        IPC_SET_ARG2(data, PAGE_SIZE);
     138
     139        int rc = ipc_req_internal(area->backend_data.pager, &data);
     140
     141        if (rc != EOK) {
     142                log(LF_USPACE, LVL_FATAL,
     143                    "Page-in request for page %#" PRIxn
     144                    " at pager %d failed with error %d.",
     145                    upage, area->backend_data.pager, rc);
     146                return AS_PF_FAULT;
     147        }
     148
     149        if (IPC_GET_RETVAL(data) != EOK)
     150                return AS_PF_FAULT;
     151
     152        /*
     153         * A successful reply will contain the physical frame in ARG1.
     154         * The physical frame will have the reference count already
     155         * incremented.
     156         */
     157
     158        uintptr_t frame = IPC_GET_ARG1(data);
     159        page_mapping_insert(AS, upage, frame, as_area_get_flags(area));
     160        if (!used_space_insert(area, upage, 1))
     161                panic("Cannot insert used space.");
     162
     163        return AS_PF_OK;
    128164}
    129165
Note: See TracChangeset for help on using the changeset viewer.