Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Mar 2017 10:28:16 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314487 - head/sys/kern
Message-ID:  <201703011028.v21ASGO1059236@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Mar  1 10:28:15 2017
New Revision: 314487
URL: https://svnweb.freebsd.org/changeset/base/314487

Log:
  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

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c	Wed Mar  1 10:22:07 2017	(r314486)
+++ head/sys/kern/imgact_elf.c	Wed Mar  1 10:28:15 2017	(r314487)
@@ -452,9 +452,10 @@ __elfN(map_insert)(struct image_params *
 			 * 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703011028.v21ASGO1059236>