-/* $OpenBSD: pmap.c,v 1.156 2022/11/29 21:41:39 guenther Exp $ */
+/* $OpenBSD: pmap.c,v 1.157 2023/01/19 20:17:11 kettenis Exp $ */
/* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */
/*
void
pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
{
- pt_entry_t nx, *spte, *epte;
+ pt_entry_t *spte, *epte;
+ pt_entry_t clear = 0, set = 0;
vaddr_t blockend;
int shootall = 0, shootself;
vaddr_t va;
sva &= PG_FRAME;
eva &= PG_FRAME;
- nx = 0;
+ if (!(prot & PROT_WRITE))
+ clear = PG_RW;
if (!(prot & PROT_EXEC))
- nx = pg_nx;
+ set |= pg_nx;
if ((eva - sva > 32 * PAGE_SIZE) && sva < VM_MIN_KERNEL_ADDRESS)
shootall = 1;
for (/*null */; spte < epte ; spte++) {
if (!pmap_valid_entry(*spte))
continue;
- pmap_pte_clearbits(spte, PG_RW);
- pmap_pte_setbits(spte, nx);
+ pmap_pte_clearbits(spte, clear);
+ pmap_pte_setbits(spte, set);
}
}
-/* $OpenBSD: pmap.h,v 1.83 2023/01/17 19:29:09 kettenis Exp $ */
+/* $OpenBSD: pmap.h,v 1.84 2023/01/19 20:17:12 kettenis Exp $ */
/* $NetBSD: pmap.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */
/*
static inline void
pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
{
- if ((prot & PROT_WRITE) == 0) {
- if (prot & (PROT_READ| PROT_EXEC)) {
- pmap_write_protect(pmap, sva, eva, prot);
- } else {
- pmap_remove(pmap, sva, eva);
- }
+ if (prot != PROT_NONE) {
+ pmap_write_protect(pmap, sva, eva, prot);
+ } else {
+ pmap_remove(pmap, sva, eva);
}
}