From 54432196dbbd70b3e66a6b1f4010a3e5332ca7d7 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 23 Sep 2014 18:54:23 +0000 Subject: [PATCH] vm_map_pmap_enter() and pmap_enter_object() are currently not aware of the wired attribute of the mapping. As result, some pmap implementations clear the wired state of the page table entries, which breaks invariants and allows the entries to be lost. Avoid calling vm_map_pmap_enter() for the MADV_WILLNEED on the wired entry, the pages must be already mapped. Noted and reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/vm/vm_map.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 50929f6b833..b8d67bd30a3 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2197,7 +2197,14 @@ vm_map_madvise( vm_object_madvise(current->object.vm_object, pstart, pend, behav); - if (behav == MADV_WILLNEED) { + + /* + * Pre-populate paging structures in the + * WILLNEED case. For wired entries, the + * paging structures are already populated. + */ + if (behav == MADV_WILLNEED && + current->wired_count == 0) { vm_map_pmap_enter(map, useStart, current->protection,