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

Function vm_map_insert

freebsd/vm/vm_map.c:1646–1864  ·  view source on GitHub ↗

* vm_map_insert: * * Inserts the given whole VM object into the target * map at the specified address range. The object's * size should match that of the address range. * * Requires that the map be locked, and leaves it so. * * If object is non-NULL, ref count must be bumped by caller * prior to making call to account for the new entry. */

Source from the content-addressed store, hash-verified

1644 * prior to making call to account for the new entry.
1645 */
1646int
1647vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
1648 vm_offset_t start, vm_offset_t end, vm_prot_t prot, vm_prot_t max, int cow)
1649{
1650 vm_map_entry_t new_entry, next_entry, prev_entry;
1651 struct ucred *cred;
1652 vm_eflags_t protoeflags;
1653 vm_inherit_t inheritance;
1654 u_long bdry;
1655 u_int bidx;
1656
1657 VM_MAP_ASSERT_LOCKED(map);
1658 KASSERT(object != kernel_object ||
1659 (cow & MAP_COPY_ON_WRITE) == 0,
1660 ("vm_map_insert: kernel object and COW"));
1661 KASSERT(object == NULL || (cow & MAP_NOFAULT) == 0 ||
1662 (cow & MAP_SPLIT_BOUNDARY_MASK) != 0,
1663 ("vm_map_insert: paradoxical MAP_NOFAULT request, obj %p cow %#x",
1664 object, cow));
1665 KASSERT((prot & ~max) == 0,
1666 ("prot %#x is not subset of max_prot %#x", prot, max));
1667
1668 /*
1669 * Check that the start and end points are not bogus.
1670 */
1671 if (start == end || !vm_map_range_valid(map, start, end))
1672 return (KERN_INVALID_ADDRESS);
1673
1674 if ((map->flags & MAP_WXORX) != 0 && (prot & (VM_PROT_WRITE |
1675 VM_PROT_EXECUTE)) == (VM_PROT_WRITE | VM_PROT_EXECUTE))
1676 return (KERN_PROTECTION_FAILURE);
1677
1678 /*
1679 * Find the entry prior to the proposed starting address; if it's part
1680 * of an existing entry, this range is bogus.
1681 */
1682 if (vm_map_lookup_entry(map, start, &prev_entry))
1683 return (KERN_NO_SPACE);
1684
1685 /*
1686 * Assert that the next entry doesn't overlap the end point.
1687 */
1688 next_entry = vm_map_entry_succ(prev_entry);
1689 if (next_entry->start < end)
1690 return (KERN_NO_SPACE);
1691
1692 if ((cow & MAP_CREATE_GUARD) != 0 && (object != NULL ||
1693 max != VM_PROT_NONE))
1694 return (KERN_INVALID_ARGUMENT);
1695
1696 protoeflags = 0;
1697 if (cow & MAP_COPY_ON_WRITE)
1698 protoeflags |= MAP_ENTRY_COW | MAP_ENTRY_NEEDS_COPY;
1699 if (cow & MAP_NOFAULT)
1700 protoeflags |= MAP_ENTRY_NOFAULT;
1701 if (cow & MAP_DISABLE_SYNCER)
1702 protoeflags |= MAP_ENTRY_NOSYNC;
1703 if (cow & MAP_DISABLE_COREDUMP)

Callers 11

exec_aout_imgactFunction · 0.85
shm_mmap_largeFunction · 0.85
kmapent_allocFunction · 0.85
vm_map_fixedFunction · 0.85
vm_map_findFunction · 0.85
vm_map_stack_lockedFunction · 0.85
vm_map_growstackFunction · 0.85
kern_breakFunction · 0.85
kmap_alloc_waitFunction · 0.85
kmem_initFunction · 0.85
uma_startup2Function · 0.85

Calls 14

vm_map_range_validFunction · 0.85
vm_map_lookup_entryFunction · 0.85
vm_map_entry_succFunction · 0.85
swap_reserveFunction · 0.85
vm_object_clear_flagFunction · 0.85
vm_object_coalesceFunction · 0.85
vm_map_entry_resizeFunction · 0.85
vm_map_try_merge_entriesFunction · 0.85
vm_object_referenceFunction · 0.85
vm_map_entry_createFunction · 0.85
vm_map_entry_linkFunction · 0.85
vm_map_pmap_enterFunction · 0.85

Tested by

no test coverage detected