Hi Oak,

1. Looks fine to me. You can test the permissions yourself though by attempting to write to that page before and after the Remap
2. Unfortunately no, there is no more efficient way in seL4. Only suggestion I can make is use larger pages where possible
3. Since you have not specified I will assume, for this explanation, that you are using the ARM IMX.6 Sabre platform. On ARM you can never just 'flip some bits' to manipulate any paging structures, as information needs to be propagated out of the L1 cache and TLB entries invalidated. I'm not sure what you mean by 'page-related operation', you're doing a remap, that is a page related operation is it not? I also cannot see how the implementation of remap in any way matters to you, the observable difference between the optimal remap (modify paging structure, clean cache, invalidate tlb) used by seL4 and unmap (modify paging structure, clean cache, invalidate tlb) then map (modify paging structure, clean cache) is a redundant memory write and cache clean, which aside from impacting execution time have no visible effects as the final memory, cache state and TLB state is the same.

Adrian

On Tue 02-May-2017 3:21 AM, Norrathep Rattanavipanon wrote:
Hello,

I have some questions about how to change access rights in seL4. (I'm using native seL4, not camkes)

1) Currently, I'm using seL4_ARCH_Page_Remap to change an access right (from R/W to R/O) to a specific page (of other processes) at run-time. I'm doing as follows:

seL4_CPtr frame = vspace_get_cap(&(p.vspace), p.thread.stack_top-1); // only for the stack
int error = seL4_ARCH_Page_Remap(frame, ppd.cptr, seL4_CanRead, seL4_ARCH_Default_VMAttributes);

Am I doing it correctly? The code seems to work fine for me but I just want to double check.

2) If my understanding in 1) is correct, the remap function only takes 1 cap at a time. 
So if I want to modify access rights of many pages, do I have to call the remap function multiple times?
Or is there a more efficient way to do so?

3) I am also curious how the kernel handles the remap function. Does it simply flip/change some bits? Or does it involve page-related operations as well?
e.g. unmap that page first and then remap the same region with a new access right? I guess it should be the former but I need to be sure about that.

Thank you,

Oak


--
Norrathep (Oak) Rattanavipanon
M.S. in Computer Science
University of California - Irvine


_______________________________________________
Devel mailing list
Devel@sel4.systems
https://sel4.systems/lists/listinfo/devel