Aliasing memory with paging
Posted: Fri Sep 02, 2005 11:45 pm
I'm working out some of the details of memory management, and I came across a potential problem.
First, a bit of background. My kernel is currently loaded at physical address 0x00100000 by GRUB, then mapped to 0xC0100000 with a 4MB page that starts at 0xC0000000 (I use PSE, but not PAE). Eventually, I want to be able to map regions of the first physical 1MB into the virtual address spaces of driver processes. But, I also want to keep the 4MB global kernel page to conserve space in the TLB. This would mean having more than one page (the 4MB one plus some 4KB ones) mapping to the same physical addresses for a given page directory (since the 4MB kernel page is mapped in all page directories).
This seemed like an OK idea to me, until I remembered reading this (from the Intel docs, volume 3):
How do those of you with user-mode drivers deal with the first 1MB of the physical address space? What do you think is the best way?
First, a bit of background. My kernel is currently loaded at physical address 0x00100000 by GRUB, then mapped to 0xC0100000 with a 4MB page that starts at 0xC0000000 (I use PSE, but not PAE). Eventually, I want to be able to map regions of the first physical 1MB into the virtual address spaces of driver processes. But, I also want to keep the 4MB global kernel page to conserve space in the TLB. This would mean having more than one page (the 4MB one plus some 4KB ones) mapping to the same physical addresses for a given page directory (since the 4MB kernel page is mapped in all page directories).
This seemed like an OK idea to me, until I remembered reading this (from the Intel docs, volume 3):
Why would this hang the processor? That sounds absolutely evil. Has anyone actually had this problem? The wording is a bit funny, in that page directory entries don't have dirty bits unless they point to 4MB pages... But it says the problem only happens when two PDEs refer to the same PTE... But PDEs refer to entire page tables, not to individual PTEs. This is almost as bad as M$ documentation.3.7.4. Memory Aliasing
The IA-32 architecture permits memory aliasing by allowing two page-directory entries to point to a common page-table entry. Software that needs to implement memory aliasing in this manner must manage the consistency of the accessed and dirty bits in the page-directory and page-table entries. Allowing the accessed and dirty bits for the two page-directory entries to become inconsistent may lead to a processor deadlock.
How do those of you with user-mode drivers deal with the first 1MB of the physical address space? What do you think is the best way?