From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 13 16:41:08 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA7D91065740 for ; Thu, 13 Mar 2008 16:41:08 +0000 (UTC) (envelope-from john.giacomoni@colorado.edu) Received: from suburban.colorado.edu (suburban.colorado.edu [128.138.189.14]) by mx1.freebsd.org (Postfix) with ESMTP id AA6E38FC1C for ; Thu, 13 Mar 2008 16:41:08 +0000 (UTC) (envelope-from john.giacomoni@colorado.edu) Received: from [127.0.0.1] (suburban.colorado.edu [127.0.0.1]) by suburban.colorado.edu (8.13.1/8.13.1) with ESMTP id m2DDIAih029095; Thu, 13 Mar 2008 09:18:10 -0400 Message-Id: <006DB5A0-3669-473B-84B6-E3C8CC3C059D@colorado.edu> From: John Giacomoni To: freebsd-hackers@freebsd.org In-Reply-To: <12A5C15467D5B94F8E0FF265D9498ADD02B35F81@orsmsx419.amr.corp.intel.com> Content-Type: multipart/mixed; boundary=Apple-Mail-473--515687753 Mime-Version: 1.0 (Apple Message framework v919.2) Date: Thu, 13 Mar 2008 10:12:58 -0600 References: <12A5C15467D5B94F8E0FF265D9498ADD02B35F81@orsmsx419.amr.corp.intel.com> X-Mailer: Apple Mail (2.919.2) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: "Rao, Nikhil" Subject: Re: Shared VM address range across processes 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: Thu, 13 Mar 2008 16:41:09 -0000 --Apple-Mail-473--515687753 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Nihkil, I'm working on something similar for a research project and the answer is that it is possible but ugly. First, are you sure you need to do this? Ensuring safety by checking pointers before dereferencing can be painful :) FreeBSD seems to have checks scattered throughout the kernel trying to ensure that the kernel address range remains unavailable to the userspace address range. These checks can obviously be bypassed but they are fairly invasive. Once all those checks are bipassed, you need to ensure that the PTEs and PDEs are have the userspace bit set for the appropriate page ranges which then requires flushing the specific pages out of the TLB using the invlpg function, note that flushing the TLB is insufficient as kernel pages are marked global and thus won't flush with any other method. files that I touched /usr/src/sys/amd64/amd64/pmap.c - pmap_enter /usr/src/sys/amd64/amd64/trap.c - trap_pfault and the allocation site needs to ensure that the user-mode bit is set on the correct PTEs and PDEs. I directly allocate memory using vm objects to help me bypass the various address range checks that can be found in the higher levels of the kernel. I'm planning on generalizing and cleaning my approach up in the next few months but I'll be glad to answer any specific questions you might have. For the FreeBSD kernel developers, Is there a reason to enforce the high/low mem address range as strongly as is done in FreeBSD? It seems that if the higher-levels of the kernel allow a mapping, the lower-levels should respect that. John G On Mar 12, 2008, at 12:46 PM, Rao, Nikhil wrote: > Hi, > > > > I want to map device memory into the same virtual address range in > multiple processes, this means I would have to add a vm_map_entry per > address range in every process, since the list of processes can be > potentially huge .. Is it allowed to point to the same list of > vm_map_entrys from multiple vm_spaces ? BSD3 had a field in the > vm_map_entry that could be a share map - would it be an idea that I > could reuse ? > > > > Nikhil > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org > " -- John.Giacomoni@colorado.edu University of Colorado at Boulder Department of Computer Science Engineering Center, ECCR 1B50 430 UCB Boulder, CO 80303-0430 USA --Apple-Mail-473--515687753 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-473--515687753--