Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_map.c
Context not available. | |||||
"vm_map_entry_link: map %p, nentries %d, entry %p, after %p", map, | "vm_map_entry_link: map %p, nentries %d, entry %p, after %p", map, | ||||
map->nentries, entry, after_where); | map->nentries, entry, after_where); | ||||
VM_MAP_ASSERT_LOCKED(map); | VM_MAP_ASSERT_LOCKED(map); | ||||
KASSERT(after_where == &map->header || | KASSERT(after_where->end <= entry->start, | ||||
after_where->end <= entry->start, | |||||
("vm_map_entry_link: prev end %jx new start %jx overlap", | ("vm_map_entry_link: prev end %jx new start %jx overlap", | ||||
(uintmax_t)after_where->end, (uintmax_t)entry->start)); | (uintmax_t)after_where->end, (uintmax_t)entry->start)); | ||||
KASSERT(after_where->next == &map->header || | KASSERT(entry->end <= after_where->next->start, | ||||
entry->end <= after_where->next->start, | |||||
("vm_map_entry_link: new end %jx next start %jx overlap", | ("vm_map_entry_link: new end %jx next start %jx overlap", | ||||
(uintmax_t)entry->end, (uintmax_t)after_where->next->start)); | (uintmax_t)entry->end, (uintmax_t)after_where->next->start)); | ||||
Context not available. | |||||
entry->right = map->root; | entry->right = map->root; | ||||
entry->left = NULL; | entry->left = NULL; | ||||
} | } | ||||
entry->adj_free = (entry->next == &map->header ? map->max_offset : | entry->adj_free = entry->next->start - entry->end; | ||||
entry->next->start) - entry->end; | |||||
vm_map_entry_set_max_free(entry); | vm_map_entry_set_max_free(entry); | ||||
map->root = entry; | map->root = entry; | ||||
} | } | ||||
Context not available. | |||||
else { | else { | ||||
root = vm_map_entry_splay(entry->start, entry->left); | root = vm_map_entry_splay(entry->start, entry->left); | ||||
root->right = entry->right; | root->right = entry->right; | ||||
root->adj_free = (entry->next == &map->header ? map->max_offset : | root->adj_free = entry->next->start - root->end; | ||||
entry->next->start) - root->end; | |||||
vm_map_entry_set_max_free(root); | vm_map_entry_set_max_free(root); | ||||
} | } | ||||
map->root = root; | map->root = root; | ||||
Context not available. | |||||
if (entry != map->root) | if (entry != map->root) | ||||
map->root = vm_map_entry_splay(entry->start, map->root); | map->root = vm_map_entry_splay(entry->start, map->root); | ||||
entry->adj_free = (entry->next == &map->header ? map->max_offset : | entry->adj_free = entry->next->start - entry->end; | ||||
entry->next->start) - entry->end; | |||||
vm_map_entry_set_max_free(entry); | vm_map_entry_set_max_free(entry); | ||||
} | } | ||||
Context not available. | |||||
/* | /* | ||||
* Assert that the next entry doesn't overlap the end point. | * Assert that the next entry doesn't overlap the end point. | ||||
*/ | */ | ||||
if (prev_entry->next != &map->header && prev_entry->next->start < end) | if (prev_entry->next->start < end) | ||||
return (KERN_NO_SPACE); | return (KERN_NO_SPACE); | ||||
if ((cow & MAP_CREATE_GUARD) != 0 && (object != NULL || | if ((cow & MAP_CREATE_GUARD) != 0 && (object != NULL || | ||||
Context not available. | |||||
/* | /* | ||||
* Make a first pass to check for protection violations. | * Make a first pass to check for protection violations. | ||||
*/ | */ | ||||
for (current = entry; current != &map->header && current->start < end; | for (current = entry; current->start < end; current = current->next) { | ||||
current = current->next) { | |||||
if ((current->eflags & MAP_ENTRY_GUARD) != 0) | if ((current->eflags & MAP_ENTRY_GUARD) != 0) | ||||
continue; | continue; | ||||
if (current->eflags & MAP_ENTRY_IS_SUB_MAP) { | if (current->eflags & MAP_ENTRY_IS_SUB_MAP) { | ||||
Context not available. | |||||
* now will do cow due to allowed write (e.g. debugger sets | * now will do cow due to allowed write (e.g. debugger sets | ||||
* breakpoint on text segment) | * breakpoint on text segment) | ||||
*/ | */ | ||||
for (current = entry; current != &map->header && current->start < end; | for (current = entry; current->start < end; current = current->next) { | ||||
current = current->next) { | |||||
vm_map_clip_end(map, current, end); | vm_map_clip_end(map, current, end); | ||||
Context not available. | |||||
* Go back and fix up protections. [Note that clipping is not | * Go back and fix up protections. [Note that clipping is not | ||||
* necessary the second time.] | * necessary the second time.] | ||||
*/ | */ | ||||
for (current = entry; current != &map->header && current->start < end; | for (current = entry; current->start < end; current = current->next) { | ||||
current = current->next) { | |||||
if ((current->eflags & MAP_ENTRY_GUARD) != 0) | if ((current->eflags & MAP_ENTRY_GUARD) != 0) | ||||
continue; | continue; | ||||
Context not available. | |||||
* We clip the vm_map_entry so that behavioral changes are | * We clip the vm_map_entry so that behavioral changes are | ||||
* limited to the specified address range. | * limited to the specified address range. | ||||
*/ | */ | ||||
for (current = entry; | for (current = entry; current->start < end; | ||||
(current != &map->header) && (current->start < end); | current = current->next) { | ||||
markj: While you're here, perhaps fix style and move the closing paren and opening brace to the end of… | |||||
Not Done Inline ActionsPlease deindent by one space on this continuation line. alc: Please deindent by one space on this continuation line. | |||||
current = current->next | |||||
) { | |||||
if (current->eflags & MAP_ENTRY_IS_SUB_MAP) | if (current->eflags & MAP_ENTRY_IS_SUB_MAP) | ||||
continue; | continue; | ||||
Context not available. | |||||
* Since we don't clip the vm_map_entry, we have to clip | * Since we don't clip the vm_map_entry, we have to clip | ||||
* the vm_object pindex and count. | * the vm_object pindex and count. | ||||
*/ | */ | ||||
for (current = entry; | for (current = entry; current->start < end; | ||||
(current != &map->header) && (current->start < end); | current = current->next) { | ||||
Not Done Inline ActionsPlease deindent by one space on this continuation line. alc: Please deindent by one space on this continuation line. | |||||
current = current->next | |||||
) { | |||||
vm_offset_t useEnd, useStart; | vm_offset_t useEnd, useStart; | ||||
if (current->eflags & MAP_ENTRY_IS_SUB_MAP) | if (current->eflags & MAP_ENTRY_IS_SUB_MAP) | ||||
Context not available. | |||||
vm_map_clip_start(map, entry, start); | vm_map_clip_start(map, entry, start); | ||||
} else | } else | ||||
entry = temp_entry->next; | entry = temp_entry->next; | ||||
while ((entry != &map->header) && (entry->start < end)) { | while (entry->start < end) { | ||||
vm_map_clip_end(map, entry, end); | vm_map_clip_end(map, entry, end); | ||||
if ((entry->eflags & MAP_ENTRY_GUARD) == 0 || | if ((entry->eflags & MAP_ENTRY_GUARD) == 0 || | ||||
new_inheritance != VM_INHERIT_ZERO) | new_inheritance != VM_INHERIT_ZERO) | ||||
Context not available. | |||||
} | } | ||||
last_timestamp = map->timestamp; | last_timestamp = map->timestamp; | ||||
entry = first_entry; | entry = first_entry; | ||||
while (entry != &map->header && entry->start < end) { | while (entry->start < end) { | ||||
if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { | if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { | ||||
/* | /* | ||||
* We have not yet clipped the entry. | * We have not yet clipped the entry. | ||||
Context not available. | |||||
* If VM_MAP_WIRE_HOLESOK was specified, skip this check. | * If VM_MAP_WIRE_HOLESOK was specified, skip this check. | ||||
*/ | */ | ||||
if (((flags & VM_MAP_WIRE_HOLESOK) == 0) && | if (((flags & VM_MAP_WIRE_HOLESOK) == 0) && | ||||
(entry->end < end && (entry->next == &map->header || | (entry->end < end && entry->next->start > entry->end)) { | ||||
entry->next->start > entry->end))) { | |||||
end = entry->end; | end = entry->end; | ||||
rv = KERN_INVALID_ADDRESS; | rv = KERN_INVALID_ADDRESS; | ||||
goto done; | goto done; | ||||
Context not available. | |||||
else | else | ||||
KASSERT(result, ("vm_map_unwire: lookup failed")); | KASSERT(result, ("vm_map_unwire: lookup failed")); | ||||
} | } | ||||
for (entry = first_entry; entry != &map->header && entry->start < end; | for (entry = first_entry; entry->start < end; entry = entry->next) { | ||||
entry = entry->next) { | |||||
/* | /* | ||||
* If VM_MAP_WIRE_HOLESOK was specified, an empty | * If VM_MAP_WIRE_HOLESOK was specified, an empty | ||||
* space in the unwired region could have been mapped | * space in the unwired region could have been mapped | ||||
Context not available. | |||||
} | } | ||||
last_timestamp = map->timestamp; | last_timestamp = map->timestamp; | ||||
entry = first_entry; | entry = first_entry; | ||||
while (entry != &map->header && entry->start < end) { | while (entry->start < end) { | ||||
if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { | if (entry->eflags & MAP_ENTRY_IN_TRANSITION) { | ||||
/* | /* | ||||
* We have not yet clipped the entry. | * We have not yet clipped the entry. | ||||
Context not available. | |||||
*/ | */ | ||||
next_entry: | next_entry: | ||||
if ((flags & VM_MAP_WIRE_HOLESOK) == 0 && | if ((flags & VM_MAP_WIRE_HOLESOK) == 0 && | ||||
entry->end < end && (entry->next == &map->header || | entry->end < end && entry->next->start > entry->end) { | ||||
entry->next->start > entry->end)) { | |||||
end = entry->end; | end = entry->end; | ||||
rv = KERN_INVALID_ADDRESS; | rv = KERN_INVALID_ADDRESS; | ||||
goto done; | goto done; | ||||
Context not available. | |||||
else | else | ||||
KASSERT(result, ("vm_map_wire: lookup failed")); | KASSERT(result, ("vm_map_wire: lookup failed")); | ||||
} | } | ||||
for (entry = first_entry; entry != &map->header && entry->start < end; | for (entry = first_entry; entry->start < end; entry = entry->next) { | ||||
entry = entry->next) { | |||||
/* | /* | ||||
* If VM_MAP_WIRE_HOLESOK was specified, an empty | * If VM_MAP_WIRE_HOLESOK was specified, an empty | ||||
* space in the unwired region could have been mapped | * space in the unwired region could have been mapped | ||||
Context not available. | |||||
/* | /* | ||||
* Make a first pass to check for user-wired memory and holes. | * Make a first pass to check for user-wired memory and holes. | ||||
*/ | */ | ||||
for (current = entry; current != &map->header && current->start < end; | for (current = entry; current->start < end; current = current->next) { | ||||
current = current->next) { | |||||
if (invalidate && (current->eflags & MAP_ENTRY_USER_WIRED)) { | if (invalidate && (current->eflags & MAP_ENTRY_USER_WIRED)) { | ||||
vm_map_unlock_read(map); | vm_map_unlock_read(map); | ||||
return (KERN_INVALID_ARGUMENT); | return (KERN_INVALID_ARGUMENT); | ||||
} | } | ||||
if (end > current->end && | if (end > current->end && | ||||
(current->next == &map->header || | current->end != current->next->start) { | ||||
current->end != current->next->start)) { | |||||
vm_map_unlock_read(map); | vm_map_unlock_read(map); | ||||
return (KERN_INVALID_ADDRESS); | return (KERN_INVALID_ADDRESS); | ||||
} | } | ||||
Context not available. | |||||
* Make a second pass, cleaning/uncaching pages from the indicated | * Make a second pass, cleaning/uncaching pages from the indicated | ||||
* objects as we go. | * objects as we go. | ||||
*/ | */ | ||||
for (current = entry; current != &map->header && current->start < end;) { | for (current = entry; current->start < end;) { | ||||
offset = current->offset + (start - current->start); | offset = current->offset + (start - current->start); | ||||
size = (end <= current->end ? end : current->end) - start; | size = (end <= current->end ? end : current->end) - start; | ||||
if (current->eflags & MAP_ENTRY_IS_SUB_MAP) { | if (current->eflags & MAP_ENTRY_IS_SUB_MAP) { | ||||
Context not available. | |||||
/* | /* | ||||
* Step through all entries in this region | * Step through all entries in this region | ||||
*/ | */ | ||||
while ((entry != &map->header) && (entry->start < end)) { | while (entry->start < end) { | ||||
vm_map_entry_t next; | vm_map_entry_t next; | ||||
/* | /* | ||||
Context not available. | |||||
entry = tmp_entry; | entry = tmp_entry; | ||||
while (start < end) { | while (start < end) { | ||||
if (entry == &map->header) | |||||
return (FALSE); | |||||
/* | /* | ||||
* No holes allowed! | * No holes allowed! | ||||
*/ | */ | ||||
Context not available. | |||||
/* | /* | ||||
* If we can't accommodate max_ssize in the current mapping, no go. | * If we can't accommodate max_ssize in the current mapping, no go. | ||||
*/ | */ | ||||
if ((prev_entry->next != &map->header) && | if (prev_entry->next->start < addrbos + max_ssize) | ||||
(prev_entry->next->start < addrbos + max_ssize)) | |||||
return (KERN_NO_SPACE); | return (KERN_NO_SPACE); | ||||
/* | /* | ||||
Context not available. |
While you're here, perhaps fix style and move the closing paren and opening brace to the end of the previous line? Ditto below.