Magic page fault
Posted: Mon Nov 07, 2005 8:31 pm
After some code-cleaning and bugfixing (it needed it) my kernel heap initialization code now pagefaults while zeroing out the heap. Said code is rather too long to post here, so I've attached the source file. The fault occurs in the FillDWord() function on line 353, which should just set lwHeapPages*1024 4-byte doublewords to 0 starting at pKernelHeap (0xc1000000). Instead, it causes a page fault with this stuff from the handler:
The strange thing is that I check the PTE just before the FillDWord() is run, and it contains the correct address, so something must be overwriting the PTE in the FillDWord(). This means that the page table is mapped somewhere into the kernel heap, I just don't understand where or why.
I wish it had taken me less than 3-4 days just to come up with this much information.
Code: Select all
$800 pages are being used for the kernel heap.
Address in CR2: $C1400000
Page directory address: $7FFF000
Page directory entry at fault: $7BFB023
Page table entry at fault: $0
gs: $C0160018
fs: $C0160018
es: $7BF0018
ds: $FFC00018
edi: $C1400000
esi: $2CFDB
ebp: $C016CC0C
ebx: $0
edx: $200000
ecx: $100000
eax: $0
int #: $E
error code: $2
eip: $C0100F31
cs: $20
eflags: $10206
useresp: $2CFDC
ss: $C016CC20
Page Fault Exception
I wish it had taken me less than 3-4 days just to come up with this much information.