difference between virtual page permission bit and area struct permission bit

Viewed 301

I'm a beginner in Linux and C, have a question about the virtual page permission bit and area struct permission bit. As the pictures below show:

enter image description here

enter image description here

What I don't understand is, since we have page-level permission control, what's the point to have area struct level permission control? if we want all of the pages in one area to be read-only then we just set every virtual page's read bit to be yes and write bit to be 0, so why double define?

2 Answers

The page-level permissions are set on demand when pages are mapped in and out! The vm_area_struct is used to check what the permissions for the page itself should be.

The CPU itself checks the page level permission bits each and every time any bytes are read from or written to the page.

In your question you are hitting upon the difference between virtual memory translation and logical memory translation. Virtual memory is the simulation of memory using secondary storage. Logical memory is the redirection of addresses to physical addresses.

Page tables define the logical memory translation. Operating system tables define the virtual memory translation.

Related