From owner-freebsd-arch@FreeBSD.ORG Fri Sep 15 17:08:50 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7C24116A412 for ; Fri, 15 Sep 2006 17:08:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id C69BE43D60 for ; Fri, 15 Sep 2006 17:08:49 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id k8FH89i7052169; Fri, 15 Sep 2006 13:08:28 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: LI Xin Date: Fri, 15 Sep 2006 12:51:16 -0400 User-Agent: KMail/1.9.1 References: <450AB80B.1050100@delphij.net> <200609151035.12069.jhb@freebsd.org> <450AC4FE.6070303@delphij.net> In-Reply-To: <450AC4FE.6070303@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200609151251.16371.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Fri, 15 Sep 2006 13:08:28 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/1885/Fri Sep 15 07:19:10 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-arch@freebsd.org Subject: Re: How to map a page with userland program? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Sep 2006 17:08:50 -0000 On Friday 15 September 2006 11:21, LI Xin wrote: > John Baldwin wrote: > > On Friday 15 September 2006 10:26, LI Xin wrote: > >> Dear folks, > >> > >> Is there a continent and MI way to map a kernel page into userland > >> address space under the same virtual address? It seems that this can be > >> implemented through some routines in MD part of pmap, but is it possible > >> to use higher level VM routines to do the job? > > > > Not to the same userland virtual address. Why do you need the same > > virtual address anyway? If it's for pointers use offsets relative to > > the start of the page instead. > > That would make it easier to implement some sort of VSYSCALL, which is > in fact executed in userland. Or, is there any better way? :-) If you want to stick code in the page, make the code PIC, the same as is done for shared libraries. Alternatively, if you wanted to be very, very evil and can have the page read-only once it is initialized, flip the user/supervisor bit in the kernel PTE for that page such that it is treated as a user page rather than a kernel page (even though it's in KVA), and then userland processes can access that page via it's kernel VA. Making the code PIC would probably be better though. -- John Baldwin