MIT 6.S081 学习笔记 -- page tables

Chapter 3 Page table

1. From User perspetive, how VA maps to PA?

lab1: print pagetable for pid == 1, 

PR: https://github.com/nipperhou/xv6-riscv/commit/eb8e0008c019cfa0f3687989a90a63a7d45bde6f

Output: 

```

xv6 kernel is booting

trampoline:0x0000000080007000
hart 2 starting
hart 1 starting
trampoline:0x0000000080007000
page table 0x0000000087f6c000
..0: pte 0x0000000021fda001 pa 0x0000000087f68000
.. ..0: pte 0x0000000021fd9c01 pa 0x0000000087f67000
.. .. ..0: pte 0x0000000021fda41b pa 0x0000000087f69000
.. .. ..1: pte 0x0000000021fd9817 pa 0x0000000087f66000
.. .. ..2: pte 0x0000000021fd9407 pa 0x0000000087f65000
.. .. ..3: pte 0x0000000021fd9017 pa 0x0000000087f64000
..255: pte 0x0000000021fdac01 pa 0x0000000087f6b000
.. ..511: pte 0x0000000021fda801 pa 0x0000000087f6a000
.. .. ..510: pte 0x0000000021fdd007 pa 0x0000000087f74000
.. .. ..511: pte 0x0000000020001c0b pa 0x0000000080007000
init: starting sh
trampoline:0x0000000080007000
trampoline:0x0000000080007000

```

analyze: 

 VA increase from lower bit to higher bit, so page table will allocate one by one from PTE level3(because L0 is for PTE level3, it has the least scope, thus it increase more faster than PTE lvl2 and PTE lvl1).

从output也可以印证这个结论,pa从 .. .. ..3 增加到.. .. ..2,到.. .. ..1,.. .. ..0:,然后才是.. ..0,然后是.. .. ..510,.. ..511,..255。 最后是.. .. ..511, 他保存的是trampoline的地址。

 

posted @ 2024-05-17 21:41  nipper  阅读(8)  评论(0编辑  收藏  举报