OSDev.org
https://forum.osdev.org/

Relationship between Page Directory & Page Table
https://forum.osdev.org/viewtopic.php?f=15&t=30791
Page 1 of 1

Author:  snijj [ Tue Sep 06, 2016 12:04 am ]
Post subject:  Relationship between Page Directory & Page Table

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

Author:  Boris [ Tue Sep 06, 2016 12:15 am ]
Post subject:  Re: Relationship between Page Directory & Page Table

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.

Author:  snijj [ Tue Sep 06, 2016 12:36 am ]
Post subject:  Re: Relationship between Page Directory & Page Table

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?

Author:  alexfru [ Tue Sep 06, 2016 12:59 am ]
Post subject:  Re: Relationship between Page Directory & Page Table

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.

Author:  danielbj [ Tue Sep 13, 2016 4:41 am ]
Post subject:  Re: Relationship between Page Directory & Page Table

Have a look here to further understand recursive page directory mapping. After being confused myself, I read this, and understood everything at an instant! :)

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/