vm_map_submap(): Avoid unnecessary clipping.

A submap can only be created from an entry spanning the entire request
range.  In particular, if vm_map_lookup_entry() returns false or the
returned entry contains "end".

Since the only use of submaps in FreeBSD is for the static pipe and
execve argument KVA maps, this has no functional effect.

Github PR:	https://github.com/freebsd/freebsd/pull/420
Submitted by:	Wuyang Chung <wuyang.chung1@gmail.com> (original)
Reviewed by:	dougm, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23299
This commit is contained in:
Mark Johnston 2020-01-23 16:45:10 +00:00
parent 976d7cecd5
commit e6bd3a812d

View File

@ -2477,19 +2477,12 @@ vm_map_submap(
vm_map_unlock(submap);
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
if (vm_map_lookup_entry(map, start, &entry)) {
if (vm_map_lookup_entry(map, start, &entry) && entry->end >= end &&
(entry->eflags & MAP_ENTRY_COW) == 0 &&
entry->object.vm_object == NULL) {
vm_map_clip_start(map, entry, start);
} else
entry = vm_map_entry_succ(entry);
vm_map_clip_end(map, entry, end);
if ((entry->start == start) && (entry->end == end) &&
((entry->eflags & MAP_ENTRY_COW) == 0) &&
(entry->object.vm_object == NULL)) {
vm_map_clip_end(map, entry, end);
entry->object.sub_map = submap;
entry->eflags |= MAP_ENTRY_IS_SUB_MAP;
result = KERN_SUCCESS;