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

Function vm_map_inherit

freebsd/vm/vm_map.c:3146–3197  ·  view source on GitHub ↗

* vm_map_inherit: * * Sets the inheritance of the specified address * range in the target map. Inheritance * affects how the map will be shared with * child maps at the time of vmspace_fork. */

Source from the content-addressed store, hash-verified

3144 * child maps at the time of vmspace_fork.
3145 */
3146int
3147vm_map_inherit(vm_map_t map, vm_offset_t start, vm_offset_t end,
3148 vm_inherit_t new_inheritance)
3149{
3150 vm_map_entry_t entry, lentry, prev_entry, start_entry;
3151 int rv;
3152
3153 switch (new_inheritance) {
3154 case VM_INHERIT_NONE:
3155 case VM_INHERIT_COPY:
3156 case VM_INHERIT_SHARE:
3157 case VM_INHERIT_ZERO:
3158 break;
3159 default:
3160 return (KERN_INVALID_ARGUMENT);
3161 }
3162 if (start == end)
3163 return (KERN_SUCCESS);
3164 vm_map_lock(map);
3165 VM_MAP_RANGE_CHECK(map, start, end);
3166 rv = vm_map_lookup_clip_start(map, start, &start_entry, &prev_entry);
3167 if (rv != KERN_SUCCESS)
3168 goto unlock;
3169 if (vm_map_lookup_entry(map, end - 1, &lentry)) {
3170 rv = vm_map_clip_end(map, lentry, end);
3171 if (rv != KERN_SUCCESS)
3172 goto unlock;
3173 }
3174 if (new_inheritance == VM_INHERIT_COPY) {
3175 for (entry = start_entry; entry->start < end;
3176 prev_entry = entry, entry = vm_map_entry_succ(entry)) {
3177 if ((entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK)
3178 != 0) {
3179 rv = KERN_INVALID_ARGUMENT;
3180 goto unlock;
3181 }
3182 }
3183 }
3184 for (entry = start_entry; entry->start < end; prev_entry = entry,
3185 entry = vm_map_entry_succ(entry)) {
3186 KASSERT(entry->end <= end, ("non-clipped entry %p end %jx %jx",
3187 entry, (uintmax_t)entry->end, (uintmax_t)end));
3188 if ((entry->eflags & MAP_ENTRY_GUARD) == 0 ||
3189 new_inheritance != VM_INHERIT_ZERO)
3190 entry->inheritance = new_inheritance;
3191 vm_map_try_merge_entries(map, prev_entry, entry);
3192 }
3193 vm_map_try_merge_entries(map, prev_entry, entry);
3194unlock:
3195 vm_map_unlock(map);
3196 return (rv);
3197}
3198
3199/*
3200 * vm_map_entry_in_transition:

Callers 1

kern_minheritFunction · 0.85

Calls 5

vm_map_lookup_clip_startFunction · 0.85
vm_map_lookup_entryFunction · 0.85
vm_map_clip_endFunction · 0.85
vm_map_entry_succFunction · 0.85
vm_map_try_merge_entriesFunction · 0.85

Tested by

no test coverage detected