Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm Rework uvm_map_protect():



details:   https://anonhg.NetBSD.org/src/rev/82a8f8a8182e
branches:  trunk
changeset: 474739:82a8f8a8182e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jul 18 00:41:56 1999 +0000

description:
Rework uvm_map_protect():
- Fix some locking bugs; a couple of places would return an error condition
  without unlocking the map.
- Deal with maps marked WIREFUTURE; if making an entry VM_PROT_NONE ->
  anything else, and it is not already marked as wired, wire it.

diffstat:

 sys/uvm/uvm_map.c |  53 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 43 insertions(+), 10 deletions(-)

diffs (91 lines):

diff -r 81cd4d3e4518 -r 82a8f8a8182e sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Jul 17 22:39:18 1999 +0000
+++ b/sys/uvm/uvm_map.c Sun Jul 18 00:41:56 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.64 1999/07/17 21:35:49 thorpej Exp $     */
+/*     $NetBSD: uvm_map.c,v 1.65 1999/07/18 00:41:56 thorpej Exp $     */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -1721,6 +1721,7 @@
        boolean_t set_max;
 {
        vm_map_entry_t current, entry;
+       int rv = KERN_SUCCESS;
        UVMHIST_FUNC("uvm_map_protect"); UVMHIST_CALLED(maphist);
        UVMHIST_LOG(maphist,"(map=0x%x,start=0x%x,end=0x%x,new_prot=0x%x)",
        map, start, end, new_prot);
@@ -1741,13 +1742,15 @@
 
        current = entry;
        while ((current != &map->header) && (current->start < end)) {
-               if (UVM_ET_ISSUBMAP(current))
-                       return (KERN_INVALID_ARGUMENT);
+               if (UVM_ET_ISSUBMAP(current)) {
+                       rv = KERN_INVALID_ARGUMENT;
+                       goto out;
+               }
                if ((new_prot & current->max_protection) != new_prot) {
-                       vm_map_unlock(map);
-                       return (KERN_PROTECTION_FAILURE);
+                       rv = KERN_PROTECTION_FAILURE;
+                       goto out;
                }
-                       current = current->next;
+               current = current->next;
        }
 
        /* go back and fix up protections (no need to clip this time). */
@@ -1772,18 +1775,48 @@
                 */
 
                if (current->protection != old_prot) {
-
                        /* update pmap! */
                        pmap_protect(map->pmap, current->start, current->end,
                            current->protection & MASK(entry));
-
                }
+
+               /*
+                * If the map is configured to lock any future mappings,
+                * wire this entry now if the old protection was VM_PROT_NONE
+                * and the new protection is not VM_PROT_NONE.
+                */
+
+               if ((map->flags & VM_MAP_WIREFUTURE) != 0 &&
+                   VM_MAPENT_ISWIRED(entry) == 0 &&
+                   old_prot == VM_PROT_NONE &&
+                   new_prot != VM_PROT_NONE) {
+                       if (uvm_map_pageable(map, entry->start,
+                           entry->end, FALSE,
+                           UVM_LK_ENTER|UVM_LK_EXIT) != KERN_SUCCESS) {
+                               /*
+                                * If locking the entry fails, remember the
+                                * error if it's the first one.  Note we
+                                * still continue setting the protection in
+                                * the map, but will return the resource
+                                * shortage condition regardless.
+                                *
+                                * XXX Ignore what the actual error is,
+                                * XXX just call it a resource shortage
+                                * XXX so that it doesn't get confused
+                                * XXX what uvm_map_protect() itself would
+                                * XXX normally return.
+                                */
+                               rv = KERN_RESOURCE_SHORTAGE;
+                       }
+               }
+
                current = current->next;
        }
        
+ out:
        vm_map_unlock(map);
-       UVMHIST_LOG(maphist, "<- done",0,0,0,0);
-       return(KERN_SUCCESS);
+       UVMHIST_LOG(maphist, "<- done, rv=%d",rv,0,0,0);
+       return (rv);
 }
 
 #undef  max



Home | Main Index | Thread Index | Old Index