kernel page table
Hello,
I'm trying to understand the Linux virtual memory management. I know each process has its own page table. How about the kernel? Does the kernel have its own page table? User space process page table is in mm_struct -> pgd, and pgd is passed to MMU when the process is scheduled to run. How about the kernel's page table. Where is it defined? When is it used? Thanks, lqu |
As I understand it the kernel runs in the top of physical memory, not virtual memory, so it is essentially invisible to user space processes.
You can find a description of the memory management system at http://www.linuxhq.com/guides/TLK/mm/memory.html |
Thank you for your reply, but what do you mean by "in the top of physical memory, not virtual memory"? After MMU is enabled, every address the CPU issues is virtual, and must be translated by the MMU. I guess the "top" you are talking about is related to the typical partition of address space. User (0x00000000 ~ 0xBFFFFFFF), kernel (0xC00000000 ~ 0xFFFFFFFF). But they are also virtual. Is it so?
So, when writing a device driver for UART, for example, if I want to access the UART control register (physically at 0x50000000, which is mapped to virtual 0xF5000000), I have to issue 0xF5000000, the virtual one, not the physical one. My question was how (where, when) this 0x50000000 is mapped to 0xF5000000. Where is part of page table for memory above 0xC0000000? Thanks, lqu Quote:
|
Quote:
Quote:
If I understand correctly, the statement "The Linux kernel is linked to run in physical address space." is technically true to the extent that it means anything (if you read a lot into the subtle difference between "linked to run in" and "runs in"). In x86, the physical-like address space is achieved by a big sequential mapping into contiguous virtual address space. Quote:
Don't you hate it when someone who knows less about the subject than you do takes away your thread's zero reply status with a useless answer to a hard question. Since zero reply status gets so much attention around here, there ought to be a way for those of us who sometimes ask hard questions to re flag the thread as having zero useful replies. |
I think I have found the answer in the book "Understand the linux kernel", chapter 2.
The kernel page table is in swapper_pg_dir. In the mm_struct for the idle process (process 0), "pgd" points to this swapper_pg_dir. Every process has a (same) copy of this master page table for the entries between 0xC0000000 and 0xFFFFFFFF. Please correct me if I am wrong. lqu |
Robert Love knows his stuff (stupid statement, I know), but I'd recommend a read of this.
Has very good chapters on (all) the mm plumbing. |
All times are GMT -5. The time now is 04:07 PM. |