Paging not working, despite memory looking fine
Posted: Wed Dec 30, 2020 9:15 pm
I'm trying to set up virtual memory in my operating system, and have code to set up a page directory, as well as all of the pages within the first table in the directory. The problem is, after setting up these tables, as soon as I enable the paging bit in CR0, I get a triple fault on the very next instruction. I can't work out why this is though, since as far as I can tell, I have all of: CR3, the page directory which CR3 points to, and page table #0 in that page directory. (I've only set the first page table (4MB) in memory because, for now, I'm not using any more than that, my kernel begins at 1MB.)
I'll show the state of various parts of the computer at the moment that I enable paging with the paging bit in CR0.
First, the value of CR3 is: 0x1000. This is where my page directory is.
The memory at 0x1000 begins:
So the first DWORD of this is: 0x02000003, which represents a page directory entry referring to a page table with physical address of 0x2000, correct? So, the memory at 0x2000 (this page table) begins:
So for example, taking the first entry in this page table (0x00000003), that page maps to frame 0, correct?
So first of all, after enabling the paging bit in this state, I use bochs's feature of viewing the page table, but when I do so, it shows a blank table, which makes me think my page table isn't loaded correctly somehow.
Does any of this look incorrect? I've been through the relevant parts of the intel developer manual in depth, and can't find anything wrong with what I've done.
I'll show the state of various parts of the computer at the moment that I enable paging with the paging bit in CR0.
First, the value of CR3 is: 0x1000. This is where my page directory is.
The memory at 0x1000 begins:
Code: Select all
0x00001000: 03 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00
Code: Select all
0x00002000: 03 00 00 00 03 00 00 01 03 00 00 02 03 00 00 03
...
So first of all, after enabling the paging bit in this state, I use bochs's feature of viewing the page table, but when I do so, it shows a blank table, which makes me think my page table isn't loaded correctly somehow.
Does any of this look incorrect? I've been through the relevant parts of the intel developer manual in depth, and can't find anything wrong with what I've done.