MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_map_lookup

Function vm_map_lookup

freebsd/vm/vm_map.c:4940–5103  ·  view source on GitHub ↗

* vm_map_lookup: * * Finds the VM object, offset, and * protection for a given virtual address in the * specified map, assuming a page fault of the * type specified. * * Leaves the map in question locked for read; return * values are guaranteed until a vm_map_lookup_done * call is performed. Note that the map argument * is in/out; the returned map must be used in * the call to vm_map_l

Source from the content-addressed store, hash-verified

4938 * remain the same.
4939 */
4940int
4941vm_map_lookup(vm_map_t *var_map, /* IN/OUT */
4942 vm_offset_t vaddr,
4943 vm_prot_t fault_typea,
4944 vm_map_entry_t *out_entry, /* OUT */
4945 vm_object_t *object, /* OUT */
4946 vm_pindex_t *pindex, /* OUT */
4947 vm_prot_t *out_prot, /* OUT */
4948 boolean_t *wired) /* OUT */
4949{
4950 vm_map_entry_t entry;
4951 vm_map_t map = *var_map;
4952 vm_prot_t prot;
4953 vm_prot_t fault_type;
4954 vm_object_t eobject;
4955 vm_size_t size;
4956 struct ucred *cred;
4957
4958RetryLookup:
4959
4960 vm_map_lock_read(map);
4961
4962RetryLookupLocked:
4963 /*
4964 * Lookup the faulting address.
4965 */
4966 if (!vm_map_lookup_entry(map, vaddr, out_entry)) {
4967 vm_map_unlock_read(map);
4968 return (KERN_INVALID_ADDRESS);
4969 }
4970
4971 entry = *out_entry;
4972
4973 /*
4974 * Handle submaps.
4975 */
4976 if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) {
4977 vm_map_t old_map = map;
4978
4979 *var_map = map = entry->object.sub_map;
4980 vm_map_unlock_read(old_map);
4981 goto RetryLookup;
4982 }
4983
4984 /*
4985 * Check whether this task is allowed to have this page.
4986 */
4987 prot = entry->protection;
4988 if ((fault_typea & VM_PROT_FAULT_LOOKUP) != 0) {
4989 fault_typea &= ~VM_PROT_FAULT_LOOKUP;
4990 if (prot == VM_PROT_NONE && map != kernel_map &&
4991 (entry->eflags & MAP_ENTRY_GUARD) != 0 &&
4992 (entry->eflags & (MAP_ENTRY_STACK_GAP_DN |
4993 MAP_ENTRY_STACK_GAP_UP)) != 0 &&
4994 vm_map_growstack(map, vaddr, entry) == KERN_SUCCESS)
4995 goto RetryLookupLocked;
4996 }
4997 fault_type = fault_typea & VM_PROT_ALL;

Callers 4

umtx_key_getFunction · 0.85
umtx_shm_aliveFunction · 0.85
shm_unmapFunction · 0.85
vm_fault_lookupFunction · 0.85

Calls 8

vm_map_lookup_entryFunction · 0.85
vm_map_growstackFunction · 0.85
swap_reserve_by_credFunction · 0.85
vm_object_shadowFunction · 0.85
swap_release_by_credFunction · 0.85
vm_object_allocate_anonFunction · 0.85
crholdFunction · 0.50
crfreeFunction · 0.50

Tested by

no test coverage detected