Emulating cpu page protection in userspace

Manish Katiyar mkatiyar at gmail.com
Wed May 15 18:31:33 EDT 2013


Hi,

This is really not a linux kernel question, but I guess there are enough OS
specialists on this thread that someone can point me in the right direction.

Some context
----------------------
On normal hardware machines its possible to change the page table flags to
make a particular 4K page area as readonly or readwrite. This is generally
used for protecting against memory corruptions. Now even if you have
READONLY flags set in the page table, its possible to change the control
register of a particular cpu (in a multicore system) such that, that cpu
will not cause a fault/trap if you try to modify the contents of the page.
What this means is let's say I have 4 cpus, and I change the control
register on cpu-1, only cpu-1 will see the page as readwrite and others
will see it as readonly.

I've seen that this behavior is honoured in virtualised vmware environments
too, so I'm assuming that this cpu behavior is getting simulated somehow.

My problem is that I want to simulate the same behavior in userspace, where
my 4 cpus map to 4 pthreads. I change the permissions of my memory area
using mprotect() but then I also want to have a similar capability where I
can flip/change something in one of the threads and that thread should be
able to modify the region, while for other pthreads it is still a readonly
page.

Any suggestions how vmware or other virtualised environments do this, or is
this even possible ? Any pointers to the code is appreciated. (Sorry no
locking/synchronisation solutions pls).

-- 
Thanks -
Manish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130515/80a8604f/attachment.html 


More information about the Kernelnewbies mailing list