August 28th, 2013, 09:44 AM
Tricky : how to put the same page twice in the same address range
What I'm trying to do is a little tricky. I want to implement a shared buffer ring with page sharing. It means I share a page between 2 processes and this page is used has the buffer of a buffer ring. I try to use the trick introduced by Michael Tyson, Philip Howard and Kurt Davis : "virtual copy of the buffer is inserted directly after the end of the buffer, so that you can write past the end of the buffer, but have your writes automatically wrapped around to the start". The goal is to get an address range in the virtual memory which size is twice the size of a page (the buffer in my case). Then I put my page twice in this address range so there is twice the same data in the address range. All that is really tricky and hard to understand, I hope I did no mistake.
I was wondering if someone knew which functions I have to use to do that ? From the user space, I need to allocate a page and to map it twice in an address range. I thank you for your help.
August 28th, 2013, 01:37 PM
Well it would be a lot easier if you told us which OS/Compiler you're using, so we could suggest which API to use.
August 29th, 2013, 03:36 AM
Oh yes, sorry, long day. I use Linux (Ubuntu) and the Gnu compiler (gcc). I think I have to allocate a virtual memory area and then put the page twice in it, but I don't understand how to do that.
I have an idea on how to do it by creating a module which allocates the page and implements the mmap function, but I would like to avoid working in the kernel space if possible.
August 29th, 2013, 03:15 PM
August 30th, 2013, 03:01 AM
Thanks, I knew how shared memory work, but I'm not trying to share data between processes but between virtual machines (that's why I need to work with pages). I know how to do that stuff with a module in the kernel space, but I would like to try another solution, if it exists.
August 30th, 2013, 01:49 PM
> but I'm not trying to share data between processes but between virtual machines (that's why I need to work with pages)
Perhaps you should have been more open about your intentions in the first instance.
Next question, what is your virtualisation solution?
The whole point about a VM is that it is very well sand-boxed away from other VM's. Assuming that this is at all possible, it represents a gaping security hole IMO.
September 2nd, 2013, 07:45 AM
Sorry, I'm using Xen and several domU's must access to a device connected on the PCI port. As only one machine at a time can access the PCI port, I built a server running on dom0 to receive and execute requests on the device.
I'm building a ring buffer to transfer data and requests without copy between the domU's and the dom0. I know sharing page can be a security breach, but I've got no other choices.
I think that what I'm willing to do is not possible in the user space, I will write a module to allocate pages and mmaping them in the processus.
Thanks for your help.