From owner-svn-src-head@freebsd.org Mon Mar 6 14:09:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B88ECFBBD0; Mon, 6 Mar 2017 14:09:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A4B0014EB; Mon, 6 Mar 2017 14:09:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v26E9sO8085980; Mon, 6 Mar 2017 14:09:54 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v26E9sg0085979; Mon, 6 Mar 2017 14:09:54 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703061409.v26E9sg0085979@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 6 Mar 2017 14:09:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314773 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Mar 2017 14:09:56 -0000 Author: kib Date: Mon Mar 6 14:09:54 2017 New Revision: 314773 URL: https://svnweb.freebsd.org/changeset/base/314773 Log: Instead of direct use of vm_map_insert(), call vm_map_fixed(MAP_CHECK_EXCL). This KPI explicitely indicates the intent of creating the mapping at the fixed address, and incorporates the map locking into the callee. Suggested and reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Mon Mar 6 12:22:05 2017 (r314772) +++ head/sys/kern/imgact_elf.c Mon Mar 6 14:09:54 2017 (r314773) @@ -397,10 +397,8 @@ __elfN(map_partial)(vm_map_t map, vm_obj /* * Create the page if it doesn't exist yet. Ignore errors. */ - vm_map_lock(map); - vm_map_insert(map, NULL, 0, trunc_page(start), round_page(end), - VM_PROT_ALL, VM_PROT_ALL, 0); - vm_map_unlock(map); + vm_map_fixed(map, NULL, 0, trunc_page(start), round_page(end) - + trunc_page(start), VM_PROT_ALL, VM_PROT_ALL, MAP_CHECK_EXCL); /* * Find the page from the underlying object. @@ -451,10 +449,8 @@ __elfN(map_insert)(struct image_params * * The mapping is not page aligned. This means we have * to copy the data. Sigh. */ - 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); + rv = vm_map_fixed(map, NULL, 0, start, end - start, + prot | VM_PROT_WRITE, VM_PROT_ALL, MAP_CHECK_EXCL); if (rv != KERN_SUCCESS) return (rv); if (object == NULL) @@ -477,10 +473,9 @@ __elfN(map_insert)(struct image_params * rv = KERN_SUCCESS; } else { vm_object_reference(object); - vm_map_lock(map); - rv = vm_map_insert(map, object, offset, start, end, - prot, VM_PROT_ALL, cow); - vm_map_unlock(map); + rv = vm_map_fixed(map, object, offset, start, + end - start, prot, VM_PROT_ALL, + cow | MAP_CHECK_EXCL); if (rv != KERN_SUCCESS) { locked = VOP_ISLOCKED(imgp->vp); VOP_UNLOCK(imgp->vp, 0);