Reply 120 of 238, by superfury
Hmmmm... Something is going strange when testing paging on the Pentium emulation, running debian 3.0r0(from https://sourceforge.net/projects/bochs/files/ … Debian%20Linux/)? Trying to run it on the Pentium emulation makes the emulator somehow lock up, because the Paging TAG generation(which is used for looking up the entry and storing it) WILL set bit 0 to 1(the present bit) when saving the TLB entry. But when reading the TLB entry from the paging TLB, somehow all bits are correctly set in the tag to look it up, but bit 0 is reset? Even though the basic expression used is:
//W=Writable, U=User, D=Dirty
OPTINLINE uint_32 Paging_generateTAG(uint_32 logicaladdress, byte W, byte U, byte D, byte S)
return (((((((((S<<1)|D)<<1)|W)<<1)|U)<<1)|1)|(logicaladdress & 0xFFFFF000)); //The used TAG(using a 4KB page, but the lower 10 bits are unused in 4MB pages)!
Why is it clearing bit 0? All other bits are correctly set, but bit 0 is reset?
The only thing following it is:
TAG &= (curentry->entry->addrmask|0xFFF); //The full search mask, with the address width(KB vs MB) applied!
Where curentry->entry->addrmask is 0xFFC00000 due to it being in a 4MB TLB entry? But that still has bit 0 set, but it's still cleared after these two lines(Paging_generateTAG and the TAG &= (curentry->entry->addrmask|0xFFF); ? Why is this happening?
Edit: Managed to fix it. It seems a problem with the mask to be applied(for searching tags and masking off bits that are to be ignored(e.g. writable and dirty bits in some cases for memory read accesses) was causing issues. Since the mask and the tag that's pre-masked for quick search weren't matching properly with 4MB entries, it was failing to properly recognise them when the upper bits were non-zero(upper 10 bits of the address(bit 12 to 21) that were added in the case of the 4MB pages).