Page protection in kernel mode or not?
Posted: Wed Jan 12, 2011 8:11 pm
How do you setup your text and data for the kernel? Do you setup separate text and data region with different protections (execute for the text and read write for data) or do you just put it as one big region.
The advantage of having it one region is that you can use large pages without wasting too much memory and let kernel heap continue on the pages. For example you let the kernel heap expand upwards in large steps of 2MB for example. The benefit is that you get less TLB misses with large pages and have the option to lock one or more TLB entries. The disadvantage is that you get less protection in the kernel and more errors might slip through. Also once you allocate a new large page you will probably never get rid of it because of fragmentation.
You can also do the traditional and split code and data with different protection settings. Litter 4KB pages around but not waste RAM as much.
What do you think? Is the advantage of only using large pages that way in the kernel pages really worth it?
The advantage of having it one region is that you can use large pages without wasting too much memory and let kernel heap continue on the pages. For example you let the kernel heap expand upwards in large steps of 2MB for example. The benefit is that you get less TLB misses with large pages and have the option to lock one or more TLB entries. The disadvantage is that you get less protection in the kernel and more errors might slip through. Also once you allocate a new large page you will probably never get rid of it because of fragmentation.
You can also do the traditional and split code and data with different protection settings. Litter 4KB pages around but not waste RAM as much.
What do you think? Is the advantage of only using large pages that way in the kernel pages really worth it?