I cannot understand dataspace very well. I have some questions about it. Each time I want to alloc a piece of memory, I must create a dataspace first?
I look at the example code of memory allocation. I found after create adataspace, we call L4Re::Env::envhttp://l4re.org/doc/classL4Re_1_1Env.html#aa1181d6256037deda5b5f83c2006ba60()->mem_alloc()->alloc() to alloca memory via dataspace. Can I call this function multiple times on the same dataspace instance without free? If so, what is its effect?
In addtion we use attach to map the dataspace. Can I attach the same dataspace multiple times without free? In this case, does it mean that the same physical memory is mapped into different virtual address?
Hi,
On Sat May 10, 2014 at 11:23:47 +0800, Yuxin Ren wrote:
I cannot understand dataspace very well. I have some questions about it. Each time I want to alloc a piece of memory, I must create a dataspace first?
I think you mean that you need to allocate a capability before calling mem_alloc()->alloc()? Yes, you need to do that for each new memory to be allocated.
I look at the example code of memory allocation. I found after create adataspace, we call L4Re::Env::envhttp://l4re.org/doc/classL4Re_1_1Env.html#aa1181d6256037deda5b5f83c2006ba60()->mem_alloc()->alloc() to alloca memory via dataspace. Can I call this function multiple times on the same dataspace instance without free? If so, what is its effect?
No, don't do that. free the dataspace at mem_alloc() before allocating new memory on the same dataspace (capability).
In addtion we use attach to map the dataspace. Can I attach the same dataspace multiple times without free?
Yes, you can do that.
In this case, does it mean that the same physical memory is mapped into different virtual address?
Yes, exactly.
Adam
Thank you very much for your reply. But I still have some questions. Can I alloc and free memory without dataspace?
I know we can do memory mapping over IPC, using L4::Ipc::Snd_fpage and L4::Ipc::Rcv_fpage. So after a client gets a piece of memory mapping in, how does it ummap that memory? Still use deattach or anyting else?
Does Fiasco manage memory in user level or kernel level? That is to say, attach and deattach function are just system call or normal IPC invoking some serve in the user level?
Thank you
On Sat, May 10, 2014 at 4:15 PM, Adam Lackorzynski < adam@os.inf.tu-dresden.de> wrote:
Hi,
On Sat May 10, 2014 at 11:23:47 +0800, Yuxin Ren wrote:
I cannot understand dataspace very well. I have some questions about it. Each time I want to alloc a piece of memory, I must create a dataspace first?
I think you mean that you need to allocate a capability before calling mem_alloc()->alloc()? Yes, you need to do that for each new memory to be allocated.
I look at the example code of memory allocation. I found after create adataspace, we call L4Re::Env::env<
http://l4re.org/doc/classL4Re_1_1Env.html#aa1181d6256037deda5b5f83c2006ba60
()->mem_alloc()->alloc() to alloca memory via dataspace. Can I call this function multiple times on the same dataspace instance without free? If so, what is its effect?
No, don't do that. free the dataspace at mem_alloc() before allocating new memory on the same dataspace (capability).
In addtion we use attach to map the dataspace. Can I attach the same dataspace multiple times without free?
Yes, you can do that.
In this case, does it mean that the same physical memory is mapped into different virtual address?
Yes, exactly.
Adam
Adam adam@os.inf.tu-dresden.de Lackorzynski http://os.inf.tu-dresden.de/~adam/
l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
On Tue May 13, 2014 at 20:56:54 +0800, Yuxin Ren wrote:
Can I alloc and free memory without dataspace?
The quick answer is: no. The reason is that there need to be some service (the allocator) which gives you the memory. And that allocator would need to talk a different protocol. However, the L4Re ones use dataspaces.
I know we can do memory mapping over IPC, using L4::Ipc::Snd_fpage and L4::Ipc::Rcv_fpage. So after a client gets a piece of memory mapping in, how does it ummap that memory? Still use deattach or anyting else?
When handling the virtual memory space directly with fpages both dataspaces and the region management are out of the game. You should still reserve that area with L4Re::Rm::reserve_area to block the area from use by the region management. Unmapping can be done, for example, via L4Re::Env::env()->task()->unmap().
Does Fiasco manage memory in user level or kernel level? That is to say, attach and deattach function are just system call or normal IPC invoking some serve in the user level?
Fiasco just provides the mechanism to established mappings (page table entries) to an address space (a task). Managing those mappings is up to user-space. So, for example, the region management is completely implemented in user-level.
Adam
For the unmapping stuff, can you tell me a little more in detail. I do not understand the parameters of unmap function. Thank you so much.
On Tue, May 13, 2014 at 3:55 PM, Adam Lackorzynski < adam@os.inf.tu-dresden.de> wrote:
On Tue May 13, 2014 at 20:56:54 +0800, Yuxin Ren wrote:
Can I alloc and free memory without dataspace?
The quick answer is: no. The reason is that there need to be some service (the allocator) which gives you the memory. And that allocator would need to talk a different protocol. However, the L4Re ones use dataspaces.
I know we can do memory mapping over IPC, using L4::Ipc::Snd_fpage and L4::Ipc::Rcv_fpage. So after a client gets a piece of memory mapping in, how does it ummap
that
memory? Still use deattach or anyting else?
When handling the virtual memory space directly with fpages both dataspaces and the region management are out of the game. You should still reserve that area with L4Re::Rm::reserve_area to block the area from use by the region management. Unmapping can be done, for example, via L4Re::Env::env()->task()->unmap().
Does Fiasco manage memory in user level or kernel level? That is to say, attach and deattach function are just system call or normal IPC invoking some serve in the user level?
Fiasco just provides the mechanism to established mappings (page table entries) to an address space (a task). Managing those mappings is up to user-space. So, for example, the region management is completely implemented in user-level.
Adam
Adam adam@os.inf.tu-dresden.de Lackorzynski http://os.inf.tu-dresden.de/~adam/
l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
On Tue May 13, 2014 at 17:45:46 -0800, Yuxin Ren wrote:
For the unmapping stuff, can you tell me a little more in detail. I do not understand the parameters of unmap function.
So the L4::Task::unmap() function takes two arguments. The first is a flexpage which can be constructed with the l4_fpage helper, like this: l4_fpage(address, L4_LOG2_PAGESIZE, L4_FPAGE_RWX) So in our case the fpage describes a piece of memory, with a start (address) and size (L4_LOG2_PAGESIZE, given in log2) and attributes (L4_FPAGE_RWX). For the unmapping, this yields to: l4_msgtag_t result; result = task->unmap(l4_fpage(address, L4_LOG2_PAGESIZE, L4_FPAGE_RWX), L4_FP_ALL_SPACES); if (l4_error(result)) // some error handling/message
So this means that this unmap call shall remove all access rights (L4_FPAGE_RWX), for task and its childs (L4_FP_ALL_SPACES) from memory region address to address + (1 << L4_LOG2_PAGESIZE) (what is just a single page in our case).
HTH, Adam
l4-hackers@os.inf.tu-dresden.de