http://bottomupcs.sourceforge.net/csbu/x2816.htm

  • swapper_pg_dir contains a mapping for all physical pages from 0xc0000000 to 0xc0000000 + 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 between 0xC0000000 to 0xFFFFFFFF. However, for HW controllers, such as the MMU or any co processor, memory window is porbably based at 0x00000000.
      • 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_dir  will evaluate to a virtual address, which is only usable AFTER the page tables are set up. $swapper_pg_dir-0xc0000000 is 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 at 0xc0000000. 0xc0000000 is historical and relies on variables such as 32bit address space, memory holes in PC systems and sizes of system memory, acceptable back then.

🌱 Back to Garden