Re: VM question related to faults



On Monday 31 July 2006 14:15, Attilio Rao wrote:
2006/7/30, Divacky Roman <xdivac02@xxxxxxxxxxxxxxxxx>:
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

You would use something like:

#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/systm.h>
#include <sys/resource.h>

#include <vm/vm_page.h>

...
int
lock_and_fetch(const void* mem1, const void *mem2)
{

mtx_lock(&vm_page_queue_mtx);
if (fubyte(mem1) == -1 || fubyte(mem2) == -1) {
mtx_unlock(&vm_page_queue_mtx);
return(EINVAL);
}
/* Operations... */
mtx_unlock(&vm_page_queue_mtx);

return(0);
}

It prevents to virtual pages to be passed through queues.

Erm, but if fubyte() had to page the file in from disk you would
have to sleep while holding the vm_page_queue_mtx, and that's not
allowed.

--
John Baldwin
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: VM question related to faults
    ... > while working on SoC linuxolator project I am in a need of this: ... > where the mem1/mem2 access can trigger fault. ... I am trying to access user-space memory from kernel. ...
    (freebsd-hackers)
  • Re: VM question related to faults
    ... where the mem1/mem2 access can trigger fault. ... I am trying to access user-space memory from kernel. ...
    (freebsd-hackers)
  • Re: VM question related to faults
    ... Divacky Roman wrote: ... where the mem1/mem2 access can trigger fault. ... I need to check from kernel if some memory is accessible and then perform an operation on this memory. ... any contents in user space should be copied into kernel space ...
    (freebsd-hackers)
  • [UNIX] Linux Kernel do_brk() Vulnerablility (Explained)
    ... Get your security news from a reliable source. ... A critical security bug has been found in the Linux kernel 2.4.22 (and ... earlier) memory management subsystem. ... for the code working at the lowest privilege level. ...
    (Securiteam)
  • Re: Cached memory never gets released
    ... Stock linux 2.4.26 kernel. ... Due to flash bug 3M of memory gets lost due to font memory getting lost ... The output of "free" cache number steadily grows. ... longer to exhaust all of system memory with the cache. ...
    (Linux-Kernel)