Page 1 of 1

Page fault after setting up paging

Posted: Fri Feb 13, 2009 11:47 am
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

Re: Page fault after setting up paging

Posted: Fri Feb 13, 2009 12:11 pm
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

Re: Page fault after setting up paging

Posted: Fri Feb 13, 2009 2:44 pm
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.

Re: Page fault after setting up paging

Posted: Sat Feb 14, 2009 11:30 am
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