Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2005 20:06:42 +1000
From:      Peter Jeremy <PeterJeremy@optushome.com.au>
To:        Aziz Kezzou <french.linuxian@gmail.com>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: FreeBSD Memory Management questions ?
Message-ID:  <20050614100642.GC50157@cirb503493.alcatel.com.au>
In-Reply-To: <37273927050614012154fdb80b@mail.gmail.com>
References:  <37273927050614012154fdb80b@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[-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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050614100642.GC50157>