paging in AMD64

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
diurpaneus
Posts: 3
Joined: Sun Oct 10, 2010 10:14 am

paging in AMD64

Post by diurpaneus »

Hello,
I'm trying to understand the AMD64 paging mode by following Stephanvanschaik/Setting Up Long Mode tutorial at: http://wiki.osdev.org/User:Stephanvansc ... _Long_Mode. But I can't understand how to setup the PML4E field.
According to the AMD64 Manual, volume 2 at page 131: bits 51 to bits 12 represent the pointer to the base of the PML3 table. So I was expecting the first PML4 entry to be: 0x2000003. But in his tutorial he sets the first entry to 0x2003( bit 0 and bit 1 are the P and R/W flags). The tables are located at:
PML4 0x1000
PML3 0x2000
PML2 0x3000
PML1 0x4000
Can someone explain why the PML tables are setup like this?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: paging in AMD64

Post by Combuster »

bits 12..48 match bits 12..48 of the address (and not 36..0). There's no point in storing 12 zeroes when each pagetable must be page aligned - instead those 12 bits are used as flags.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply