FreeBSD Memory Management questions ?

Scott Long scottl at samsco.org
Tue Jun 14 21:33:15 GMT 2005


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


More information about the freebsd-net mailing list