Some questions with regard to emul_l4rm.c

Leon Brits ljbrits at
Fri Apr 1 14:21:36 CEST 2005

Hi all,

I am trying to understand the workings of the emul_l4rm.c.

Please allow me to explain how I understand the working of this file so
that you can correct me.

When calling l4rm_attach(), the function l4rm_do_attach() gets called.
This function calls reserve_virtual_area() which uses mmap(). Mmap()
searches for an available area (with a certain size) in the calling
process's virtual memory. After finding such an area it remaps memory,
allocated using kmalloc() by /dev/zero, to the newly found virtual
memory space. Kmalloc() allocates memory from the l4linux dataspace and
that piece of memory is now mapped into user space.
Next, the call to l4dm_map_pages(), maps my specified dataspace's pages
into this mapped virtual address.

Q1: Why go thru the first memory mapping of the kmalloc-ed memory into
user space if immediately after it is remapped again by l4dm? Seems like
a waste of the l4linux dataspace.

Q2: Can the free virtual memory area be determined by another method and
then call l4dm_map_pages()?

Q2: When l4_fpage_unmap() is called, is the previous mapping to the
pages of the kmalloc-ed memory restored?

Thanks for your time.

More information about the l4-hackers mailing list