I'm currently reading the Understanding the Linux kernel Third Edition and I'm on chapter 2 about memory addressing. At first the book covers paging in 32 bit, PAE 32 bit, and PSE (we are talking about x86 here). More specifically the anatomy of linear address and what bits are for what tables, offsets, etc... I started to get confused about the paging model in Linux. At one moment the book was talking about directory, table, and offset bits of a linear address (PDPT table for PAE) and next I was thrown into the world of "Linux" paging. Now with the Linux paging they talk about Global, Upper, and Middle tables with table and offset? I don't see how the x86 MMU paging relates to this new Linux model at all. If the MMU is in charge of translating (paging) addresses, why does the kernel need this paging model as well? It just seems like the kernel should just leave it up to the MMU. If anyone could elaborate on why the kernel has this, that would be great!
I understand that the MMU has to translate address based on the tables that the kernel manages. So, the MMU is in charge of address translation (from memory accesses from a process running on a core) but the kernel is not! So why do we have this Global, Upper, and Middle tables with table and offset stuff?
Or maybe this Linux paging model is more abstract than I'm making it to be! Maybe the idea of this kernel page table is not really a table but a set of kernel macros specifying the properties of the many levels of page directories/tables that the kernel has to maintain! For example, the PGD_SIZE
, PUD_SIZE
and the other SIZE
macros (along with the SHIFT
and MASK
macros) specify the different properties of the levels of paging. Based on these macros (of course there are other macros) the kernel can generate the correct page tables in memory? This Linux paging model can adjust the SHIFT macros based on the specific architecture (more specifically the bit layout of linear addresses on the specific architecture)?