You need to map an entry of the page map level 4 table, the page directory pointer table and the page directory table to the pml4 page. This will let you access all levels of the page table hierarchy using a fractal memory map.
Here's what my code looks like:
Code:
pml4 = (PageTable*) KeAllocatePage();
pdp = (PageTable*) KeAllocatePage();
pd = (PageTable*) KeAllocatePage();
KeZeroPage(pml4);
KeZeroPage(pdp);
KeZeroPage(pd);
// Set up the page table elements needed for fractal memory
pml4->pages[510].raw = ((uint64) pdp) | 0x3;
pdp->pages[510].raw = ((uint64) pd) | 0x3;
// Set up fractal memory
pml4->pages[511].raw = ((uint64) pml4) | 0x3;
pdp->pages[511].raw = ((uint64) pml4) | 0x3;
pd->pages[511].raw = ((uint64) pml4) | 0x3;
Using this, the page tables start at 0xFFFFFF8000000000.
The page directories start at 0xFFFFFF7FC0000000.
The page directory pointers start at 0xFFFFFF7FBFE00000.
And you can access all levels of the page table hierarchy directly.