MMU/Kernel 如何知道 PTE 有效?

How does the MMU/Kernel knows that a PTE is valid?

假设一个两级页面 table,假设程序被分配了 2 个页面 (8KB)

  GPD      PD1     PD2      PD3 
+-----+ +------+ +------+ +------+
+  1  + +  22  + +------+ +------+
+  0  + +  62  + +------+ +------+
+  0  + +  0   + +------+ +------+
+-----+ +------+ +------+ +------+

MMU/kernel 如何知道程序何时试图访问 PD1 的第三个条目或类似 GPD 的 2,3 条目? 它是否用一些值初始化未使用的 PTE 以区分未使用的? (比如 0 之类的)

我已读入 here 并且 pte 标志中没有有效位或其他内容

有一个名为 pte_none 的函数。它可以测试 PTE 是否为空。如果 PTE 无效,其值为零,函数 pte_none 将 return TRUE。

如果页面 table 条目为零,则 present bit is also zero, so the mapping from virtual address to physical address does not exist. If a program wants to access this invalid virtual address, MMU will check the present bit and raise an exception called page fault and then CPU will execute an exception handler which is registered by Interrupt Descriptor Table(IDT)。处理程序将做什么取决于此异常的类型。结果可能是加载所需的页面或终止程序。