FreeBSD/sys/kern/kern_umtx.c
/*
 * Convert userspace address into unique logical address.
 */
Convert userspace address into unique logical address.
Convert userspace address into unique logical address .
int
umtx_key_get(const void *addr, int type, int share, struct umtx_key *key)
{
	struct thread *td = curthread;
	vm_map_t map;
	vm_map_entry_t entry;
	vm_pindex_t pindex;
	vm_prot_t prot;
	boolean_t wired;
	key->type = type;
	if (share == THREAD_SHARE) {
		key->shared = 0;
		key->info.private.vs = td->td_proc->p_vmspace;
		key->info.private.addr = (uintptr_t)addr;
	} else {
		MPASS(share == PROCESS_SHARE || share == AUTO_SHARE);
		map = &td->td_proc->p_vmspace->vm_map;
		if (vm_map_lookup(&map, (vm_offset_t)addr, VM_PROT_WRITE,
		    &entry, &key->info.shared.object, &pindex, &prot,
		    &wired) != KERN_SUCCESS) {
			return (EFAULT);
		}
		if ((share == PROCESS_SHARE) ||
		    (share == AUTO_SHARE &&
		     VM_INHERIT_SHARE == entry->inheritance)) {
			key->shared = 1;
			key->info.shared.offset = (vm_offset_t)addr -
			    entry->start + entry->offset;
			vm_object_reference(key->info.shared.object);
		} else {
			key->shared = 0;
			key->info.private.vs = td->td_proc->p_vmspace;
			key->info.private.addr = (uintptr_t)addr;
		}
		vm_map_lookup_done(map, entry);
	}
	umtxq_hash(key);
	return (0);
}
int umtx_key_get ( const void * addr , int type , int share , struct umtx_key * key ) { struct thread * td = curthread ; vm_map_t map ; vm_map_entry_t entry ; vm_pindex_t pindex ; vm_prot_t prot ; boolean_t wired ; key -> type = type ; if ( share == THREAD_SHARE ) { key -> shared = 0 ; key -> info . private . vs = td -> td_proc -> p_vmspace ; key -> info . private . addr = ( uintptr_t ) addr ; } else { MPASS ( share == PROCESS_SHARE || share == AUTO_SHARE ) ; map = & td -> td_proc -> p_vmspace -> vm_map ; if ( vm_map_lookup ( & map , ( vm_offset_t ) addr , VM_PROT_WRITE , & entry , & key -> info . shared . object , & pindex , & prot , & wired ) != KERN_SUCCESS ) { return ( EFAULT ) ; } if ( ( share == PROCESS_SHARE ) || ( share == AUTO_SHARE && VM_INHERIT_SHARE == entry -> inheritance ) ) { key -> shared = 1 ; key -> info . shared . offset = ( vm_offset_t ) addr - entry -> start + entry -> offset ; vm_object_reference ( key -> info . shared . object ) ; } else { key -> shared = 0 ; key -> info . private . vs = td -> td_proc -> p_vmspace ; key -> info . private . addr = ( uintptr_t ) addr ; } vm_map_lookup_done ( map , entry ) ; } umtxq_hash ( key ) ; return ( 0 ) ; }
Convert userspace address into unique logical address.
Convert userspace address into unique logical address .