next up previous contents index
Next: 4.3 Using Page Table Up: 4. Page Table Management Previous: 4.1 Describing the Page   Contents   Index

4.2 Describing a Page Table Entry

As mentioned, each entry is described by the structs pte_t, pmd_t and pgt_t for PTEs, PMDs and PGDs respectively. Even though these are often just unsigned integers, they are defined as structs for two reasons. The first is for type protection so that they will not be used inappropriately. The second is for features like PAE on the x86 where an additional 4 bits may be used for addressing more than 4GB of memory. To store the protection bits pgprot_t is defined which holds the relevant flags and is usually stored in the lower bits of a page table entry.

For type casting, 4 macros are provided in asm/page.h which takes the above types and returns the relevant part of the struts. They are pte_val, pmd_val, pgd_val and pgprot_val. To reverse the type casting, 4 more macros are provided __pte, __pmd, __pgd and __pgprot.

Where exactly the protection bits are stored is architecture dependent. For illustration purposes, we will examine the case of an x86 architecture without PAE enabled but the same principles apply across architectures. For this one, the pte_t is a 32 bit integer stored within a struct. Each entry in this points to the address of a page frame but all the addresses are guaranteed to be page aligned, therefore there is PAGE_SHIFT (12) bits in that 32 bit value that are free for status bits of the page table entry. A number of the protection and status bits are listed in Table 4.1 but what bits exist and what they mean vary between architectures.


Table 4.1: Page Table Entry Protection and Status Bits
\begin{table}\begin{center}
\begin{tabularx}{13.5cm}{\vert l\vert X\vert}
\pa...
...page is accessed \\
\par\hline
\par
\end{tabularx}
\end{center} \end{table}



next up previous contents index
Next: 4.3 Using Page Table Up: 4. Page Table Management Previous: 4.1 Describing the Page   Contents   Index
Mel 2003-01-14