summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2023-01-17 19:29:10 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2023-01-17 19:29:10 +0000
commitfca87f16c1710705e469972b31e9e3c320313f06 (patch)
tree56d0bf9433a4d1350cd699c4c3d082adfa98d027 /sys/arch/amd64/include
parent8241946210402a3e06a95e6c8367152817ca86ee (diff)
Simplify and clarify the implementation of the pmap_page_protect(9) API.
This function is only ever called with PROT_NONE or PROT_READ where PROT_NONE removes the mapping from the page tables and PROT_READ takes away write permission. Add a KASSERT to make sure no other values are passed. This KASSERT should be optimized away by any decent compiler. ok deraadt@, mpi@, guenther@
Diffstat (limited to 'sys/arch/amd64/include')
-rw-r--r--sys/arch/amd64/include/pmap.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/arch/amd64/include/pmap.h b/sys/arch/amd64/include/pmap.h
index e36c1f6f1c6..4cfd83eb244 100644
--- a/sys/arch/amd64/include/pmap.h
+++ b/sys/arch/amd64/include/pmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.h,v 1.82 2022/10/16 15:03:39 kettenis Exp $ */
+/* $OpenBSD: pmap.h,v 1.83 2023/01/17 19:29:09 kettenis Exp $ */
/* $NetBSD: pmap.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */
/*
@@ -70,6 +70,7 @@
#ifndef _LOCORE
#ifdef _KERNEL
+#include <lib/libkern/libkern.h> /* for KASSERT() */
#include <machine/cpufunc.h>
#endif /* _KERNEL */
#include <sys/mutex.h>
@@ -455,12 +456,11 @@ pmap_update_pg(vaddr_t va)
static inline void
pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
{
- if ((prot & PROT_WRITE) == 0) {
- if (prot & (PROT_READ | PROT_EXEC)) {
- (void) pmap_clear_attrs(pg, PG_RW);
- } else {
- pmap_page_remove(pg);
- }
+ if (prot == PROT_READ) {
+ (void) pmap_clear_attrs(pg, PG_RW);
+ } else {
+ KASSERT(prot == PROT_NONE);
+ pmap_page_remove(pg);
}
}