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

Function vm_map_copy_entry

freebsd/vm/vm_map.c:4137–4232  ·  view source on GitHub ↗

* vm_map_copy_entry: * * Copies the contents of the source entry to the destination * entry. The entries *must* be aligned properly. */

Source from the content-addressed store, hash-verified

4135 * entry. The entries *must* be aligned properly.
4136 */
4137static void
4138vm_map_copy_entry(
4139 vm_map_t src_map,
4140 vm_map_t dst_map,
4141 vm_map_entry_t src_entry,
4142 vm_map_entry_t dst_entry,
4143 vm_ooffset_t *fork_charge)
4144{
4145 vm_object_t src_object;
4146 vm_map_entry_t fake_entry;
4147 vm_offset_t size;
4148
4149 VM_MAP_ASSERT_LOCKED(dst_map);
4150
4151 if ((dst_entry->eflags|src_entry->eflags) & MAP_ENTRY_IS_SUB_MAP)
4152 return;
4153
4154 if (src_entry->wired_count == 0 ||
4155 (src_entry->protection & VM_PROT_WRITE) == 0) {
4156 /*
4157 * If the source entry is marked needs_copy, it is already
4158 * write-protected.
4159 */
4160 if ((src_entry->eflags & MAP_ENTRY_NEEDS_COPY) == 0 &&
4161 (src_entry->protection & VM_PROT_WRITE) != 0) {
4162 pmap_protect(src_map->pmap,
4163 src_entry->start,
4164 src_entry->end,
4165 src_entry->protection & ~VM_PROT_WRITE);
4166 }
4167
4168 /*
4169 * Make a copy of the object.
4170 */
4171 size = src_entry->end - src_entry->start;
4172 if ((src_object = src_entry->object.vm_object) != NULL) {
4173 if (src_object->type == OBJT_DEFAULT ||
4174 src_object->type == OBJT_SWAP) {
4175 vm_map_copy_swap_object(src_entry, dst_entry,
4176 size, fork_charge);
4177 /* May have split/collapsed, reload obj. */
4178 src_object = src_entry->object.vm_object;
4179 } else {
4180 vm_object_reference(src_object);
4181 dst_entry->object.vm_object = src_object;
4182 }
4183 src_entry->eflags |= MAP_ENTRY_COW |
4184 MAP_ENTRY_NEEDS_COPY;
4185 dst_entry->eflags |= MAP_ENTRY_COW |
4186 MAP_ENTRY_NEEDS_COPY;
4187 dst_entry->offset = src_entry->offset;
4188 if (src_entry->eflags & MAP_ENTRY_WRITECNT) {
4189 /*
4190 * MAP_ENTRY_WRITECNT cannot
4191 * indicate write reference from
4192 * src_entry, since the entry is
4193 * marked as needs copy. Allocate a
4194 * fake entry that is used to

Callers 1

vmspace_forkFunction · 0.85

Calls 7

vm_map_copy_swap_objectFunction · 0.85
vm_object_referenceFunction · 0.85
vm_map_entry_createFunction · 0.85
vm_fault_copy_entryFunction · 0.85
pmap_protectFunction · 0.50
pmap_copyFunction · 0.50
crholdFunction · 0.50

Tested by

no test coverage detected