Emulating cpu page protection in userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux