pmap_update(map->pmap);
uvm_map_protect(map, start, end, new_prot, set_max)	struct vm_map *map;	vaddr_t start, end;	vm_prot_t new_prot;	boolean_t set_max;{	struct vm_map_entry *current, *entry;	int error = 0;	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);	vm_map_lock(map);	VM_MAP_RANGE_CHECK(map, start, end);	if (uvm_map_lookup_entry(map, start, &entry)) {		UVM_MAP_CLIP_START(map, entry, start);	} else {		entry = entry->next;	}	/*	 * make a first pass to check for protection violations.	 */	current = entry;	while ((current != &map->header) && (current->start < end)) {		if (UVM_ET_ISSUBMAP(current)) {			error = EINVAL;			goto out;		}		if ((new_prot & current->max_protection) != new_prot) {			error = EACCES;			goto out;		}		current = current->next;	}	/* go back and fix up protections (no need to clip this time). */	current = entry;	while ((current != &map->header) && (current->start < end)) {		vm_prot_t old_prot;		UVM_MAP_CLIP_END(map, current, end);		old_prot = current->protection;		if (set_max)			current->protection =			    (current->max_protection = new_prot) & old_prot;		else			current->protection = new_prot;		/*		 * update physical map if necessary.  worry about copy-on-write		 * here -- CHECK THIS XXX		 */		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) != 0) {				/*				 * 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 error				 * 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.				 */				error = ENOMEM;			}		}		current = current->next;	}	pmap_update(map->pmap); out:	vm_map_unlock(map);	UVMHIST_LOG(maphist, "<- done, error=%d",error,0,0,0);	return error;}