Use vm_map_insert() instead of vm_map_find() in elf_map_insert().

Elf_map_insert() needs to create mapping at the known fixed address.
Usage of vm_map_find() assumes, on the other hand, that any suitable
address space range above or equal the specified hint, is acceptable.
Due to operating on the fresh or cleared address space, vm_map_find()
usually creates mapping starting exactly at hint.

Switch to vm_map_insert() use to clearly request fixed mapping from
the VM.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
This commit is contained in:
kib 2017-03-01 10:28:15 +00:00
parent cf53f19d89
commit 4f433ead68

View File

@ -452,9 +452,10 @@ __elfN(map_insert)(struct image_params *imgp, vm_map_t map, vm_object_t object,
* The mapping is not page aligned. This means we have
* to copy the data. Sigh.
*/
rv = vm_map_find(map, NULL, 0, &start, end - start, 0,
VMFS_NO_SPACE, prot | VM_PROT_WRITE, VM_PROT_ALL,
0);
vm_map_lock(map);
rv = vm_map_insert(map, NULL, 0, start, end,
prot | VM_PROT_WRITE, VM_PROT_ALL, 0);
vm_map_unlock(map);
if (rv != KERN_SUCCESS)
return (rv);
if (object == NULL)