1) Question is so confused, I can't guess what you are trying to get at. But.
Quote:
Originally Posted by syg00
Kernel addresses are real - no page translation. User-space uses page table to map virtual address to real address (when resident in real).
|
No. Some obscure architectures running Linux act that way, but x86 certainly does not.
All addresses (kernel and user) go through page translation.
Linux was designed with the idea that virtual address space is larger than physical ram (back when 1GB of ram was too expensive to put in a single computer). So it was convenient to map all of physical ram to a contiguous subset of kernel virtual addresses, so a physical address can be accessed by just adding an offset. Current 32-bit Linux maps only a small part of physical ram that way. Certain kernel data structures are restricted to that small part of physical ram.
2).
All addresses (kernel and user) go through page translation.
Every 32-bit virtual address is split by the CPU into a 20-bit virtual "page frame number" and a 12 bit offset within the page. Then the 20-bit number is looked up in a hardware translation system (translation look aside buffer) to produce a 24-bit physical PFN. The 24-bit PFN and original 12-bit offset are combined to produce the 36-bit physical memory address.
The kernel maintains a hierarchical set of page tables (for each process). When any 20-bit virtual PFN is missing from the "translation look aside buffer" hardware, the CPU automatically looks that PFN up in the page table structure to use and to copy into the TLB. If the translation is disabled in the page table structure, the CPU "faults" into kernel code to take appropriate action (such as physically reading in a page from a file mapping).
Back to the actual question (2): At any one moment (in any single core or hyperthread), the TLB and page table system can map at most 1048576 4KB pages (total 4GB) but that 4GB may be scattered anywhere through the 64GB physical address space. When the kernel switches to a different process, it flushes the TLB system and it switches to a different page table structure.
Each hyperthread has its own page table pointer. So if you had a 4 core CPU with hyperthreading enabled, there are eight independent page table pointers so eight different software threads could be using eight different 4GB subsets of the 64GB physical space.
By hardware design, each of those page tables hierarchies is totally independent. By Linux design (for 32-bit x86) all of those page table structures overlap and share their top 1GB of mappings. So kernel addresses are the same in every process address space.
One extra detail: There is actually an alternate translation method that can be mixed in. In that method only the top 11 (not 20) bits of virtual address are translated to the top 15 (not 24) bits of physical address. The bottom 21 bits of virtual address pass untranslated to the bottom 21 bits of physical address (just as normally the bottom 12 bits pass through untranslated). That is a more efficient system for use when a large area of physical memory is used contiguously in virtual address space, such as the Linux mapping of a big contiguous chunk of physical memory to be most of the kernel virtual space.