summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-09-01 12:08:18 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-09-01 12:08:18 +0000
commit42abdac3c3fbea4d53bcab7bcc10a55b0e07b0e7 (patch)
tree362f69225d02ba9e606645c26e33847318a17a69 /sys
parent364091aa5ad8b3c8020de961122e6ec80a098dd7 (diff)
In pmap_protect(), compute the bitmask to set in the ptes only once, instead
of every iteration.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sh/sh/pmap.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c
index 7bcd4e0644b..2fbb24c9b6c 100644
--- a/sys/arch/sh/sh/pmap.c
+++ b/sys/arch/sh/sh/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.7 2007/06/21 04:41:21 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.8 2007/09/01 12:08:17 miod Exp $ */
/* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */
/*-
@@ -618,7 +618,7 @@ void
pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
{
boolean_t kernel = pmap == pmap_kernel();
- pt_entry_t *pte, entry;
+ pt_entry_t *pte, entry, protbits;
vaddr_t va;
paddr_t pa;
struct vm_page *pg;
@@ -632,6 +632,22 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
return;
}
+ switch (prot) {
+ default:
+ panic("pmap_protect: invalid protection mode %x", prot);
+ /* NOTREACHED */
+ case VM_PROT_READ:
+ /* FALLTHROUGH */
+ case VM_PROT_READ | VM_PROT_EXECUTE:
+ protbits = kernel ? PG_PR_KRO : PG_PR_URO;
+ break;
+ case VM_PROT_READ | VM_PROT_WRITE:
+ /* FALLTHROUGH */
+ case VM_PROT_ALL:
+ protbits = kernel ? PG_PR_KRW : PG_PR_URW;
+ break;
+ }
+
for (va = sva; va < eva; va += PAGE_SIZE) {
if (((pte = __pmap_pte_lookup(pmap, va)) == NULL) ||
@@ -645,22 +661,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
sh_dcache_wbinv_range_index(va, PAGE_SIZE);
}
- entry &= ~PG_PR_MASK;
- switch (prot) {
- default:
- panic("pmap_protect: invalid protection mode %x", prot);
- /* NOTREACHED */
- case VM_PROT_READ:
- /* FALLTHROUGH */
- case VM_PROT_READ | VM_PROT_EXECUTE:
- entry |= kernel ? PG_PR_KRO : PG_PR_URO;
- break;
- case VM_PROT_READ | VM_PROT_WRITE:
- /* FALLTHROUGH */
- case VM_PROT_ALL:
- entry |= kernel ? PG_PR_KRW : PG_PR_URW;
- break;
- }
+ entry = (entry & ~PG_PR_MASK) | protbits;
*pte = entry;
if (pmap->pm_asid != -1)
@@ -1035,7 +1036,7 @@ __pmap_pte_load(pmap_t pmap, vaddr_t va, int flags)
/*
* int __pmap_asid_alloc(void):
- * Allocate new ASID. if all ASID is used, steal from other process.
+ * Allocate new ASID. if all ASID are used, steal from other process.
*/
int
__pmap_asid_alloc()