The current pmap_enter() implementation always enters PROT_WRITE
mappings as read-only and relies on pmap_fault_fixup() to fix this up.
This is obviously not the intention, since we do go through the
trouble of checking whether we have to do modified bit emulation.
The diff below fixes this.
ok?
Index: pmap7.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/pmap7.c,v
retrieving revision 1.42
diff -u -p -r1.42 pmap7.c
--- pmap7.c 19 Aug 2016 17:31:04 -0000 1.42
+++ pmap7.c 20 Aug 2016 08:47:19 -0000
@@ -1165,9 +1165,8 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
nflags |= PVF_REF;
npte |= L2_V7_AF;
- if ((prot & PROT_WRITE) != 0 &&
- ((flags & PROT_WRITE) != 0 ||
- (pg->mdpage.pvh_attrs & PVF_MOD) != 0)) {
+ if ((flags & PROT_WRITE) ||
+ (pg->mdpage.pvh_attrs & PVF_MOD)) {
/*
* This is a writable mapping, and the
* page's mod state indicates it has
@@ -1175,6 +1174,8 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
* writable from the outset.
*/
nflags |= PVF_MOD;
+ } else {
+ prot &= ~PROT_WRITE;
}
} else {
/*
@@ -1241,8 +1242,7 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
/*
* Make sure userland mappings get the right permissions
*/
- npte |= L2_S_PROT(pm == pmap_kernel() ? PTE_KERNEL : PTE_USER,
- prot & ~PROT_WRITE);
+ npte |= L2_S_PROT(pm == pmap_kernel() ? PTE_KERNEL : PTE_USER, prot);
/*
* Keep the stats up to date