I rewrote my page manager, and as soon as my kernel enters it identity maps the lower/top 1GB using 4MB pages in assembly. Once in the C++ kernel, my proper page tables are created using 4KB pages.
After a week of trying to discover why Bochs kept triple faulting, I finally discovered that I kept the 4MB pages bit set in my page directory entries. I found about a dozen other bugs along the way though
EDIT: Still on the paging topic, I was loading ELF files into memory and I was getting "Invalid Opcode" (VirtualBox sucks for catching this exception BTW, it crashes rather than handle it through my OS's exception system). I spent most of this afternoon looking through my thread constructor and my scheduler wondering why. Then I decided to print out the memory it's trying to execute which happened to be "255 255 255 255 255 255" (a.k.a. 0xFF 0xFF etc in decimal), even though I just loaded perfectly valid instructions into that location! Eventually I tried:
Code: Select all
char *a = (char *)1024 * 1024;
*a = 100;
console << (unsigned int) a << " ";
but it was still printing out "255"! That's when I knew something was fishy with my paging, and it just happened that when I was allocating the pages to load the program into, I created a page table, and set the page table's page directory entry to the
virtual address of the page table, not the physical!
It was the difference between:
Code: Select all
processPageTable[pagetable][pagetableentry] = (unsigned int)(pageAddrPhysical * MEMORY_PAGESIZE) | 3;
and
Code: Select all
processPageTable[pagetable][pagetableentry] = (unsigned int)(pageAddr * MEMORY_PAGESIZE) | 3;
That waisted me an afternoon of debugging while I ripped apart half of my kernel.