Fix typo in graphics and replace SVGs with PNGs
The SVG have rendering problems on some devices, e.g. when the text is zoomed.
@@ -55,7 +55,7 @@ So in order to access page table frames, we need to map some virtual pages to th
|
||||
|
||||
- Alternatively, we could **map the page tables frames only temporarily** when we need to access them. To be able to create the temporary mappings we only need a single identity-mapped level 1 table:
|
||||
|
||||

|
||||

|
||||
|
||||
The level 1 table in this graphic controls the first 2 MiB of the virtual address space. This is because it is reachable by starting at the CR3 register and following the 0th entry in the level 4, level 3, and level 2 page tables. The entry with index `8` maps the virtual page at address `32 KiB` to the physical frame at address `32 KiB`, thereby identity mapping the level 1 table itself. The graphic shows this identity-mapping by the horizontal arrow at `32 KiB`.
|
||||
|
||||
@@ -78,7 +78,7 @@ The idea behind this approach sounds simple: _Map some entry of the level 4 page
|
||||
|
||||
Let's go through an example to understand how this all works:
|
||||
|
||||

|
||||

|
||||
|
||||
The only difference to the [example at the beginning of this post] is the additional entry at index `511` in the level 4 table, which is mapped to physical frame `4 KiB`, the frame of the level 4 table itself.
|
||||
|
||||
@@ -88,17 +88,17 @@ By letting the CPU follow this entry on a translation, it doesn't reach a level
|
||||
|
||||
By following the recursive entry one or multiple times before we start the actual translation, we can effectively shorten the number of levels that the CPU traverses. For example, if we follow the recursive entry once and then proceed to the level 3 table, the CPU thinks that the level 3 table is a level 2 table. Going further, it treats the level 2 table as a level 1 table, and the level 1 table as the mapped frame. This means that we can now read and write the level 1 page table because the CPU thinks that it is the mapped frame. The graphic below illustrates the 5 translation steps:
|
||||
|
||||

|
||||

|
||||
|
||||
Similarly, we can follow the recursive entry twice before starting the translation to reduce the number of traversed levels to two:
|
||||
|
||||

|
||||

|
||||
|
||||
Let's go through it step by step: First the CPU follows the recursive entry on the level 4 table and thinks that it reaches a level 3 table. Then it follows the recursive entry again and thinks that it reaches a level 2 table. But in reality, it is still on the level 4 table. When the CPU now follows a different entry, it lands on a level 3 table, but thinks it is already on a level 1 table. So while the next entry points at a level 2 table, the CPU thinks that it points to the mapped frame, which allows us to read and write the level 2 table.
|
||||
|
||||
Accessing the tables of levels 3 and 4 works in the same way. For accessing the level 3 table, we follow the recursive entry entry three times, tricking the CPU into thinking it is already on a level 1 table. Then we follow another entry and reach a level 3 table, which the CPU treats as a mapped frame. For accessing the level 4 table itself, we just follow the recursive entry four times until the CPU treats the level 4 table itself as mapped frame (in blue in the graphic below).
|
||||
|
||||

|
||||

|
||||
|
||||
It might take some time to wrap your head around the concept, but it works quite well in practice.
|
||||
|
||||
@@ -635,4 +635,4 @@ We're now able to map arbitrary pages and to allocate new physical frames when w
|
||||
TODO spellcheck
|
||||
TODO improve transition between sections
|
||||
TODO update post date
|
||||
TODO check level 2 table diagram 24KiB -> 32KiB
|
||||
TODO use PNGs instead of SVGs?
|
||||
|
||||
|
After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 34 KiB |