if (UVM_ET_ISSUBMAP(current)) return (KERN_INVALID_ARGUMENT);
if (UVM_ET_ISSUBMAP(current)) { rv = KERN_INVALID_ARGUMENT; goto out; }
uvm_map_protect(map, start, end, new_prot, set_max)	vm_map_t map;	vaddr_t start, end;	vm_prot_t new_prot;	boolean_t set_max;{	vm_map_entry_t current, entry;	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))			return (KERN_INVALID_ARGUMENT);		if ((new_prot & current->max_protection) != new_prot) {			vm_map_unlock(map);			return (KERN_PROTECTION_FAILURE);		}		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));		}		current = current->next;	}		vm_map_unlock(map);	UVMHIST_LOG(maphist, "<- done",0,0,0,0);	return(KERN_SUCCESS);}