From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 14 10:06:47 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 A368E16A41C for ; Tue, 14 Jun 2005 10:06:47 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail26.syd.optusnet.com.au (mail26.syd.optusnet.com.au [211.29.133.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2544043D58 for ; Tue, 14 Jun 2005 10:06:46 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) by mail26.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id j5EA6ikJ003235 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 14 Jun 2005 20:06:45 +1000 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id j5EA6hRx054021; Tue, 14 Jun 2005 20:06:44 +1000 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id j5EA6h5U054020; Tue, 14 Jun 2005 20:06:43 +1000 (EST) (envelope-from pjeremy) Date: Tue, 14 Jun 2005 20:06:42 +1000 From: Peter Jeremy To: Aziz Kezzou Message-ID: <20050614100642.GC50157@cirb503493.alcatel.com.au> References: <37273927050614012154fdb80b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37273927050614012154fdb80b@mail.gmail.com> User-Agent: Mutt/1.4.2i Cc: freebsd-hackers 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 10:06:47 -0000 [-net dropped: This is not off-topic there] On Tue, 2005-Jun-14 04:21:41 -0400, Aziz Kezzou wrote: >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 ? The only supported way to access user memory from the kernel is via the copy(9), fetch(9) or store(9) functions. These functions include checks to ensure that the userland address is valid and resident. Playing with CR3 (or any other memory management control registers) is not supported outside the MD VM subsystem. >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 ? Re-loading CR3 flushes the TLB. This makes it a quite expensive operation which should be avoided unless necessary. Instead, both the kernel and userland share the same flat address space and use different segment selectors to control access to the kernel space. -- Peter Jeremy