#define PGDIR_SHIFT 39 #define PTRS_PER_PGD 512
#define PUD_SHIFT 3 0 #define PTRS_PER_PUD 512
#define PMD_SHIFT 21 #define PTRS_PER_PMD 512
The macros ptrs_per_xxx specify how many pointers (i.e., different values) a given directory entry can represent. Since AMD64 employs 9 bits for each directory, 29 = 512 pointers fit into each.
The kernel also needs a means of extracting the individual components from a given address. The kernel uses the bitmasks defined below to do this.
#define PGDIR_MASK (~(PGDIR_SIZE-1))
The masks are applied on a given address by simple bitwise addition.
Continue reading here: Format of Page Tables
Was this article helpful?