So I setup recursive page directory in my hobby kernel and it works fine. But when I try to add a new Page Mapping I get a page fault. It seems to store the new physical address of page table in the page directory.
I have been following this tutorial. http://www.rohitab.com/discuss/topic/31 ... directory/
This is my implementation of the Paging : https://github.com/TheBugEater/FluxOS/b ... l/paging.c
The Page Fault Occurs on Line Number 103, when I try to add a new mapping. I was trying to figure out this for the past 2 days. I think I'm missing something small but couldn't figure out.
Thanks in Advance.
Page Fault in Recursive Page Directory
-
- Posts: 4
- Joined: Tue Jul 26, 2016 5:03 am
- Libera.chat IRC: TheBugEater
Page Fault in Recursive Page Directory
Last edited by TheBugEater on Tue Jul 26, 2016 10:35 pm, edited 1 time in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Page Fault in Recursive Page Directory
Two things that I noticed:
- Using recursive paging, one would set a new page table via a write to 0xfffff000-0xffffffff
- page_directory was never set in this code.
My preliminary guess is that the page table was added to the wrong page directory.
In addition, I see a number of print statements, the output of which would be very nice information for us to have.
- Using recursive paging, one would set a new page table via a write to 0xfffff000-0xffffffff
- page_directory was never set in this code.
My preliminary guess is that the page table was added to the wrong page directory.
In addition, I see a number of print statements, the output of which would be very nice information for us to have.
-
- Posts: 4
- Joined: Tue Jul 26, 2016 5:03 am
- Libera.chat IRC: TheBugEater
Re: Page Fault in Recursive Page Directory
I have defined the Page Directory in the header file
https://github.com/TheBugEater/FluxOS/b ... l/paging.h
Here is a screenshot of the Output.
As you can see the physical frame 10F000 is allocated for the new page table, With Write Present and Writable flags set it's 10F003... After the Page Fault happens, I'm also extracting the value of physical address in the page directory entry for the table. It returns the same value, but not reading or writing to it.
https://github.com/TheBugEater/FluxOS/b ... l/paging.h
Here is a screenshot of the Output.
As you can see the physical frame 10F000 is allocated for the new page table, With Write Present and Writable flags set it's 10F003... After the Page Fault happens, I'm also extracting the value of physical address in the page directory entry for the table. It returns the same value, but not reading or writing to it.
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: Page Fault in Recursive Page Directory
Code: Select all
v_page_directory[1023] = ((unsigned long)recursive_page_table & 0xFFFFF000) | 3;
/***************************************************
* This Block Sets the Last Index of the Page Table to Map to Page
* Directory*/
for(unsigned int i = 0; i < 1023; i++)
{
// Set the Address and Make it Present and Writable
v_recursive_page_table[i] = 2;
}
v_recursive_page_table[1023] = ((unsigned long)page_directory_phys_addr & 0xFFFFF000) | 3;
v_recursive_page_table[768] = ((unsigned long)kernel_page_table & 0xFFFFF000) | 3;
What you probably want to do is to map
Code: Select all
page_directory[1023] = page_directory
-
- Posts: 4
- Joined: Tue Jul 26, 2016 5:03 am
- Libera.chat IRC: TheBugEater
Re: Page Fault in Recursive Page Directory
Doesn't this line map 0xFFFFF000 to the page directory itself ?
v_recursive_page_table[1023] = ((unsigned long)page_directory_phys_addr & 0xFFFFF000) | 3;
v_recursive_page_table is the virtual address of the page table since I have a higher half kernel enabled at this point of time. So it writes the physical address of page directory to index 1023, which is 0xFFFFF000. Is this wrong ? I'm still kinda confused about the recursive page directory. Everytime I think of it deeply, my mind starts to think recursively on it and doesn't stop (I'm not joking)
v_recursive_page_table[1023] = ((unsigned long)page_directory_phys_addr & 0xFFFFF000) | 3;
v_recursive_page_table is the virtual address of the page table since I have a higher half kernel enabled at this point of time. So it writes the physical address of page directory to index 1023, which is 0xFFFFF000. Is this wrong ? I'm still kinda confused about the recursive page directory. Everytime I think of it deeply, my mind starts to think recursively on it and doesn't stop (I'm not joking)
-
- Posts: 4
- Joined: Tue Jul 26, 2016 5:03 am
- Libera.chat IRC: TheBugEater
Re: Page Fault in Recursive Page Directory
Yes You're right man, It took me so long Thanks allot. It was my mistake. I created a seperate page to handle the recursive page directory. Instead of mapping itself to it. Now it works Thanks.