Hi,
Colonel Kernel wrote:Basically, I see a problem with using a page directory entry as a page table entry as well. The problem is bit 6: the Dirty bit. For PTEs, the processor will set it when the corresponding page is written to. For PDEs, it is reserved and is supposed to be 0. I'm guessing that nothing happens if it's set to 1, but the manuals are pretty clear on this point (from section 3.7.6 on page 3-30 of IA-32 Volume 3):
In a page-directory entry that points to a page table, bit 6 is reserved and should be set to 0.
It seems this would depend on
which Intel manual you're reading. My hardcopy version says (from section 3.7.6 on page
3-27 of volume 3):
Dirty(D) flag, bit 6
Indicates whether a page has been written to when set. (This flag is not used in page-directory entries that point to page tables). [following/unrelated text skipped]
The newest electronic version I have (order number 253668-018), which includes long mode and virtualization extensions, says the same thing in from section 3.7.6 on page
3-29 of volume
3A.
Of course there's a major difference between
should and
must....
Perhaps a more worrying thing could be found in Chapter 5 - Interrupt 13, where it lists possible causes for general protection faults, including:
- If the PAE and/or PSE flag in control register CR4 is set and the processor detects any reserved bits in a page-directory-pointer-table entry set to 1. These bits are checked during a write to a control registers CR0, CR3, or CR4 that causes a reloading of the page-directory-pointer-table entry.
Colonel Kernel wrote:
So I doubt that this technique has been "blessed" by Intel.
Does anybody think this matters? If not, why not? If so, what should be done about it? Is there any technique that is similarly clean (the hackish nature of it notwithstanding) as the self-mapped page directory?
I wouldn't be surprised if "self-mapping" is the
reason why bit 5 remains reserved...
I guess I should also point out (before anyone gets worried about "self-mapping" in their long mode paging code, like I just did), that in the newest Intel manual there's a table describing which reserved bits are actually checked in different modes (see table 3-4 on page 3-44 and table 3-5 on page 3-45 in section 3.10.3.1 "Reserved Bit Checking").
According to these tables bits 5 and 6 are only ever checked in page directory pointer table entries when PAE and/or PSE is enabled and long mode is disabled.
Cheers,
Brendan