ucore Lab2学习:Virtual Memory

我觉得这个lab最主要就是理解好Virtual memory是怎么map到physical memory的。在CSAPP里面了,通过MMU和TLB电路来实现转换。x86中是用的2级page table。

还要理解stack frame(譬如lab1的project 4.1.1):switch_to_u2k和swith_to_k2u.有2种方法。一个是通过改写stackframe的TSS。一个是直接用asm改写gate descriptor。

CSAPP讲了:每一个process有一个对应的VM和Page table.

imageimage

不过为什么BIOS在xv6和ucore的位置不同呢?(kernal.ld)都是指定了entry在0x100000处(物理地址)。

在csapp里面很好的解释了user/kernal stack以及process直接如何share 全局变量和kernel (xv6 book: each process has 2 stacks: user stack, and kernel stack)

imageimage

在xv6中提到:像右图这样把2段VM映射到同一个物理地址是page table一个惯用伎俩!

// return address
return &((pte_t*)KADDR(PDE_ADDR(*pdepage)))[PTX(la)];
原文地址:https://www.cnblogs.com/gpuasic/p/3816667.html