From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 14 21:33: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 3850816A41C; Tue, 14 Jun 2005 21:33: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 DCA7843D1D; Tue, 14 Jun 2005 21:33:14 +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.3/8.13.3) with ESMTP id j5ELbsha013988; Tue, 14 Jun 2005 15:37:55 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <42AF4C82.7070306@samsco.org> Date: Tue, 14 Jun 2005 15:30:42 -0600 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-Mark Gurney References: <37273927050614012154fdb80b@mail.gmail.com> <20050614212214.GK742@funkthat.com> In-Reply-To: <20050614212214.GK742@funkthat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org Cc: freebsd-hackers , Aziz Kezzou , freebsd-net Subject: Re: FreeBSD Memory Management questions ? 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: Tue, 14 Jun 2005 21:33:15 -0000 John-Mark Gurney wrote: > Aziz Kezzou wrote this message on Tue, Jun 14, 2005 at 04:21 -0400: > >>I have two questions concerning FreeBSD Memory management : >> >>1 - Right now to access the memory address space of a user process >>from kernel mode, I only have to set, on x86 systems, the register CR3 >>to the right value. How can I do that on other architectures ? is >>there an architecture-independant way of doing that ? >> >>2- I have noticed that while in kernel mode the value of CR3 is equal >>to that of the user process beeing interrupted. Doesn't the kernel >>supposed to have its "own" page-directory, i.e it's own CR3 value ? >>or is kernel virtual address resolution does not go through CR3 at >>all ? > > > You should be using copyin(9)/copyout(9) instead of playing around with > CR3 directly... or fuword(9)/suword(9)... This provides a platform > independant way of accessing user's memory (for the current running > process)... > Not to mention that setting CR3, or whatever on other platforms, doesn't handle accessing pages that have been swapped out. That's the real magic that copyin/copyout does. Scott