PDPT Present flag

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

PDPT Present flag

Post by evoex »

Hi all,

I have a question regarding PAE. In the Wiki (http://wiki.osdev.org/Setting_Up_Paging_With_PAE) the PDPT has only one entry with the "present" bit set to 1. The other 3 entries are unused and thus it seems that they are not required to be present. However, when looking up the PDPT in the Intel manual (https://communities.intel.com/servlet/J ... amming.pdf page 3-35) it says:
The present (P) flag (bit 0) in all page-directory-pointer-table entries must be set to 1 anytime extended physical addressing mode is enabled; that is, whenever the PAE flag (bit 5 in register CR4) and the PG flag (bit 31 in register CR0) are set. If the P flag is not set in all 4 page-direc- tory-pointer-table entries in the page-directory-pointer table when extended physical addressing is enabled, a general-protection exception (#GP) is generated.
So that seems to indicate one would need to make 4 valid page directories before enabling PAE. If they are unused, it seems that they should point to an all-zero page directories (at least none of the pages being marked present), and the entries in the PDPT pointing to these all-zero page directories with the present bit being set to 1.
Is this correct? If so, it seems the Wiki is slightly wrong. But then again, I've tried the Wiki's method and it works fine. So is this simply undefined behaviour (even though it specifically says an exception must be generated)? Or am I missing something here?

Thanks in advance
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: PDPT Present flag

Post by thepowersgang »

The version I have of the intel manuals (June 2010, Vol 3A, section 4.4) does not mention this requirement. So according to that, the tutorial is correct.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PDPT Present flag

Post by Brendan »

Hi,
thepowersgang wrote:The version I have of the intel manuals (June 2010, Vol 3A, section 4.4) does not mention this requirement. So according to that, the tutorial is correct.
This is the first time I've noticed a "present bits in PDPT entries must be set" requirement; so I did some more checking.

It seems Intel manuals from 2002 and earlier do say the present bit must be set, and manuals from 2004 and later say it can be set or clear. For the 2004 manual, "Chapter 18, IA-32 Compatibility" has no mention of any older CPUs requiring the present bit set (but does have various compatibility differences going back to 8086). For all manuals, the section in the "exception reference" that lists all of the possible causes of a general protection fault doesn't mention anything about general protection faults caused by PDPT entries that were clear (even though they do include things like "Setting any reserved bits in PDPT entries to 1 when PAE is enabled causes GPF").

For these reasons I'm tempted to assume that the older manuals were wrong, the mistake was corrected between 2002 and 2004, and there never was a requirement for the present bits in PDPT entries to be set.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: PDPT Present flag

Post by evoex »

Ok, good to know. Thanks for the answers, guys!
Post Reply