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.
Hello,
I thougt my paging works well, but a few hours ago I noticed that my vmm is not able to remap a virtual address to a new physical address when the virtual page has been accessed already.
Yes, don't forget to invalidate that page table entry (or the entire page directory) before trying to use it! The easiest way (albeit slow way, but works for beginning) make a function called invalidate page, and pass the memroy address to it (this allows for expansion later), then simply mov eax, cr3; mov cr3, eax; This will reload your entire page directory and ALL page table entries (aka, slow), there is an invalidate page instruction that isn't very complicated, but do that just to check that it fixes your problem. If that fixes it, I recommend filling in that function properly so it only invalidates the CPU's cache of the actual page table entry, rather than the entire page directory & all entires .
unsigned long virtual_addr_to_invalidate;
__asm__ __volatile__("invlpg %0" : : "m" (virtual_addr_to_invalidate));
To invalidate just one page
Also, keep in mind, invlpg is a 486+ instruction, so if you try running your OS on a 386 it will crash, if you don't plan on 386 support, not an issue . Just keep that in mind though if you do plan on supporting a 386 (I don't, so for me it's invlpg all the way, but hey, just some info just incase).