Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Use UVM_PROT_ALL only if UVM_KMF_EXEC is given as ar...
details: https://anonhg.NetBSD.org/src/rev/9f25819fcccb
branches: trunk
changeset: 346683:9f25819fcccb
user: maxv <maxv%NetBSD.org@localhost>
date: Wed Jul 27 16:45:00 2016 +0000
description:
Use UVM_PROT_ALL only if UVM_KMF_EXEC is given as argument. Otherwise, if
UVM_KMF_PAGEABLE is also given as argument, only the VA is allocated and
UVM waits for the page to fault before kentering it. When kentering it, it
will use the UVM_PROT_ flag that was passed to uvm_map; which means that it
will kenter it as RWX.
With this change, the number of RWX pages in the amd64 kernel reaches
strictly zero.
diffstat:
sys/uvm/uvm_km.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (38 lines):
diff -r 502fcc259dba -r 9f25819fcccb sys/uvm/uvm_km.c
--- a/sys/uvm/uvm_km.c Wed Jul 27 13:04:28 2016 +0000
+++ b/sys/uvm/uvm_km.c Wed Jul 27 16:45:00 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.c,v 1.140 2016/07/20 12:38:43 maxv Exp $ */
+/* $NetBSD: uvm_km.c,v 1.141 2016/07/27 16:45:00 maxv Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -152,7 +152,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.140 2016/07/20 12:38:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.141 2016/07/27 16:45:00 maxv Exp $");
#include "opt_uvmhist.h"
@@ -593,7 +593,7 @@
struct vm_page *pg;
struct uvm_object *obj;
int pgaflags;
- vm_prot_t prot;
+ vm_prot_t prot, vaprot;
UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist);
KASSERT(vm_map_pmap(map) == pmap_kernel());
@@ -617,8 +617,9 @@
* allocate some virtual space
*/
+ vaprot = (flags & UVM_KMF_EXEC) ? UVM_PROT_ALL : UVM_PROT_RW;
if (__predict_false(uvm_map(map, &kva, size, obj, UVM_UNKNOWN_OFFSET,
- align, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
+ align, UVM_MAPFLAG(vaprot, UVM_PROT_ALL, UVM_INH_NONE,
UVM_ADV_RANDOM,
(flags & (UVM_KMF_TRYLOCK | UVM_KMF_NOWAIT | UVM_KMF_WAITVA
| UVM_KMF_COLORMATCH)))) != 0)) {
Home |
Main Index |
Thread Index |
Old Index