diff --git a/Initialization/linux-initialization-1.md b/Initialization/linux-initialization-1.md index 683e67bb..9e155de9 100644 --- a/Initialization/linux-initialization-1.md +++ b/Initialization/linux-initialization-1.md @@ -90,7 +90,7 @@ rbp = 0x1000000 - (0xffffffff81000000 - 0xffffffff80000000) jnz bad_address ``` -在这里我们将 `rbp` 寄存器的低32位与 `PMD_PAGE_MASK` 进行比较。`PMD_PAGE_MASK` 代表中层页目录(`Page middle directory`)屏蔽位(相关信息请阅读 [paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) 一节),它的定义如下: +在这里我们将 `rbp` 寄存器的低32位与 `PMD_PAGE_MASK` 进行比较。`PMD_PAGE_MASK` 代表中层页目录(`Page middle directory`)屏蔽位(相关信息请阅读 [paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/linux-theory-1.html) 一节),它的定义如下: ```C #define PMD_PAGE_MASK (~(PMD_PAGE_SIZE-1)) @@ -162,7 +162,7 @@ NEXT_PAGE(level1_fixmap_pgt) _PAGE_ACCESSED | _PAGE_DIRTY) ``` -更多信息请阅读 [分页](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) 部分. +更多信息请阅读 [分页](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/linux-theory-1.html) 部分. `level3_kernel_pgt` 中保存的两项用来映射内核空间,在它的前 `510`(即 `L3_START_KERNEL`)项均为 `0`。这里的 `L3_START_KERNEL` 保存的是在上层页目录(Page Upper Directory)中包含`__START_KERNEL_map` 地址的那一条索引,它等于 `510`。后面一项 `level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE` 中的 `level2_kernel_pgt` 比较容易理解,它是一条页表项,包含了指向中层页目录的指针,它用来映射内核空间,并且具有如下的访问权限: @@ -620,7 +620,7 @@ write_cr3(__pa_nodebug(early_level4_pgt)); -------------------------------------------------------------------------------- * [Model Specific Register](http://en.wikipedia.org/wiki/Model-specific_register) -* [Paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) +* [Paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/linux-theory-1.html) * [Previous part - Kernel decompression](http://xinqiu.gitbooks.io/linux-insides-cn/content/Booting/linux-bootstrap-5.html) * [NX](http://en.wikipedia.org/wiki/NX_bit) * [ASLR](http://en.wikipedia.org/wiki/Address_space_layout_randomization) diff --git a/MM/linux-mm-2.md b/MM/linux-mm-2.md index 64802a2c..cb52ebd1 100644 --- a/MM/linux-mm-2.md +++ b/MM/linux-mm-2.md @@ -519,5 +519,5 @@ prev_map[slot] = NULL; * [e820](http://en.wikipedia.org/wiki/E820) * [Memory management unit](http://en.wikipedia.org/wiki/Memory_management_unit) * [TLB](http://en.wikipedia.org/wiki/Translation_lookaside_buffer) -* [Paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) +* [Paging](http://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/linux-theory-1.html) * [内核内存管理第一部分](http://xinqiu.gitbooks.io/linux-insides-cn/content/MM/linux-mm-1.html) diff --git a/MM/linux-mm-3.md b/MM/linux-mm-3.md index 4ba16fc9..c07caead 100644 --- a/MM/linux-mm-3.md +++ b/MM/linux-mm-3.md @@ -148,7 +148,7 @@ config X86 struct my_struct *my_struct = kmalloc(sizeof(struct my_struct), GFP_KERNEL); ``` -或者换句话说,在内核访问 [page](https://en.wikipedia.org/wiki/Page_%28computer_memory%29) 时会发生[缺页中断](https://en.wikipedia.org/wiki/Page_fault)。这是由于 `kmemcheck` 将内存页标记为`不存在`(关于Linux内存分页的相关信息,你可以参考[分页](https://0xax.gitbooks.io/linux-insides/content/Theory/Paging.html))。如果一个`缺页中断`异常发生了,异常处理程序会来处理这个异常,如果异常处理程序检测到内核使能了 `kmemcheck`,那么就会将控制权提交给 `kmemcheck` 来处理;`kmemcheck` 检查完之后,该内存页会被标记为 `present`,然后被中断的程序得以继续执行下去。 这里的处理方式比较巧妙,被中断程序的第一条指令执行时,`kmemcheck` 又会标记内存页为 `not present`,按照这种方式,下一个对内存页的访问也会被捕获。 +或者换句话说,在内核访问 [page](https://en.wikipedia.org/wiki/Page_%28computer_memory%29) 时会发生[缺页中断](https://en.wikipedia.org/wiki/Page_fault)。这是由于 `kmemcheck` 将内存页标记为`不存在`(关于Linux内存分页的相关信息,你可以参考[分页](https://0xax.gitbooks.io/linux-insides/content/Theory/linux-theory-1.html))。如果一个`缺页中断`异常发生了,异常处理程序会来处理这个异常,如果异常处理程序检测到内核使能了 `kmemcheck`,那么就会将控制权提交给 `kmemcheck` 来处理;`kmemcheck` 检查完之后,该内存页会被标记为 `present`,然后被中断的程序得以继续执行下去。 这里的处理方式比较巧妙,被中断程序的第一条指令执行时,`kmemcheck` 又会标记内存页为 `not present`,按照这种方式,下一个对内存页的访问也会被捕获。 目前我们只是从理论层面考察了 `kmemcheck`,接下来我们看一下Linux内核是怎么来实现该机制的。 @@ -422,7 +422,6 @@ Links * [memory leaks](https://en.wikipedia.org/wiki/Memory_leak) * [kmemcheck documentation](https://www.kernel.org/doc/Documentation/kmemcheck.txt) * [valgrind](https://en.wikipedia.org/wiki/Valgrind) -* [paging](https://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) * [page fault](https://en.wikipedia.org/wiki/Page_fault) * [initcalls](https://xinqiu.gitbooks.io/linux-insides-cn/content/Concepts/initcall.html) * [opcode](https://en.wikipedia.org/wiki/Opcode) @@ -430,5 +429,5 @@ Links * [per-cpu variables](https://xinqiu.gitbooks.io/linux-insides-cn/content/Concepts/per-cpu.html) * [flags register](https://en.wikipedia.org/wiki/FLAGS_register) * [tasklet](https://xinqiu.gitbooks.io/linux-insides-cn/content/Interrupts/interrupts-9.html) -* [Paging](https://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/Paging.html) +* [Paging](https://xinqiu.gitbooks.io/linux-insides-cn/content/Theory/linux-theory-1.html) * [Previous part](https://xinqiu.gitbooks.io/linux-insides-cn/content/MM/linux-mm-2.html)