X86 Long Mode PML4E/PDPE question

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
Bipman
Member
Member
Posts: 40
Joined: Wed Mar 15, 2017 9:22 am

X86 Long Mode PML4E/PDPE question

Post by Bipman »

Hi all.

I'm just setting up a 64 bit test in assembler so setting up the translation tables. I'm setting as 1GB tables and had a question on the structure. I've seen a few examples where say their PML4E table is at address 1000 and the PDPE is at 2000 etc. In the PML4E table they are setting the pointer to 2003 hence 2000 with two bits set for the switches. In the AMD docs, it shows the first 8 bits as switches and then 4 bits ignored so the address starts at bit 12. What I can't relate to is how the address they show is correct?

Bipman
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: X86 Long Mode PML4E/PDPE question

Post by FusT »

You're confusing bits and bytes. The difference between 0x2000 and 0x2003 is 2 bytes, not 2 bits
Bipman
Member
Member
Posts: 40
Joined: Wed Mar 15, 2017 9:22 am

Re: X86 Long Mode PML4E/PDPE question

Post by Bipman »

Sorry I didn't mention is was ox2003 i.e. hex. Isn't ox2000 + 11b = ox2003? Anyway, what I am trying to say (I think) is do the first 12 bits of the field that make up the address also include the flags?

Bipman
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: X86 Long Mode PML4E/PDPE question

Post by JAAman »

Bipman wrote:Sorry I didn't mention is was ox2003 i.e. hex. Isn't ox2000 + 11b = ox2003? Anyway, what I am trying to say (I think) is do the first 12 bits of the field that make up the address also include the flags?

Bipman
yes

basically, since the address must be aligned on a 4K boundary, the lower 12 bits of the address will always be 0, therefore, the CPU ignores those bits (assumes they are all 0) and those bits can then be re-used for various flags -- all versions of x86 paging do this
Bipman
Member
Member
Posts: 40
Joined: Wed Mar 15, 2017 9:22 am

Re: X86 Long Mode PML4E/PDPE question

Post by Bipman »

Excellent thanks :D Just what I needed to know.

Bipman
Post Reply