From owner-freebsd-arch@FreeBSD.ORG Fri Sep 15 17:51:04 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 DECE416A407; Fri, 15 Sep 2006 17:51:04 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [210.51.165.229]) by mx1.FreeBSD.org (Postfix) with ESMTP id 47BDB43D49; Fri, 15 Sep 2006 17:51:04 +0000 (GMT) (envelope-from delphij@delphij.net) Received: from localhost (tarsier.geekcn.org [210.51.165.229]) by tarsier.geekcn.org (Postfix) with ESMTP id B5137EB323E; Sat, 16 Sep 2006 01:51:02 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([210.51.165.229]) by localhost (mail.geekcn.org [210.51.165.229]) (amavisd-new, port 10024) with ESMTP id LkBDUxT7obNy; Sat, 16 Sep 2006 01:51:00 +0800 (CST) Received: from [192.168.1.32] (unknown [221.216.126.47]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTP id 38FE8EB0BD2; Sat, 16 Sep 2006 01:50:59 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:organization:user-agent:mime-version:to:cc: subject:references:in-reply-to:content-type:content-transfer-encoding; b=paRvf6W31vTmH0uuzvHdeaffdy/Hrm1PhKBxi0cq4la/KnnKugMZg4fUcEJhvBADJ zSDBwaE5nGl5Fnbmbjx8w== Message-ID: <450AE7FE.5000905@delphij.net> Date: Sat, 16 Sep 2006 01:50:54 +0800 From: LI Xin Organization: The FreeBSD Project User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) MIME-Version: 1.0 To: John Baldwin References: <450AB80B.1050100@delphij.net> <200609151035.12069.jhb@freebsd.org> <450AC4FE.6070303@delphij.net> <200609151251.16371.jhb@freebsd.org> In-Reply-To: <200609151251.16371.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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:51:05 -0000 John Baldwin wrote: > 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. I see... So, what if I want to make some data available to userland? Is flipping the user/supervisor bit the only way? Cheers, -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve!