Hi, I have a few questions about paging.
As I see it, paging works with the kernel looking up the PHYS address of a 4KB block in the page table, pointed to by the page directory which contrains page tables containing the PHYS address of the virtual 4KB blocks pointed to by the page table entrys...
Can each page directory entry only address 4MB of memory?
Does the page size have to be 4KB?
Questions about paging
Hi,
Yes, each Page Table represents a 4MB range, split in to 4KB pages and so each PTE has to be 4kb.
However, If you are looking for larger pages, simply pointing a PDE to a 4MB range (instead of a page table) and setting bit 7 of that PDE allows you to use 4MB pages (you do not need any page tables for this). This requires setting the Page Size Extensions (bit 4) flag in CR4.
If you are using either PAE or long mode, the system changes somewhat. In this system, each and PDE is 64 bytes. This means that each PDE only represents 2MB of virtual space rather thatn 4MB. You therefore have a Page Map Level 4 table (PML4) and a Page Directory Pointer Table) which take you up to 256TiB of virtual address space.
HTH
Adam
Yes, each Page Table represents a 4MB range, split in to 4KB pages and so each PTE has to be 4kb.
However, If you are looking for larger pages, simply pointing a PDE to a 4MB range (instead of a page table) and setting bit 7 of that PDE allows you to use 4MB pages (you do not need any page tables for this). This requires setting the Page Size Extensions (bit 4) flag in CR4.
If you are using either PAE or long mode, the system changes somewhat. In this system, each and PDE is 64 bytes. This means that each PDE only represents 2MB of virtual space rather thatn 4MB. You therefore have a Page Map Level 4 table (PML4) and a Page Directory Pointer Table) which take you up to 256TiB of virtual address space.
HTH
Adam
Add a second page directory entry. Each PDE represents 4MB. The PD has 1024 entries. This means you have 4GB of virtual address space (in 32 bit mode without PAE enabled). You can find the PDE of any virtual space by virtual_addresss / 0x400000.
If you do not have PSE enabled, the PDE then points to the PT (as you said). Each PTE points to a 4k range.
If you do have PSE enabled and bit 7 of the PDE is set, you do not need a PTE - the PDE just points to a 4MB contiguous physical space.
Cheers,
Adam
If you do not have PSE enabled, the PDE then points to the PT (as you said). Each PTE points to a 4k range.
If you do have PSE enabled and bit 7 of the PDE is set, you do not need a PTE - the PDE just points to a 4MB contiguous physical space.
Cheers,
Adam