diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2002-07-15 17:01:27 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2002-07-15 17:01:27 +0000 |
commit | a5c62c10ddfb67b500526130156e9332227c562e (patch) | |
tree | 5d62cbede41f66a94e66ba19c983ffbafb8a9dec | |
parent | b6ebd148dd8af361a1838a8ca3dbf4edd9db95a7 (diff) |
Perform accounting for executable pages on powerpc, prepare for
non-executeable stack.
-rw-r--r-- | sys/arch/powerpc/include/pmap.h | 3 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/pmap.c | 31 |
2 files changed, 28 insertions, 6 deletions
diff --git a/sys/arch/powerpc/include/pmap.h b/sys/arch/powerpc/include/pmap.h index 7762e98f6de..3e3066c8632 100644 --- a/sys/arch/powerpc/include/pmap.h +++ b/sys/arch/powerpc/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.26 2002/07/12 20:28:55 drahn Exp $ */ +/* $OpenBSD: pmap.h,v 1.27 2002/07/15 17:01:26 drahn Exp $ */ /* $NetBSD: pmap.h,v 1.1 1996/09/30 16:34:29 ws Exp $ */ /*- @@ -84,6 +84,7 @@ void pmap_kenter_cache( vaddr_t va, paddr_t pa, vm_prot_t prot, int cacheable); struct pmap { sr_t pm_sr[16]; /* segments used in this pmap */ struct pmapvp *pm_vp[VP_SR_SIZE]; /* virtual to physical table */ + u_int32_t pm_exec[16]; /* segments used in this pmap */ int pm_refs; /* ref count */ struct pmap_statistics pm_stats; /* pmap statistics */ }; diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c index 9cf70c14b19..be9e5d169d1 100644 --- a/sys/arch/powerpc/powerpc/pmap.c +++ b/sys/arch/powerpc/powerpc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.71 2002/07/12 20:28:55 drahn Exp $ */ +/* $OpenBSD: pmap.c,v 1.72 2002/07/15 17:01:25 drahn Exp $ */ /* * Copyright (c) 2001, 2002 Dale Rahn. All rights reserved. @@ -344,10 +344,11 @@ pteidx(sr_t sr, vaddr_t va) return hash & pmap_ptab_mask; } -#define PTED_VA_PTEGIDX_M 0x07 -#define PTED_VA_HID_M 0x08 -#define PTED_VA_MANAGED_M 0x10 -#define PTED_VA_WIRED_M 0x20 +#define PTED_VA_PTEGIDX_M 0x07 +#define PTED_VA_HID_M 0x08 +#define PTED_VA_MANAGED_M 0x10 +#define PTED_VA_WIRED_M 0x20 +#define PTED_VA_EXEC_M 0x40 static inline u_int32_t PTED_HID(struct pte_desc *pted) @@ -496,6 +497,9 @@ pmap_enter(pm, va, pa, prot, flags) */ pte_insert(pted); + if (prot & VM_PROT_EXECUTE) + pm->pm_exec[va >> ADDR_SR_SHIFT]++; + splx(s); /* only instruction sync executable pages */ @@ -598,6 +602,11 @@ pmap_remove_pg(pmap_t pm, vaddr_t va) pmap_hash_remove(pted); + if (pted->pted_va & PTED_VA_EXEC_M) { + pm->pm_exec[pted->pted_va >> ADDR_SR_SHIFT]--; + pted->pted_va &= ~PTED_VA_EXEC_M; + } + pted->pted_pte.pte_hi &= ~PTE_VALID; if (PTED_MANAGED(pted)) @@ -666,6 +675,9 @@ _pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot, int flags, int cache) pte_insert(pted); pted->pted_va |= PTED_VA_WIRED_M; + if (prot & VM_PROT_EXECUTE) + pm->pm_exec[va >> ADDR_SR_SHIFT]++; + splx(s); } @@ -712,6 +724,11 @@ pmap_kremove_pg(vaddr_t va) */ pmap_hash_remove(pted); + if (pted->pted_va & PTED_VA_EXEC_M) { + pm->pm_exec[pted->pted_va >> ADDR_SR_SHIFT]--; + pted->pted_va &= ~PTED_VA_EXEC_M; + } + if (PTED_MANAGED(pted)) pmap_remove_pv(pted); @@ -807,6 +824,10 @@ pmap_fill_pte(pmap_t pm, vaddr_t va, paddr_t pa, struct pte_desc *pted, pte->pte_lo |= PTE_RO; pted->pted_va = va & ~PAGE_MASK; + + if (prot & VM_PROT_EXECUTE) + pted->pted_va |= PTED_VA_EXEC_M; + pted->pted_pmap = pm; } |