Page 1 of 1

paging problem

Posted: Sun Jul 05, 2009 8:19 pm
by yemista
Right now, I keep getting a triple fault when I try to unmap the first 4mb in my kernels directory.
I have oxc0000000 => 0x00000000, and 0x00000000 => 0x00000000, but when I execute the line

Code: Select all

 kernel_dir->tables[0] = 0;
it resets. here is a bochs dump after the reset

[edit] sorry, i pasted the wrong bochs dump

Code: Select all

<bochs:2> creg
CR0=0x60000010: pg CD NW ac wp ne ET ts em mp pe
CR2=page fault laddr=0x00000000
CR3=0x00000000
    PCD=page-level cache disable=0
    PWT=page-level writes transparent=0
CR4=0x00000000: osxsave smx vmx osxmmexcpt osfxsr pce pge mce pae pse de tsd pvi vme
<bochs:3> r
eax: 0x00000000 0
ecx: 0x00000000 0
edx: 0x00000543 1347
ebx: 0x00000000 0
esp: 0x00000000 0
ebp: 0x00000000 0
esi: 0x00000000 0
edi: 0x00000000 0
eip: 0x0000fff0
eflags 0x00000002
id vip vif ac vm rf nt IOPL=0 of df if tf sf zf af pf cf
[/edit]

This will not happen though if interrupts are disabled, but my idt is being set with all virtual addresses.

Re: paging problem

Posted: Mon Jul 06, 2009 1:09 am
by xenos
If it happens only when interrupts are enabled, the problem seems to be in an interrupt handler. It would probably helpful to see the register contents immedidiately before the reset, as well as a disassembly of the faulting instruction. Bochs should give you this information in the logfile when it panics.

Re: paging problem

Posted: Mon Jul 06, 2009 6:38 am
by yemista
Yea I figured it had to do with an interrupt handler, but the contents before wont make much difference. It happens right when 0 is moved into entry zero of the directory. This one is very hard to debug because the interrupt wont execute, it will just fault, but it looks like a double fault right now, and the reason im saying that is the code that caused the triple fault is at the address of the 8th idt entry. Ill check the log though once I get home

Re: paging problem

Posted: Mon Jul 06, 2009 12:00 pm
by frank
The IDTR and GDTR registers both contain virtual addresses and not physical addresses. You need to use the virtual base of the IDT rather than the physical base.

Re: paging problem

Posted: Mon Jul 06, 2009 3:26 pm
by yemista
There we go! that was it. Documentation in different places says different things about this. Thank you

Re: paging problem

Posted: Mon Jul 06, 2009 5:24 pm
by pcmattman
I specifically edited the IDT and GDT wiki pages to show this fact a month or two ago:

GDT Article:
The offset is the virtual address of the table itself
IDT Article:
The offset is the virtual address of the table itself