From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 3 17:38:02 2011 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 0DCDD1065678 for ; Sat, 3 Dec 2011 17:38:02 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id D65AE8FC14 for ; Sat, 3 Dec 2011 17:38:01 +0000 (UTC) Received: from julian-mac.elischer.org (c-67-180-24-15.hsd1.ca.comcast.net [67.180.24.15]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id pB3HbwUW085687 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 3 Dec 2011 09:38:00 -0800 (PST) (envelope-from julian@freebsd.org) Message-ID: <4EDA5E84.1030605@freebsd.org> Date: Sat, 03 Dec 2011 09:38:12 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.24) Gecko/20111103 Thunderbird/3.1.16 MIME-Version: 1.0 To: Filippo Sironi References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: mmap implementation for cdev 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: Sat, 03 Dec 2011 17:38:02 -0000 On 12/3/11 12:42 AM, Filippo Sironi wrote: > Dear all, > > I've a strange problem I cannot understand... > I implemented a piece of code within the FreeBSD 7.2 kernel that basically allocate a per-thread memory page to store a certain amount of information that must be read and written without crossing user to kernel and kernel to user boundaries. > To read and write the memory page I decided to allocate it in kernel space and then mmap'ing it to user space using a "virtual cdev" as an entry point for user space threads. The implementation of the mmap I came up with is really trivial, I basically do: > > *paddr = vtophys(curthread->private_info); > > Now for the problem. > I enter the mmap and private_info is the correct kernel space virtual address, each thread as its own address and the physical address - returned by vtophys - is different too. The problem is that when I come back to user space all the threads write in memory page mapped by the first thread that called the mmap leaving their memory pages untouched. > > This problem bugs me but I cannot find a solution. I don't really understand the behavior. > each thread needs to store a different address as the base of it's memory.. the memory map of a process is just that.. the memory map of the PROCESS All threads see the same map. > Any ideas? > Thanks a lot, > Filippo > > > _______________________________________________ > 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" > >