From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 14 20:57:15 2005 Return-Path: X-Original-To: freebsd-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 D728316A420 for ; Mon, 14 Nov 2005 20:57:15 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 337E943D46 for ; Mon, 14 Nov 2005 20:57:15 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.14] (imini.samsco.home [192.168.254.14]) (authenticated bits=0) by pooker.samsco.org (8.13.4/8.13.4) with ESMTP id jAEKvAeC061924; Mon, 14 Nov 2005 13:57:10 -0700 (MST) (envelope-from scottl@samsco.org) Message-ID: <4378FA26.8040604@samsco.org> Date: Mon, 14 Nov 2005 13:57:10 -0700 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.7) Gecko/20050416 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Giacomoni References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on pooker.samsco.org Cc: freebsd-hackers@freebsd.org Subject: Re: Sharing the same VM address space between Kernel and UserSpace 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: Mon, 14 Nov 2005 20:57:16 -0000 John Giacomoni wrote: > I am in need of a way to share memory between kernel space and possibly > multiple different user-space processes for an extended period of time. > This memory would need to be a single unpageable region. > > I am using the vm routines as cribbed from mmap, however I'd like the > address spaces to be viewed as the same regardless of which process I'm > in to avoid swizzling pointers as I'm storing data structures in the > shared memory region. > > I imagine I'd need to find a way to expose part of the kernel address > space to user space to accomplish this. > > Is there a way to do this? > > thanks > > John G > If you get this working then it'll be very useful for the syspage support that was talked about recently. The kernel can access addresses in the user space so long as they are wired and won't cause a fault. Thus I imagine that you only need to allocate the memory, wire it, mark it with the appropriate page permissions, and reserve a user address range for it in the process map. I'd look at the process exec path in the kernel for places to hook in. The only other trick then is how to let the user process know the address for this magic region. An easy way would be to store it in a sysctl that can be read at runtime. A harder way would be to have the kernel dummy up an elf segment in the image activator code that the dynamic linker could read and put into a global variable for the program to access. Scott