Page fault after setting up paging

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
computafreak
Member
Member
Posts: 76
Joined: Sun Dec 14, 2008 1:53 pm

Page fault after setting up paging

Post by computafreak »

Me again. I've managed to get paging working, but as soon as I leave the void which sets it up, I get a page fault. This happens whether I explicitly set up the stack or not. I prints the register values to the screen on a page fault, so I know that the console driver works. Interrupts are disabled while I'm setting up paging, and enabled immediately afterwards. However, sometime between leaving the void which initialises paging and 'dropping down' to Main(). My paging code is based on James Molloy's tutorial, with the only difference being that I can specify the amount of memory to page (however, in this case I leave it at his default of 0x1000000). If needed, I can upload my code. Strangely, my code raises exception 6 in bochs, but a page fault in Virtual PC. My register values are as follows (in VPC):
CR0: 0x80000011
CR1: triple fault when I try to retrieve it, but presumably this is normal behaviour?
CR2: 0x67F00000
CR3: 0x113000
CR4: 0x0
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Page fault after setting up paging

Post by AJ »

Hi,

What code or data do you expect to be at address 0x67F00000? Could we see your final bochs register dump, please?

Because you manage to execute the RET, it sounds like one of two things, both stack related:

1. Your stack or return address is not paged in.
2. Your stack has become corrupted (you return to an unknown location hence bochs' invalid opcode).

Cheers,
Adam
xlq
Member
Member
Posts: 36
Joined: Mon Dec 11, 2006 7:51 am

Re: Page fault after setting up paging

Post by xlq »

It's difficult to know without more information, but:
  • maybe I'm missing something, but turning interrupts on:
    • Have you set up your IDT?
    • Is it mapped?
    • Are the IDT entries pointing to the *virtual* ISR addresses?
    It's probably better to leave interrupts disabled until you've fixed paging.
  • Is the code you're currently running 1:1 mapped, before you turn on paging?
  • What happens if you infinite-loop immediately after enabling paging?
  • Is your code linked at the correct address?
  • etc.
Marionette the flexible kernel
computafreak
Member
Member
Posts: 76
Joined: Sun Dec 14, 2008 1:53 pm

Re: Page fault after setting up paging

Post by computafreak »

Sorry for the lack of information. Yes, the first 31 entries of my IDT are set up. There are a few things strange, like a device not available exception being raised instead of an invalid opcode exception, and two keyboard interrupts being raised instead of one. I'm using 1:1 mapping. As far as I know, everything is being linked correctly. I've attached the Bochs log, and nothing changes if I don't reenable interrupts
Attachments
bochsLog.txt
(11.64 KiB) Downloaded 63 times
Post Reply