VM question related to faults

Intron mag at intron.ac
Mon Jul 31 06:12:24 UTC 2006


Divacky Roman wrote:

> On Sun, Jul 30, 2006 at 12:57:32PM +0200, Divacky Roman wrote:
>> hi,
>> 
>> while working on SoC linuxolator project I am in a need of this:
>> 
>> I need to do some operation on memory like mem1 = mem1 + mem2 etc.
>> where the mem1/mem2 access can trigger fault. (memory not mapped or something)
> 
> to make it clear.. I am trying to access user-space memory from kernel.
> This needs to be atomic (its an implementation of linux futexes)
> 
> I need to check from kernel if some memory is accessible and then perform an 
> operation on this memory. All atomically.
> 
> hence I need two things - function which checks wheter the memory is accessible
> and something which makes it atomic (some mutex/something which prevents other
> process to enter VM to unmap/etc. the memory in question)
> 
> hope its a bit more clear now
> 
> roman
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"

The manual page mutex(9) says,

      No mutexes should be held (except for Giant) across functions which
      access memory in userspace, such as copyin(9), copyout(9), uiomove(9),
      fuword(9), etc.  No locks are needed when calling these functions.

Actually, any contents in user space should be copied into kernel space
before reading them. They should also be mirrored in kernel space if
necessary.

Mutex(9) is sometimes too heavy, and has many limitations, while sx(9)
is somewhat enough.

------------------------------------------------------------------------
                                                From Beijing, China



More information about the freebsd-hackers mailing list