Ignore:
File:
1 edited

Legend:

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

    r59fb782 r94795812  
    7979#include <syscall/copy.h>
    8080#include <arch/interrupt.h>
    81 #include <interrupt.h>
    8281
    8382/**
     
    427426        /*
    428427         * So far, the area does not conflict with other areas.
    429          * Check if it is contained in the user address space.
     428         * Check if it doesn't conflict with kernel address space.
    430429         */
    431430        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    432                 return iswithin(USER_ADDRESS_SPACE_START,
    433                     (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1,
    434                     addr, P2SZ(count));
     431                return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
     432                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
    435433        }
    436434       
     
    544542    mem_backend_data_t *backend_data, uintptr_t *base, uintptr_t bound)
    545543{
    546         if ((*base != (uintptr_t) -1) && !IS_ALIGNED(*base, PAGE_SIZE))
     544        if ((*base != (uintptr_t) -1) && ((*base % PAGE_SIZE) != 0))
    547545                return NULL;
    548546       
     
    688686int as_area_resize(as_t *as, uintptr_t address, size_t size, unsigned int flags)
    689687{
    690         if (!IS_ALIGNED(address, PAGE_SIZE))
    691                 return EINVAL;
    692 
    693688        mutex_lock(&as->lock);
    694689       
     
    701696                return ENOENT;
    702697        }
    703 
    704         if (!area->backend->is_resizable(area)) {
    705                 /*
    706                  * The backend does not support resizing for this area.
     698       
     699        if (area->backend == &phys_backend) {
     700                /*
     701                 * Remapping of address space areas associated
     702                 * with memory mapped devices is not supported.
    707703                 */
    708704                mutex_unlock(&area->lock);
     
    10611057        }
    10621058       
    1063         if (!src_area->backend->is_shareable(src_area)) {
    1064                 /*
    1065                  * The backend does not permit sharing of this area.
     1059        if ((!src_area->backend) || (!src_area->backend->share)) {
     1060                /*
     1061                 * There is no backend or the backend does not
     1062                 * know how to share the area.
    10661063                 */
    10671064                mutex_unlock(&src_area->lock);
     
    13531350 * Interrupts are assumed disabled.
    13541351 *
    1355  * @param address Faulting address.
    1356  * @param access  Access mode that caused the page fault (i.e.
    1357  *                read/write/exec).
    1358  * @param istate  Pointer to the interrupted state.
     1352 * @param page   Faulting page.
     1353 * @param access Access mode that caused the page fault (i.e.
     1354 *               read/write/exec).
     1355 * @param istate Pointer to the interrupted state.
    13591356 *
    13601357 * @return AS_PF_FAULT on page fault.
     
    13641361 *
    13651362 */
    1366 int as_page_fault(uintptr_t address, pf_access_t access, istate_t *istate)
    1367 {
    1368         uintptr_t page = ALIGN_DOWN(address, PAGE_SIZE);
    1369         int rc = AS_PF_FAULT;
    1370 
     1363int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
     1364{
    13711365        if (!THREAD)
    1372                 goto page_fault;
     1366                return AS_PF_FAULT;
    13731367       
    13741368        if (!AS)
    1375                 goto page_fault;
     1369                return AS_PF_FAULT;
    13761370       
    13771371        mutex_lock(&AS->lock);
     
    14291423         * Resort to the backend page fault handler.
    14301424         */
    1431         rc = area->backend->page_fault(area, page, access);
    1432         if (rc != AS_PF_OK) {
     1425        if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
    14331426                page_table_unlock(AS, false);
    14341427                mutex_unlock(&area->lock);
     
    14511444                istate_set_retaddr(istate,
    14521445                    (uintptr_t) &memcpy_to_uspace_failover_address);
    1453         } else if (rc == AS_PF_SILENT) {
    1454                 printf("Killing task %" PRIu64 " due to a "
    1455                     "failed late reservation request.\n", TASK->taskid);
    1456                 task_kill_self(true);
    14571446        } else {
    1458                 fault_if_from_uspace(istate, "Page fault: %p.", (void *) address);
    1459                 panic_memtrap(istate, access, address, NULL);
     1447                return AS_PF_FAULT;
    14601448        }
    14611449       
     
    16831671{
    16841672        ASSERT(mutex_locked(&area->lock));
    1685         ASSERT(IS_ALIGNED(page, PAGE_SIZE));
     1673        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    16861674        ASSERT(count);
    16871675       
     
    19671955{
    19681956        ASSERT(mutex_locked(&area->lock));
    1969         ASSERT(IS_ALIGNED(page, PAGE_SIZE));
     1957        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    19701958        ASSERT(count);
    19711959       
     
    21442132{
    21452133        uintptr_t virt = base;
    2146         as_area_t *area = as_area_create(AS, flags, size,
     2134        as_area_t *area = as_area_create(AS, flags | AS_AREA_CACHEABLE, size,
    21472135            AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound);
    21482136        if (area == NULL)
Note: See TracChangeset for help on using the changeset viewer.