-/* $OpenBSD: pmap.c,v 1.91 2022/12/10 10:13:58 patrick Exp $ */
+/* $OpenBSD: pmap.c,v 1.92 2023/01/11 11:09:17 kettenis Exp $ */
/*
* Copyright (c) 2008-2009,2014-2016 Dale Rahn <drahn@dalerahn.com>
*
}
const uint64_t ap_bits_user[8] = {
- [PROT_NONE] = ATTR_PXN|ATTR_UXN|ATTR_AP(2),
+ [PROT_NONE] = 0,
[PROT_READ] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(3),
[PROT_WRITE] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(1),
[PROT_WRITE|PROT_READ] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(1),
};
const uint64_t ap_bits_kern[8] = {
- [PROT_NONE] = ATTR_PXN|ATTR_UXN|ATTR_AP(2),
+ [PROT_NONE] = 0,
[PROT_READ] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(2),
[PROT_WRITE] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(0),
[PROT_WRITE|PROT_READ] = ATTR_PXN|ATTR_UXN|ATTR_AF|ATTR_AP(0),
pted->pted_va &= ~PROT_WRITE;
pted->pted_pte &= ~PROT_WRITE;
+ if ((prot & PROT_READ) == 0) {
+ pted->pted_va &= ~PROT_READ;
+ pted->pted_pte &= ~PROT_READ;
+ }
if ((prot & PROT_EXEC) == 0) {
pted->pted_va &= ~PROT_EXEC;
pted->pted_pte &= ~PROT_EXEC;
/*
* Lower the protection on the specified physical page.
- *
- * There are only two cases, either the protection is going to 0,
- * or it is going to read-only.
*/
void
pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
access_bits = ap_bits_user[pted->pted_pte & PROT_MASK];
pte = (pted->pted_pte & PTE_RPGN) | attr | access_bits | L3_P;
- *pl3 = pte;
+ *pl3 = access_bits ? pte : 0;
}
void