Flexpage: shared Mem
adam at os.inf.tu-dresden.de
Thu May 12 00:20:02 CEST 2016
On Tue May 10, 2016 at 16:44:35 +0200, ba_f wrote:
> writing a L4Linux Driver I'm expiring the C-Interface and low level(?)
> So far, I can push a Dataspace Capability via flexpage, and the receiving
> server is able to read its content.
> But, whatever the server writes in that mem-region doesn't appear on the
> clients side.
That sounds pretty confusing to me. When you read the proper contents
that would mean you're writing to the same physical memory location, so
given you do not read from a copy and the write is successful, the
update should be visible in the memory.
> /* client.c */
> l4_fpage_t fpage = l4_obj_fpage( dataspace, 0, L4_CAP_FPAGE_RW );
> l4_utcb_mr()->mr = size;
> l4_utcb_br()->br = fpage.raw;
That is more like a setup for a receive. Please have a look at some
calls in l4sys, such as l4_scheduler_run_thread or l4_task_map which
send caps to the callee. Note that the l4_map_obj_control+l4_obj_fpage
pair(s) must be at the end of the MR-array. And do not forget proper
values for the sending l4_msgtag.
> /* server.c */
> l4_utcb_br()->br = dataspace | L4_RCV_ITEM_SINGLE_CAP;
> l4_ipc_wait(l4_utcb(), 0, L4_IPC_NEVER);
> // allocate, and attach Dataspace
> // read & write Dataspace
> l4_utcb_mr()->mr = returnValue;
> l4_ipc_reply_and_wait(l4_utcb(), l4_msgtag(0, 1, 0, 0),
> 0, L4_IPC_NEVER);
> As I am creating the fpage with L4_CAP_FPAGE_RW my guess was I can write to
> that mem-region and the client can read my changes.
When you could not write, you'd get a page-fault and your program would
> Anyway, maybe I need some more understandings about capabilities &
> (Are there any precise slides or papers about this topic?)
> So, the client creates a dataspace capability and allocates some memory.
> But, what happens when the flexpage is pushed to the server?
> The capability is copied and both pointing to the same allocated memory, or
> is the Cap and(!) the memory it is pointing to copied to server?
When you transfer a capability to a dataspace, you just transfer the
access rights to that particular dataspace to the other party. Not the
memory. After the transfer, both can talk to the very same dataspace,
map it and use it. Typically when sharing dataspaces that is called
Adam adam at os.inf.tu-dresden.de
More information about the l4-hackers