在操作系统的 32 位实现中,页表具有固定的结构(两个级别 - 页目录和页表)。但在 x86_64 系统中,通常会实现多级页表(Linux 中为 4 级)。系统如何知道正在使用多少级别?为此需要什么命令?我们如何让CPU知道全局页目录和其他结构?
最佳答案
简短回答:
- 在撰写本文时,x86-64 页表始终为 4 级。 future 可能会实现5级和6级以覆盖完整的64位地址空间。
- 操作系统通过执行带有各种参数的 CPUID 指令来查询硬件功能。
- 操作系统通过写入控制寄存器CR3来设置全局页目录指针。
权威文本:参见 Intel® 64 and IA-32 Architectures Software Developer Manuals ,第 3A 卷“系统编程指南,第 1 部分”,第 4.5 节“IA-32e 寻呼”。
<强> Wikipedia text (略有编辑):
The 64-bit addressing mode ("long mode") is a superset of Physical Address Extensions (PAE). Rather than the three-level page table system used by systems in PAE mode, systems running in long mode use four levels of page table: PAE's Page-Directory Pointer Table is extended from 4 entries to 512, and an additional Page-Map Level 4 (PML4) Table is added, containing 512 entries in 48-bit implementations. In implementations providing larger virtual addresses, this latter table would either grow to accommodate sufficient entries to describe the entire address range, up to a theoretical maximum of 33,554,432 entries for a 64-bit implementation, or be over ranked by a new mapping level, such as a PML5.
关于kernel - x86-64 架构中的分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30006365/