paging 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
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

paging problem

Post 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.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: paging problem

Post 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.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: paging problem

Post 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
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: paging problem

Post 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.
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: paging problem

Post by yemista »

There we go! that was it. Documentation in different places says different things about this. Thank you
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: paging problem

Post 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
Post Reply