From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 14 14:15:28 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C71016A47A; Wed, 14 Jun 2006 14:15:28 +0000 (UTC) (envelope-from bruno@clisp.org) Received: from ftp.ilog.fr (ftp.ilog.fr [81.80.162.195]) by mx1.FreeBSD.org (Postfix) with ESMTP id C31B443D48; Wed, 14 Jun 2006 14:15:27 +0000 (GMT) (envelope-from bruno@clisp.org) Received: from laposte.ilog.fr (cerbere-qfe0 [81.80.162.193]) by ftp.ilog.fr (8.13.1/8.13.1) with ESMTP id k5EEFQpf011299; Wed, 14 Jun 2006 16:15:26 +0200 Received: from marbore.ilog.biz (marbore.ilog.biz [172.17.2.61]) by laposte.ilog.fr (8.13.1/8.13.1) with ESMTP id k5EEFIEX002011; Wed, 14 Jun 2006 16:15:19 +0200 Received: from honolulu.ilog.fr ([172.16.15.121]) by marbore.ilog.biz with Microsoft SMTPSVC(6.0.3790.1830); Wed, 14 Jun 2006 16:15:34 +0200 Received: by honolulu.ilog.fr (Postfix, from userid 1001) id 287C9F1433; Wed, 14 Jun 2006 16:13:54 +0200 (CEST) From: Bruno Haible To: Konstantin Belousov Date: Wed, 14 Jun 2006 16:13:53 +0200 User-Agent: KMail/1.9.1 References: <200606101822.46437.bruno@clisp.org> <200606141404.08811.bruno@clisp.org> <20060614135600.GB86300@deviant.kiev.zoral.com.ua> In-Reply-To: <20060614135600.GB86300@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606141613.54027.bruno@clisp.org> X-OriginalArrivalTime: 14 Jun 2006 14:15:34.0931 (UTC) FILETIME=[00A91630:01C68FBD] X-Mailman-Approved-At: Wed, 14 Jun 2006 14:16:33 +0000 Cc: Vasil Dimov , hackers@freebsd.org Subject: Re: valid VMA ranges and mincore() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jun 2006 14:15:28 -0000 Hello Konstantin, > > - Filling in values of -1 into the array could be done more easily by > > changing the statements in sys/vm/vm_mmap.c lines 861 and 902. > I do not agree. It zeroes array not only for holes, but also for (some) > skipped vm areas. ok, you understand the code better than I do :-) > Index: vm_mmap.c > =================================================================== > RCS file: /usr/local/arch/ncvs/src/sys/vm/vm_mmap.c,v > retrieving revision 1.205 > diff -u -r1.205 vm_mmap.c > --- vm_mmap.c 21 Apr 2006 07:17:25 -0000 1.205 > +++ vm_mmap.c 14 Jun 2006 13:51:20 -0000 > @@ -756,8 +756,10 @@ > first_addr = addr = trunc_page((vm_offset_t) uap->addr); > end = addr + (vm_size_t)round_page(uap->len); > map = &td->td_proc->p_vmspace->vm_map; > - if (end > vm_map_max(map) || end < addr) > + if (end < addr) > return (EINVAL); > + if (end > vm_map_max(map)) > + return (ENOMEM); > > /* > * Address of byte vector > @@ -770,8 +772,18 @@ > RestartScan: > timestamp = map->timestamp; > > - if (!vm_map_lookup_entry(map, addr, &entry)) > - entry = entry->next; > + if (!vm_map_lookup_entry(map, first_addr, &entry)) { > + vm_map_unlock_read(map); > + return (ENOMEM); > + } > + for (current = entry; > + (current != &map->header) && (current->end < end); > + current = current->next) { > + if (current->end != current->next->start) { > + vm_map_unlock_read(map); > + return (ENOMEM); > + } > + } > > /* > * Do this on a map entry basis so that if the pages are not > Looks good to me: This does what Linux, NetBSD, Solaris do. Thanks! Bruno