kernel address space mapping
Posted: Wed Dec 12, 2007 10:15 pm
I'm having trouble understanding a couple design descisions: I just read Tim Robinson's memory management tutorial, and his idea of mapping the page directory into itself raised a couple questions. As I understand it, the idea is so the kernel can get at the page directory/tables via virtual addresses as well as physical. He mentions that an alternative is to map the physical memory linearly into the kernel address space (linear address n+c maps physical address n), but mentions the 1GB limitation on this. I know that Linux opts for the linear mapping (with the highmem shuffle to get to pages that it can't directly map), but I haven't figured out precisely why.
Mr. Robinson seems to be saying that mapping the pgdir into itself obviates the need for that linear mapping, which (to me) implies that getting to page tables/directories is the only time the kernel would need to address a physical location in RAM. This seems too good to be true.
I guess my questions are these: Why does Linux directly map physical ram into the kernel address space? If there is need for the kernel to address ram physically (not just for the sake of page allocation, but actual dereferencing), how does Mr. Robinson's method address that? (no pun intended)
My plan is to find out the hard way by adopting the self-referential PD method and seeing where I get into trouble (my favorite way of learning ) but I thought I'd ask anyway and give people wiser than I a chance to yell "No! Don't do it!" first.
Mr. Robinson seems to be saying that mapping the pgdir into itself obviates the need for that linear mapping, which (to me) implies that getting to page tables/directories is the only time the kernel would need to address a physical location in RAM. This seems too good to be true.
I guess my questions are these: Why does Linux directly map physical ram into the kernel address space? If there is need for the kernel to address ram physically (not just for the sake of page allocation, but actual dereferencing), how does Mr. Robinson's method address that? (no pun intended)
My plan is to find out the hard way by adopting the self-referential PD method and seeing where I get into trouble (my favorite way of learning ) but I thought I'd ask anyway and give people wiser than I a chance to yell "No! Don't do it!" first.