Page Fault Problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Therx

Page Fault Problem

Post by Therx »

Ok. My code sets up paging with the first page table mapping the first 4mb 1:1 then the other page directory entries are not Present except for the final one which is set to the page dir to make the page dir and page tables accessible in the top 4mb of memory. As the first 4mb is reserved for the kerenl. On the first allocation when the vmm_alloc() function tries to scan the 2nd page table it tries to access a non-present page. So a page fault is triggered. The page fault handler recognises that the address it gets is meant to be a page table so it creates one at that address and sets it in the page directory. Then it fills the page table (with 0's). No problem uptil now. Then the page fault returns. I know where the page fault occurs and that is in the right place. But if I put a debug message on the line after I don't get it. And i'm recieving a GPF. The only possible places I think this could be occuring are:-
- After the C handler and in the STUB. but this is unlikely as identical stubs work perfectly for all other ISRs and the only difference is the little bit of code which passes CR2 to the handler. This code is (the nop's are to make it the same length as the other stubs so that the IDT is easy to generate):-

Code: Select all

          mov eax, cr2               ; Give C Code Address of Fault
          push eax                   ; Put it on the stack
          call _vmm_fault            ; Call C Code
          pop eax
          nop
          nop
- The other thing could be that I'm loading the new table wrong so that when the code which caused a page fault first time is reexecuted it generates a GPF. But I can't understand how it could. The relevant vmm.c and vmm.h code are attached.

That's the first problem. The second is that on some computers there is a triple fault after enabling the paging bit in the vmm_init() function.

Could you please take a look and suggest where I might be going wrong.

Thanks in advance

Pete

[attachment deleted by admin]
Post Reply