Relationship between Page Directory & Page Table

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
snijj
Posts: 17
Joined: Sat Apr 04, 2015 9:35 am
Location: Scarborough, UK

Relationship between Page Directory & Page Table

Post 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
Boris
Member
Member
Posts: 145
Joined: Sat Nov 07, 2015 3:12 pm

Re: Relationship between Page Directory & Page Table

Post 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.
snijj
Posts: 17
Joined: Sat Apr 04, 2015 9:35 am
Location: Scarborough, UK

Re: Relationship between Page Directory & Page Table

Post 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?
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Relationship between Page Directory & Page Table

Post 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.
danielbj
Member
Member
Posts: 36
Joined: Thu Dec 16, 2010 3:08 pm

Re: Relationship between Page Directory & Page Table

Post 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! :)

Daniel Broder Jensen
UNICORN OS
Post Reply