Page 1 of 1

Relationship between Page Directory & Page Table

Posted: Tue Sep 06, 2016 12:04 am
by snijj
Hey,

So I've run in to a bit of confusion whilst implementing my paging algorithm. The problem is specifically one paging is activated. How do I create/construct new page tables?

When I go to create a new page for a page structure (table or directory) I request a physical page from the PMM. The problem is my PMM is returning physical addresses (which is how it should be as far I'm concerned, but please correct me if I should address this), and thus I'm unable to build the structure in the page. Typically this occurs as another page fault exception stating that r/w permissions are incorrect, address not found, etc.

One solution I've thought is to reserve a single page inside the Kernel Heap for creating paging structures. Point that page at the new structure, setup the current paging directory to reference it. Once everything is constructed install the correct page directory entry and remove the heap page for it so that it can be used for future swaps. This solution will obviously need some kind of semaphore support integrating into it once O start on threads and multitasking.

Another solution I thought of (which seems even worse in my mind) is to disable paging whilst constructing page tables and page directories, and then re-enable it after the operation is complete.

However both of these solutions seems clunky to me.

Am I thinking along the right lines here? How is this typically done?

Thanks

Re: Relationship between Page Directory & Page Table

Posted: Tue Sep 06, 2016 12:15 am
by Boris
Hi,
You have to " map " the page table structure you want to edit to a virtual address, and then write at that virtual address. Indeed my friend , you cannot write directly to physical memory anymore.

If your architecture supports it (Intel, recent ARMS..) , you can do " recursive mapping " , which permanently and automatically maps all your page table structures, reserving a slice of the virtual address space for all structures.

Re: Relationship between Page Directory & Page Table

Posted: Tue Sep 06, 2016 12:36 am
by snijj
Boris wrote:Hi,
You have to " map " the page table structure you want to edit to a virtual address, and then write at that virtual address. Indeed my friend , you cannot write directly to physical memory anymore.

If your architecture supports it (Intel, recent ARMS..) , you can do " recursive mapping " , which permanently and automatically maps all your page table structures, reserving a slice of the virtual address space for all structures.
How is this recursive mapping achieved? What is the process involved?

Re: Relationship between Page Directory & Page Table

Posted: Tue Sep 06, 2016 12:59 am
by alexfru
snijj wrote:How is this recursive mapping achieved? What is the process involved?
You put in one PDE the physical address of the PD. Draw it to see what it entails.

Re: Relationship between Page Directory & Page Table

Posted: Tue Sep 13, 2016 4:41 am
by danielbj
Have a look here to further understand recursive page directory mapping. After being confused myself, I read this, and understood everything at an instant! :)