//kernel/trunk/genarch/include/mm/page_pt.h |
---|
97,6 → 97,9 |
#define PTE_VALID(p) PTE_VALID_ARCH((p)) |
#define PTE_PRESENT(p) PTE_PRESENT_ARCH((p)) |
#define PTE_GET_FRAME(p) PTE_GET_FRAME_ARCH((p)) |
#define PTE_READABLE(p) 1 |
#define PTE_WRITABLE(p) PTE_WRITABLE_ARCH((p)) |
#define PTE_EXECUTABLE(p) PTE_EXECUTABLE_ARCH((p)) |
extern page_mapping_operations_t pt_mapping_operations; |
//kernel/trunk/genarch/include/mm/page_ht.h |
---|
51,6 → 51,9 |
#define PTE_VALID(pte) ((pte) != NULL) |
#define PTE_PRESENT(pte) ((pte)->p != 0) |
#define PTE_GET_FRAME(pte) ((pte)->frame) |
#define PTE_READABLE(pte) 1 |
#define PTE_WRITABLE(pte) ((pte)->w != 0) |
#define PTE_EXECUTABLE(pte) ((pte)->x != 0) |
#define SET_PTL0_ADDRESS(x) |
//kernel/trunk/generic/include/mm/as.h |
---|
145,6 → 145,7 |
extern int as_area_destroy(as_t *as, __address address); |
extern int as_area_get_flags(as_area_t *area); |
extern void as_set_mapping(as_t *as, __address page, __address frame); |
extern bool as_area_check_access(as_area_t *area, pf_access_t access); |
extern int as_page_fault(__address page, pf_access_t access, istate_t *istate); |
extern void as_switch(as_t *old, as_t *new); |
extern void as_free(as_t *as); |
//kernel/trunk/generic/src/lib/elf.c |
---|
236,6 → 236,9 |
__address base, frame; |
index_t i; |
if (!as_area_check_access(area, access)) |
return AS_PF_FAULT; |
ASSERT((addr >= entry->p_vaddr) && (addr < entry->p_vaddr + entry->p_memsz)); |
i = (addr - entry->p_vaddr) >> PAGE_WIDTH; |
base = (__address) (((void *) elf) + entry->p_offset); |
//kernel/trunk/generic/src/mm/as.c |
---|
632,6 → 632,29 |
interrupts_restore(ipl); |
} |
/** Check access mode for address space area. |
* |
* The address space area must be locked prior to this call. |
* |
* @param area Address space area. |
* @param access Access mode. |
* |
* @return False if access violates area's permissions, true otherwise. |
*/ |
bool as_area_check_access(as_area_t *area, pf_access_t access) |
{ |
int flagmap[] = { |
[PF_ACCESS_READ] = AS_AREA_READ, |
[PF_ACCESS_WRITE] = AS_AREA_WRITE, |
[PF_ACCESS_EXEC] = AS_AREA_EXEC |
}; |
if (!(area->flags & flagmap[access])) |
return false; |
return true; |
} |
/** Handle page fault within the current address space. |
* |
* This is the high-level page fault handler. It decides |
698,6 → 721,9 |
*/ |
if ((pte = page_mapping_find(AS, page))) { |
if (PTE_PRESENT(pte)) { |
if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) || |
(access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) || |
(access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) { |
page_table_unlock(AS, false); |
mutex_unlock(&area->lock); |
mutex_unlock(&AS->lock); |
704,6 → 730,7 |
return AS_PF_OK; |
} |
} |
} |
/* |
* Resort to the backend page fault handler. |
1495,6 → 1522,9 |
{ |
__address frame; |
if (!as_area_check_access(area, access)) |
return AS_PF_FAULT; |
if (area->sh_info) { |
btree_node_t *leaf; |
//kernel/trunk/arch/ppc32/include/mm/page.h |
---|
91,6 → 91,8 |
#define PTE_VALID_ARCH(pte) (*((__u32 *) (pte)) != 0) |
#define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) |
#define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn << 12) |
#define PTE_WRITABLE_ARCH(pte) 1 |
#define PTE_EXECUTABLE_ARCH(pte) 1 |
#ifndef __ASM__ |
//kernel/trunk/arch/amd64/include/mm/page.h |
---|
103,6 → 103,8 |
#define PTE_VALID_ARCH(p) (*((__u64 *) (p)) != 0) |
#define PTE_PRESENT_ARCH(p) ((p)->present != 0) |
#define PTE_GET_FRAME_ARCH(p) ((((__address)(p)->addr_12_31)<<12) | ((__address)(p)->addr_32_51<<32)) |
#define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0) |
#define PTE_EXECUTABLE_ARCH(p) ((p)->no_execute == 0) |
#ifndef __ASM__ |
//kernel/trunk/arch/ppc64/include/mm/page.h |
---|
90,7 → 90,9 |
#define PTE_VALID_ARCH(pte) (*((__u32 *) (pte)) != 0) |
#define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) |
#define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn << 12) |
#define PTE_GET_FRAME_ARCH(pte) ((__address) ((pte)->pfn << 12)) |
#define PTE_WRITABLE_ARCH(pte) 1 |
#define PTE_EXECUTABLE_ARCH(pte) 1 |
#ifndef __ASM__ |
//kernel/trunk/arch/mips32/include/mm/page.h |
---|
97,6 → 97,8 |
#define PTE_VALID_ARCH(pte) (*((__u32 *) (pte)) != 0) |
#define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) |
#define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn<<12) |
#define PTE_WRITABLE_ARCH(pte) ((pte)->w != 0) |
#define PTE_EXECUTABLE_ARCH(pte) 1 |
#ifndef __ASM__ |
//kernel/trunk/arch/ia32/include/mm/page.h |
---|
82,6 → 82,8 |
#define PTE_VALID_ARCH(p) (*((__u32 *) (p)) != 0) |
#define PTE_PRESENT_ARCH(p) ((p)->present != 0) |
#define PTE_GET_FRAME_ARCH(p) ((p)->frame_address<<FRAME_WIDTH) |
#define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0) |
#define PTE_EXECUTABLE_ARCH(p) 1 |
#ifndef __ASM__ |