Understanding the IA-32e mode paging structures/translation
Posted: Wed Jan 12, 2011 12:26 pm
Hello,
1)
I want to make sure that I understood %topic% properly.
The 64bit linear address has its 48bits used only. Split into:
The CR3 points to the PML4 physical address.
So, given a linear address L, to convert it to physical:
1. CR3 -> PML4 physical base, then multiply by 4k
2. Now select a PML4 entry: PML4[L.PML4] -> Takes us to a 4k page structure (the PDPT)
3. Given the PDPT (which has 512 entries) select a page directory:
PDPT[L.DirectoryPtr] = PageDir
4. Now PageDir is another 4k page structure that has 512 entries. Each entry points to a page table
5. Select the page table: PageDir[L.Directory] = PageTable
6. Now again the page table has 4k of size and 512 PTE entries, we select a PTE
PTE = PageTable[L.Table]
Physical = PTE.page_frame * 4kb + L.Offset
Is my understanding correct?
2)
Assume we use 4kb pages. To pre-create a PML4, we need:
4k (for the PML4) + (4k (PDPT) * 4k (PD) * 4k (PT) ) = 0x1000001000L of memory space, right?
So in the case of 4k pages, it is better to allocate each 4kb structure on demand.
3)
If we want to pre-create a 2mb page / PML4 structure:
4k (for the PML4) + (4k (PDPT)* 4k (PD) ) = 0x1001000, right?
Thanks.
1)
I want to make sure that I understood %topic% properly.
The 64bit linear address has its 48bits used only. Split into:
Code: Select all
PML4, Directory Ptr, Directory, Table, Offset
So, given a linear address L, to convert it to physical:
1. CR3 -> PML4 physical base, then multiply by 4k
2. Now select a PML4 entry: PML4[L.PML4] -> Takes us to a 4k page structure (the PDPT)
3. Given the PDPT (which has 512 entries) select a page directory:
PDPT[L.DirectoryPtr] = PageDir
4. Now PageDir is another 4k page structure that has 512 entries. Each entry points to a page table
5. Select the page table: PageDir[L.Directory] = PageTable
6. Now again the page table has 4k of size and 512 PTE entries, we select a PTE
PTE = PageTable[L.Table]
Physical = PTE.page_frame * 4kb + L.Offset
Is my understanding correct?
2)
Assume we use 4kb pages. To pre-create a PML4, we need:
4k (for the PML4) + (4k (PDPT) * 4k (PD) * 4k (PT) ) = 0x1000001000L of memory space, right?
So in the case of 4k pages, it is better to allocate each 4kb structure on demand.
3)
If we want to pre-create a 2mb page / PML4 structure:
4k (for the PML4) + (4k (PDPT)* 4k (PD) ) = 0x1001000, right?
Thanks.