From owner-svn-src-head@freebsd.org Thu Mar 30 19:42:50 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 CF932D26CA0; Thu, 30 Mar 2017 19:42:50 +0000 (UTC) (envelope-from dchagin@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 85658377; Thu, 30 Mar 2017 19:42:50 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2UJgn10037262; Thu, 30 Mar 2017 19:42:49 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2UJgnqb037260; Thu, 30 Mar 2017 19:42:49 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201703301942.v2UJgnqb037260@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Thu, 30 Mar 2017 19:42:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316288 - in head/sys: sys vm 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: Thu, 30 Mar 2017 19:42:50 -0000 Author: dchagin Date: Thu Mar 30 19:42:49 2017 New Revision: 316288 URL: https://svnweb.freebsd.org/changeset/base/316288 Log: Add kern_mincore() helper for micore() syscall. Suggested by: kib@ Reviewed by: kib@ MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D10143 Modified: head/sys/sys/syscallsubr.h head/sys/vm/vm_mmap.c Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Thu Mar 30 19:32:25 2017 (r316287) +++ head/sys/sys/syscallsubr.h Thu Mar 30 19:42:49 2017 (r316288) @@ -152,6 +152,7 @@ int kern_lseek(struct thread *td, int fd int kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg, struct timeval *tptr, enum uio_seg tptrseg); int kern_madvise(struct thread *td, uintptr_t addr, size_t len, int behav); +int kern_mincore(struct thread *td, uintptr_t addr, size_t len, char *vec); int kern_mkdirat(struct thread *td, int fd, char *path, enum uio_seg segflg, int mode); int kern_mkfifoat(struct thread *td, int fd, char *path, Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Thu Mar 30 19:32:25 2017 (r316287) +++ head/sys/vm/vm_mmap.c Thu Mar 30 19:42:49 2017 (r316288) @@ -711,11 +711,17 @@ struct mincore_args { int sys_mincore(struct thread *td, struct mincore_args *uap) { + + return (kern_mincore(td, (uintptr_t)uap->addr, uap->len, uap->vec)); +} + +int +kern_mincore(struct thread *td, uintptr_t addr0, size_t len, char *vec) +{ vm_offset_t addr, first_addr; vm_offset_t end, cend; pmap_t pmap; vm_map_t map; - char *vec; int error = 0; int vecindex, lastvecindex; vm_map_entry_t current; @@ -732,17 +738,12 @@ sys_mincore(struct thread *td, struct mi * Make sure that the addresses presented are valid for user * mode. */ - first_addr = addr = trunc_page((vm_offset_t) uap->addr); - end = addr + (vm_size_t)round_page(uap->len); + first_addr = addr = trunc_page(addr0); + end = addr + (vm_size_t)round_page(len); map = &td->td_proc->p_vmspace->vm_map; if (end > vm_map_max(map) || end < addr) return (ENOMEM); - /* - * Address of byte vector - */ - vec = uap->vec; - pmap = vmspace_pmap(td->td_proc->p_vmspace); vm_map_lock_read(map);