Re: x86-64 Paging - Just to be sure
Posted: Sun May 21, 2017 5:19 am
Okay so PML4T[511] -> points to PML4T[0] as a fake PDPT -> points to PDPT[0] as a fake PD -> points to PD[0] as a fake PT -> points to PT[0] as a fake beginning of a page, right? Wouldn't that also mean that i can't acces PML4T to PD? Because their entry points to another table?eryjus wrote: If I am reading and understanding your concern correctly, you are having trouble understanding recursive mapping. Check out this wiki section: http://wiki.osdev.org/Page_Tables#Recursive_mapping. You can also search the forum (I know I had a post myself on the topic from several years ago). The key here is that you only need a single recursive map at the top level (where the PML4 has an entry that points back to itself) and the rest of the math works out. You do not have to map each table.
Taking the last entry in the PML4 is the easiest in my opinion to understand. Sit down with a piece of paper and prove to yourself that you can reach all of your table structures when you set PML4[511] = PML4. Use that as a fact as you traverse your tables. It's elegant, but that also means it can take some time to get your head around what is really happening.
Wait maybe i'm getting it: If i use the highest index for all tables, the PML4T will go through a 4 * loop and land at PML4T[0] as a page[0]... Right?
And because each page has to be 4K aligned, i can set the offset to 4K and get PML4T[1] as a page[1], right?