paging 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
Googles

paging question

Post by Googles »

Just a thought: Do you create the whole pagetable direct (takes 4Mib) or do you create pagestables & pagedirectories as user/syste m components ask for it (dynamic).

If you are dynamicly creating pagetables then how do you solve the following problem: Someone tries to reserve mem addr 0b000000h - 0B400000h. When your function creates a pagedirectory and pagetables for the addr it finds out that it needs to map the memory addr where the pagetables resides on... Whould you use recursive functions or how would you solve it?
Odd Little Child

Re:paging question

Post by Odd Little Child »

If paging is enabled, your page directory needs to be mapped into the virtual address space somewhere, or you won't be able to map anything (unless you drop out of paging, map, and reenable paging). A spiffy way to do this is to map the page directory into the last entry of itself, so it will appear as the last page in the virtual address space (and the page tables will be the other pages in the last 4 meg).

Then, to map something into the current address space for which there is no page table, use your physical memory manager to allocate a page, and insert its address into the page directory where you need a new page table (and possibly flush the tlb). After that, the new page table will be mapped into the virtual address space at one of the pages in the last 4 meg. You can make any modifications you need to there, flush again, and the mapping is done. If you later unmap and find that all the entries in a particular page table are unmapped, you can free the table and zero its entry in the page directory.

Hope that makes some sense and helps.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:paging question

Post by Candy »

And this is why guest posting shouldn't be disabled.

I used to map it at some "random" place != 0xFFFFF000, and I had a recursive function that kind of wasted memory, you need to map more for mapping then... Recursive does end however, if you realise when you're trying to map something already mapped. For normal stuff it's like 2x as slow, but for my goal (amd64) it's 3x as slow, so I prefer the other method detailed above.
Post Reply