Changeset fb84455 in mainline


Ignore:
Timestamp:
2006-05-27T13:35:32Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ee077ee
Parents:
6bf18fa
Message:

Update page fault handlers to distinguish between different access modes that had caused the page fault.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/mm/page.h

    r6bf18fa rfb84455  
    104104#define PTE_PRESENT_ARCH(p)                     ((p)->present != 0)
    105105#define PTE_GET_FRAME_ARCH(p)                   ((((__address)(p)->addr_12_31)<<12) | ((__address)(p)->addr_32_51<<32))
     106#define PTE_WRITABLE_ARCH(p)                    ((p)->writeable != 0)
     107#define PTE_EXECUTABLE_ARCH(p)                  ((p)->no_execute == 0)
    106108
    107109#ifndef __ASM__
  • arch/ia32/include/mm/page.h

    r6bf18fa rfb84455  
    8383#define PTE_PRESENT_ARCH(p)                     ((p)->present != 0)
    8484#define PTE_GET_FRAME_ARCH(p)                   ((p)->frame_address<<FRAME_WIDTH)
     85#define PTE_WRITABLE_ARCH(p)                    ((p)->writeable != 0)
     86#define PTE_EXECUTABLE_ARCH(p)                  1
    8587
    8688#ifndef __ASM__
  • arch/mips32/include/mm/page.h

    r6bf18fa rfb84455  
    9898#define PTE_PRESENT_ARCH(pte)                   ((pte)->p != 0)
    9999#define PTE_GET_FRAME_ARCH(pte)                 ((pte)->pfn<<12)
     100#define PTE_WRITABLE_ARCH(pte)                  ((pte)->w != 0)
     101#define PTE_EXECUTABLE_ARCH(pte)                1
    100102
    101103#ifndef __ASM__
  • arch/ppc32/include/mm/page.h

    r6bf18fa rfb84455  
    9090
    9191#define PTE_VALID_ARCH(pte)                     (*((__u32 *) (pte)) != 0)
    92 #define PTE_PRESENT_ARCH(pte)           ((pte)->p != 0)
    93 #define PTE_GET_FRAME_ARCH(pte)         ((pte)->pfn << 12)
     92#define PTE_PRESENT_ARCH(pte)                   ((pte)->p != 0)
     93#define PTE_GET_FRAME_ARCH(pte)                 ((pte)->pfn << 12)
     94#define PTE_WRITABLE_ARCH(pte)                  1
     95#define PTE_EXECUTABLE_ARCH(pte)                1
    9496
    9597#ifndef __ASM__
  • arch/ppc64/include/mm/page.h

    r6bf18fa rfb84455  
    9090
    9191#define PTE_VALID_ARCH(pte)                     (*((__u32 *) (pte)) != 0)
    92 #define PTE_PRESENT_ARCH(pte)           ((pte)->p != 0)
    93 #define PTE_GET_FRAME_ARCH(pte)         ((pte)->pfn << 12)
     92#define PTE_PRESENT_ARCH(pte)                   ((pte)->p != 0)
     93#define PTE_GET_FRAME_ARCH(pte)                 ((__address) ((pte)->pfn << 12))
     94#define PTE_WRITABLE_ARCH(pte)                  1
     95#define PTE_EXECUTABLE_ARCH(pte)                1
    9496
    9597#ifndef __ASM__
  • genarch/include/mm/page_ht.h

    r6bf18fa rfb84455  
    5252#define PTE_PRESENT(pte)        ((pte)->p != 0)
    5353#define PTE_GET_FRAME(pte)      ((pte)->frame)
     54#define PTE_READABLE(pte)       1
     55#define PTE_WRITABLE(pte)       ((pte)->w != 0)
     56#define PTE_EXECUTABLE(pte)     ((pte)->x != 0)
    5457
    5558#define SET_PTL0_ADDRESS(x)
  • genarch/include/mm/page_pt.h

    r6bf18fa rfb84455  
    9898#define PTE_PRESENT(p)          PTE_PRESENT_ARCH((p))
    9999#define PTE_GET_FRAME(p)        PTE_GET_FRAME_ARCH((p))
     100#define PTE_READABLE(p)         1
     101#define PTE_WRITABLE(p)         PTE_WRITABLE_ARCH((p))
     102#define PTE_EXECUTABLE(p)       PTE_EXECUTABLE_ARCH((p))
    100103
    101104extern page_mapping_operations_t pt_mapping_operations;
  • generic/include/mm/as.h

    r6bf18fa rfb84455  
    146146extern int as_area_get_flags(as_area_t *area);
    147147extern void as_set_mapping(as_t *as, __address page, __address frame);
     148extern bool as_area_check_access(as_area_t *area, pf_access_t access);
    148149extern int as_page_fault(__address page, pf_access_t access, istate_t *istate);
    149150extern void as_switch(as_t *old, as_t *new);
  • generic/src/lib/elf.c

    r6bf18fa rfb84455  
    236236        __address base, frame;
    237237        index_t i;
     238
     239        if (!as_area_check_access(area, access))
     240                return AS_PF_FAULT;
    238241
    239242        ASSERT((addr >= entry->p_vaddr) && (addr < entry->p_vaddr + entry->p_memsz));
  • generic/src/mm/as.c

    r6bf18fa rfb84455  
    633633}
    634634
     635/** Check access mode for address space area.
     636 *
     637 * The address space area must be locked prior to this call.
     638 *
     639 * @param area Address space area.
     640 * @param access Access mode.
     641 *
     642 * @return False if access violates area's permissions, true otherwise.
     643 */
     644bool as_area_check_access(as_area_t *area, pf_access_t access)
     645{
     646        int flagmap[] = {
     647                [PF_ACCESS_READ] = AS_AREA_READ,
     648                [PF_ACCESS_WRITE] = AS_AREA_WRITE,
     649                [PF_ACCESS_EXEC] = AS_AREA_EXEC
     650        };
     651
     652        if (!(area->flags & flagmap[access]))
     653                return false;
     654       
     655        return true;
     656}
     657
    635658/** Handle page fault within the current address space.
    636659 *
     
    699722        if ((pte = page_mapping_find(AS, page))) {
    700723                if (PTE_PRESENT(pte)) {
    701                         page_table_unlock(AS, false);
    702                         mutex_unlock(&area->lock);
    703                         mutex_unlock(&AS->lock);
    704                         return AS_PF_OK;
     724                        if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) ||
     725                                (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) ||
     726                                (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) {
     727                                page_table_unlock(AS, false);
     728                                mutex_unlock(&area->lock);
     729                                mutex_unlock(&AS->lock);
     730                                return AS_PF_OK;
     731                        }
    705732                }
    706733        }
     
    14961523        __address frame;
    14971524
     1525        if (!as_area_check_access(area, access))
     1526                return AS_PF_FAULT;
     1527
    14981528        if (area->sh_info) {
    14991529                btree_node_t *leaf;
Note: See TracChangeset for help on using the changeset viewer.