MathiLpHD wrote:PML4T[511] -> points to PML4T[0]
Almost. PML4T[511] points to the address of the table PML4T, where you can then index that table as your would any other table.
Let's decompose one to illustrate. I want to allocate a new frame for the page at canonical address 0x0000 5566 7788 9000. By the way, I am checking my work against table 4-2 in the Intel Software Developer's Manual as I write this -- it's a good reference for you to have on-hand. Also, note the slight difference between traversing this address to access it's page versus traversing these tables to
MANAGE its page.
* We are managing a page and assigning a frame to a page, so we will select PML4T[511]. This is not dependent on the address we are managing. This is binary 0b1 1111 1111.
* Next bits 47:39 (the PML4 entry number for access) are used to select which PDPT entry we will select for MANAGEMENT. The result is 0b0 1010 1010.
* And then the bit 38:30 (the PDPT entry number for access) are used to select which PDT Entry we will select for MANAGEMENT. The result is 0b1 1001 1001.
* Next we use the bits 29:21 (the PD entry number for access) are used to select which PT Entry we will select for MANAGEMENT. The result is 0b1 1011 1100. Also, note we now have a page.
* Finally we use bits 20:12 (the PT entry number for access) as an offset into the resulting PAGE we now have for MANAGEMENT. The result is 0b0 1000 1001. You will use this index to MANAGE your Page Table Entry for address 0x0000 5566 7788 9000.
The resulting address you used to get to that page table entry was:
Code: Select all
0b1111 1111 1111 1111 1111 1111 1010 1010 1011 0011 0011 1011 1100 0000 0000 0000
--- or ---
0xffff ffaa b33b c000
And then take entry 0x089. You should be able to tie the bit pattern back above, remembering the most significant 16 bits are for canonical address bit extension.
OK, so what if you wanted to manage the PD for that same address? You would use PML4T[511] and PDPT[511] and then use bits 0b0 1010 1010 and 0b1 1001 1001 to complete the traversal to a Page, and then use bits 0b1 1011 1100 as the offset into that page. Note that you are discarding bits, which conceptually makes sense because you are managing a higher-level table. The higher you want to go in your structures, the more you use PML4T[511] and the more bits you ignore. I will leave it to you as an exercise to determine this address and offset like I did above, and consider how to manage the PDP and PML4 tables using the same method.
Also, I encourage you to stick with this topic until you understand it properly. It will help down the road.
EDIT: Your post hit as I was writing mine. I'm going to reiterate what others have said. Start with 4K pages -- it makes life easier believe it or not. Then if you want to mix page sizes down the road you can once you absolutely understand the concept.