Ciro Santilli OurBigBook.com \$£ Sponsor €¥ 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱

# Single level paging scheme visualization

This is how the memory could look like in a single level paging scheme:
``````Links   Data                    Physical address

+-----------------------+ 2^32 - 1
|                       |
.                       .
|                       |
+-----------------------+ page0 + 4k
| data of page 0        |
+---->+-----------------------+ page0
|     |                       |
|     .                       .
|     |                       |
|     +-----------------------+ pageN + 4k
|     | data of page N        |
|  +->+-----------------------+ pageN
|  |  |                       |
|  |  .                       .
|  |  |                       |
|  |  +-----------------------+ CR3 + 2^20 * 4
|  +--| entry[2^20-1] = pageN |
|     +-----------------------+ CR3 + 2^20 - 1 * 4
|     |                       |
|     .    many entires       .
|     |                       |
|     +-----------------------+ CR3 + 2 * 4
|  +--| entry[1] = page1      |
|  |  +-----------------------+ CR3 + 1 * 4
+-----| entry[0] = page0      |
|  +-----------------------+ <--- CR3
|  |                       |
|  .                       .
|  |                       |
|  +-----------------------+ page1 + 4k
|  | data of page 1        |
+->+-----------------------+ page1
|                       |
.                       .
|                       |
+-----------------------+  0``````
Notice that:
• the CR3 register points to the first entry of the page table
• the page table is just a large array with 2^20 page table entries
• each entry is 4 bytes big, so the array takes up 4 MiB
• each page table contains the physical address a page
• each page is a 4 KiB aligned 4KiB chunk of memory that user processes may use
• we have 2^20 table entries. Since each page is 4KiB == 2^12, this covers the whole 4GiB (2^32) of 32-bit memory