http://bottomupcs.sourceforge.net/csbu/x2816.htm
swapper_pg_dircontains a mapping for all physical pages from0xc0000000to0xc0000000+ end_mem, so the first 768 entries in swapper_pg_dir are 0’s, and then there are 4 or more that point to kernel page tables.- What “swapper_pg_dir” is all about (on linux kernel):
- The kernel sees memory as if based at
0xC0000000. Any memory allocation, pointer or global, is located between0xC0000000to0xFFFFFFFF. However, for HW controllers, such as the MMU or any co processor, memory window is porbably based at0x00000000. - So, when loading a pointer to a table or descriptor to a HW engine, it must be based at
0x00000000. - When building the Linux kernel, the linker assigns addresses in “kernel space” (virtual addresses in the range used by the kernel) to all kernel symbols. So
$swapper_pg_dirwill evaluate to a virtual address, which is only usable AFTER the page tables are set up.$swapper_pg_dir-0xc0000000is the corresponding physical address - kernel is linked to address
0xc0000000. Each process in user-space has it’s own virtual memory map, so multiple processes see different memory page when pointing to the same address (1MB for example). However, when executing kernel code (for example when calling a system call), all processes execute it in the same virtual (but linear) address space - starting at0xc0000000.0xc0000000is historical and relies on variables such as 32bit address space, memory holes in PC systems and sizes of system memory, acceptable back then.
- The kernel sees memory as if based at
- What “swapper_pg_dir” is all about (on linux kernel):