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.
You're missing a level of indirection, and actually end up mapping 32 1GB pages instead.
The value in CR3 contains the address to the PML4, which maps 256TB.
Each entry in the PML4 (aka a PML4E) maps 512GB.
Each entry in the PML4E (a PDPE) maps 1GB.
Each entry in the PDPE (a PDE) maps 2MB.
Each entry in the PDE (a PTE) maps 4KB.
Rudster816 wrote:You're missing a level of indirection, and actually end up mapping 32 1GB pages instead.
The value in CR3 contains the address to the PML4, which maps 256TB.
Each entry in the PML4 (aka a PML4E) maps 512GB.
Each entry in the PML4E (a PDPE) maps 1GB.
Each entry in the PDPE (a PDE) maps 2MB.
Each entry in the PDE (a PTE) maps 4KB.
I'm not using the 4KiB level, but I don't see how this is so.
PML4 (512 GiB | located at 0x600000)
|
|--> PML3 (1 GiB | located at 0x601000)
|
|-> PML2 (2 MiB | located at 0x602000)
|
|--> Page at location pointed to by PML2 [(i * 0x200000) | PRESENT | WRITABLE | LARGE]
Is what I'm doing.... where am I missing an indirection table?
EDIT: Sorry, I misread your post. I did misunderstand the role of the PML4 and then proceeding on.
What have you done with CR4 to get large pages working?
"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 ]
Just a thought. Do you think it would be possible to make it configurable - you set the page size you want at compile time. I mean, additional configurability does not hurt as long as the code is still readable. And what if you wanted to go back to 4kb pages again in the future.
Sandras wrote:Just a thought. Do you think it would be possible to make it configurable - you set the page size you want at compile time. I mean, additional configurability does not hurt as long as the code is still readable. And what if you wanted to go back to 4kb pages again in the future.
The amount of mmu code is not huge. It's simpler to just write two version instead of unifying them.
Furthermore, on 4KiB page you can handle PML4/PDPT/PD fault exactly the same way as ordinary address region, while supporting 2MiB page you need to handle them differently - you won't allocate 2MiB for an page structure.
bluemoon wrote:The amount of mmu code is not huge. It's simpler to just write two version instead of unifying them.
Furthermore, on 4KiB page you can handle PML4/PDPT/PD fault exactly the same way as ordinary address region, while supporting 2MiB page you need to handle them differently - you won't allocate 2MiB for an page structure.
I suppose I wouldn't know these things. Paging is what I'm at right now for the first time after all. : )
By the way I found it more useful to have the slot id for recursive page directory be configurable, especially when working with 64bit where you may shuffle/reorder things around in the huge address space early development phase.
For example, I have these setting on 32 and 64bit kernel: