# 二级地址转换

**二级地址转换**（Second Level Address Translation，SLAT）是 x86 虚拟化扩展中的一项硬件特性，它通过第二套片上分页结构将客户机物理地址转换为宿主机物理地址，从而使虚拟机的内存得以映射，而无需 hypervisor 在每次页表变更时介入。Intel 将其实现为扩展页表（Extended Page Tables，EPT），AMD 则实现为嵌套页表（Nested Page Tables，NPT），市场推广名称为快速虚拟化索引（Rapid Virtualization Indexing）；Linux KVM 文档对两者统一采用厂商中立的术语“二维分页”（two-dimensional paging，TDP）。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup><sup> • </sup><sup>[2](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)</sup><sup> • </sup><sup>[3](https://docs.kernel.org/virt/kvm/x86/mmu.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 功能 | 通过遍历一组 EPT 分页结构来转换客户机物理地址（GPA），生成实际用于访问内存的物理地址。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup> |
| 启用方式（Intel） | 当“启用 EPT”VM 执行控制位为 1 时使用 EPT；它转换 VMX 非根模式下以及 VM 入口事件注入时使用的 GPA。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup> |
| 遍历几何（Intel） | 使用每个 GPA 的第 47:0 位，页遍历长度为 4，因此每次转换最多访问 4 个 EPT 分页结构项。<sup>[4](https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3c-part-3-manual.pdf)</sup> |
| 最坏情况开销 | 在 x86-64 上，虚拟化环境下的 TLB 未命中需要执行最多 24 次内存引用的二维页遍历，而原生遍历最多只需 4 次。<sup>[5](https://ieeexplore.ieee.org/document/7011387/)</sup> |
| 主要收益 | 消除了客户机操作系统因影子页表维护而向 VMM 产生的 VM 退出。<sup>[6](https://cdrdv2-public.intel.com/872188/872188-001.pdf)</sup> |
| AMD 对应实现 | AMD-V 下的嵌套分页（快速虚拟化索引）；嵌套页表遍历期间的故障会引发 #VMEXIT(NPF)。<sup>[2](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)</sup> |
| 扩展控制 | EPT 访问/脏位、EPTP 切换和虚拟处理器 ID（VPID）可进一步减少剩余的虚拟化开销。<sup>[6](https://cdrdv2-public.intel.com/872188/872188-001.pdf)</sup> |

## SLAT 解决的问题

在硬件支持出现之前，hypervisor 必须维护客户机页表映射的影子副本，将客户机虚拟地址直接转换为宿主机物理地址。<sup>[7](https://www.intel.com/content/www/us/en/developer/articles/technical/increase-performance-of-vm-workloads-with-thp.html)</sup> 影子分页带来了显著的性能开销：客户机可以自由修改其页表层级，而每一次这样的修改，连同 TLB 刷新和 CR3 加载，都必须被截获，以便 hypervisor 更新影子结构。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup> VMM 还可能为每台虚拟机维护多套影子分页结构，而 EPT 分页结构只需要一套。<sup>[8](https://www.intel.com/content/dam/www/public/us/en/documents/research/2010-vol14-iss-3-intel-technology-journal.pdf)</sup>

有了 SLAT，客户机保留自己的页表，将客户机虚拟地址映射到客户机物理地址，而 hypervisor 则编程设置一套独立的第二层级结构，将客户机物理地址映射到宿主机物理地址。客户机可以修改其页表而无需被截获；硬件在每次内存访问时合并两级转换。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup>

## 二维遍历的工作方式

当 SLAT 启用时，处理器执行两阶段转换。它首先遍历通过 CR3 引用的客户机分页结构，生成客户机物理地址，然后遍历 EPT（或嵌套）分页结构，将该 GPA 转换为宿主机物理地址。Intel 将基于 EPT 的转换描述为与普通线性地址转换过程非常相似，从 EPT PML4 表开始，随后是 EPT 页目录指针表、EPT 页目录和 EPT 页表。<sup>[8](https://www.intel.com/content/dam/www/public/us/en/documents/research/2010-vol14-iss-3-intel-technology-journal.pdf)</sup>

Intel EPT 根通过扩展页表指针（EPTP）定位，这是一个 VM 执行控制字段，其第 51:12 位给出一个 4 KB、自然对齐的 EPT PML4 表的物理地址，该表包含 512 个 64 位项。EPT PML4E 使用客户机物理地址的第 47:39 位来选择，因此它控制对客户机物理地址空间中 512 GB 区域的访问。<sup>[4](https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3c-part-3-manual.pdf)</sup>

开销体现在 TLB 未命中上。对客户机页表每一级的访问本身都必须通过第二层级结构进行转换，因此在 x86-64 上，4 级客户机遍历加上 4 级宿主机遍历最多可能需要 24 次内存引用，而无虚拟化时最多只需 4 次。<sup>[5](https://ieeexplore.ieee.org/document/7011387/)</sup> 页遍历缓存和大页在实践中可以减少这一开销，但在 Intel Skylake 处理器上的测量表明，虚拟化模式下许多程序在 TLB 未命中的转换上仍要花费数百个周期。<sup>[9](https://www.researchgate.net/publication/317607869_Rethinking_TLB_Designs_in_Virtualized_Environments_A_Very_Large_Part-of-Memory_TLB)</sup> 研究界的替代方案直接针对顺序结构：嵌套弹性杜鹃页表（nested elastic cuckoo page tables）消除了潜在 24 个顺序步骤中除三个之外的所有步骤，使用 4 KB 页时应用执行速度平均提升至原来的 1.19 倍，使用大页时提升至原来的 1.24 倍。<sup>[10](https://ktisis.cut.ac.cy/entities/publication/d3c601bd-4b3a-4600-9ba0-548b2732b9da)</sup>

## Intel EPT 与 AMD NPT

**Intel EPT。** EPT 通过“启用 EPT”次级基于处理器的 VM 执行控制按虚拟机启用。违反 EPT 权限或转换未映射的 GPA 会导致 EPT 违规 VM 退出，hypervisor 通过更新 EPT 层级来处理。<sup>[1](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)</sup> Intel 数据手册将 EPT 描述为硬件辅助的页表虚拟化，消除了客户机操作系统因影子页表维护而向 VMM 产生的 VM 退出。<sup>[6](https://cdrdv2-public.intel.com/872188/872188-001.pdf)</sup>

**AMD NPT。** AMD 的对应实现是 AMD-V 下的嵌套分页，以快速虚拟化索引之名推出，从 Family 10h [皓龙](https://www.edgepedia.org/zh/opteron)起出现在处理器数据手册中。<sup>[11](https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/datasheets/40036.pdf)</sup> 在嵌套分页中，页错误可以在客户机级或嵌套页表级引发；一旦客户机线性地址到客户机物理地址的映射已知且客户机权限检查通过，就在嵌套页表中遍历 GPA 以找到系统物理地址，该转换期间的任何故障都会导致 #VMEXIT(NPF)。<sup>[2](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)</sup> 当嵌套分页启用时，处理器合并客户机和嵌套页表的内存类型，利用两个层级中的 PAT 类型以及 MTRR，后者仅基于系统物理地址进行引用。<sup>[2](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)</sup>

## 软件支持

KVM 中的 x86 MMU 围绕两种方案设计：它可以使用第一代 MMU 硬件，能够在进入客户机时原子地更改活动分页模式和 CR3，同时也以 AMD NPT 和 Intel EPT 的形式处理二维分页。如果所需的转换次数等于硬件提供的次数，MMU 以直接模式运行；在其他所有情况下，它以影子模式运行。<sup>[3](https://docs.kernel.org/virt/kvm/x86/mmu.html)</sup> KVM 支持客户机和宿主机大页与小页的所有组合，支持的页大小为 4k、2M、4M 和 1G；4M 页被视为两个独立的 2M 页，因为 MMU 始终使用 PAE 分页。<sup>[3](https://docs.kernel.org/virt/kvm/x86/mmu.html)</sup>

大页之所以重要，是因为单个 EPT 项随后覆盖一个大区域：一旦建立大页映射，大页内的所有基础页区域共享单个 EPT 项，因此 hypervisor 失去了对各个基础页区域访问的感知。<sup>[12](https://arxiv.org/abs/2307.10618)</sup> 在嵌套虚拟化中，客户机 hypervisor 增加了另一层页映射，宿主机和客户机的大页策略必须协同工作以实现正确的大页对齐，即客户机大页由宿主机大页支撑。<sup>[13](https://researchwith.njit.edu/en/publications/effective-huge-page-strategies-for-tlb-miss-reduction-in-nested-v/)</sup>

## 扩展特性

若干特性构建在 SLAT 层级之上，以减少剩余开销：<sup>[6](https://cdrdv2-public.intel.com/872188/872188-001.pdf)</sup>

- **EPT 访问位和脏位**使 VMM 能够高效实现内存管理和页分类算法，优化 VM 内存操作，如碎片整理、分页、实时迁移和检查点。没有硬件 A/D 位时，VMM 通过将 EPT 分页结构标记为不存在或只读来模拟它们，从而导致 EPT 页错误 VM 退出及相关的软件处理。
- **EPTP 切换**允许 VMX 非根模式下的客户机软件在没有 VM 退出的情况下请求不同的 EPT 分页结构层级，从 VMX 根模式下软件预先确定的一组潜在 EPTP 值中进行选择。
- **虚拟处理器 ID（VPID）**分配一个 VM ID 来标记 TLB 等硬件结构，避免 VM 切换时的刷新，降低 VM 切换成本。

## 安全应用

SLAT 层级也是强制实施安全策略和隔离的原语。通过 EPT，VMM 可以要求每个客户机物理地址为 4 KB，并防止客户机软件更改用于转换的硬件页大小，从而缓解页大小更改时可能出现的机器检查错误。<sup>[14](https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/machine-check-error-avoidance-on-page-size-change.html)</sup> 由于第二级页表由 hypervisor 管理，且违规由硬件直接传递给它，基于 EPT 的内存追踪对客户机保持不可见，尽管性能开销相当大。<sup>[15](https://tklengyel.com/thesis.pdf)</sup>

机密计算架构扩展了这一理念。Intel TDX 为每个信任域维护独立的安全 EPT 和共享 EPT，以及一个称为物理地址元数据表（Physical-Address-Metadata Table，PAMT）的追踪结构，使得映射到一个 TD 的安全 EPT 中的页无法映射到任何其他 TD 的安全 EPT 中。<sup>[16](https://cdrdv2-public.intel.com/690419/TDX-Whitepaper-February2022.pdf)</sup> AMD 的 SEV-SNP（安全嵌套分页）是 SEV 的下一代，增加了基于硬件的内存完整性保护，抵御恶意 hypervisor 攻击，如数据重放和内存重映射。<sup>[17](https://www.amd.com/content/dam/amd/en/documents/epyc-business-docs/white-papers/SEV-SNP-strengthening-vm-isolation-with-integrity-protection-and-more.pdf)</sup>

## 嵌套虚拟化

当为客户机分区启用嵌套虚拟化时，该分区暴露的 MMU 包括对二级地址转换的支持，L1 hypervisor 可以利用它为自己的客户机虚拟化物理内存。每个二级地址空间由客户机定义的 64 位 ID 值标识；在 Intel 平台上该值为 EPT 指针，在 AMD 平台上等于 VMCB nCR3 字段。<sup>[18](https://learn.microsoft.com/fr-fr/virtualization/hyper-v-on-windows/tlfs/nested-virtualization)</sup> Hypervisor 暴露针对虚拟化优化的刷新超级调用，如 HvCallFlushGuestPhysicalAddressSpace 和 HvCallFlushGuestPhysicalAddressList，使客户机能够高效地使缓存的二级 TLB 映射失效。<sup>[18](https://learn.microsoft.com/fr-fr/virtualization/hyper-v-on-windows/tlfs/nested-virtualization)</sup>

## References

1. [Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3B (Chapter 24, Extended Page Tables)](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/253669.pdf)
2. [AMD64 Architecture Programmer's Manual, Volume 2: System Programming](https://docs.amd.com/api/khub/documents/sD1_QL~h4Afq2_tvzxqqSQ/content)
3. [The x86 KVM shadow MMU, Linux Kernel documentation](https://docs.kernel.org/virt/kvm/x86/mmu.html)
4. [Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3C, Part 3](https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3c-part-3-manual.pdf)
5. [Efficient Memory Virtualization: Reducing Dimensionality of Nested Page Walks, MICRO 2014, IEEE](https://ieeexplore.ieee.org/document/7011387/)
6. [Intel Core Ultra Processors (Series 3) Datasheet, Volume 1 of 2](https://cdrdv2-public.intel.com/872188/872188-001.pdf)
7. [Improving VM workload performance with THP, Intel Developer](https://www.intel.com/content/www/us/en/developer/articles/technical/increase-performance-of-vm-workloads-with-thp.html)
8. [Intel Technology Journal, Volume 14, Issue 3, 2010](https://www.intel.com/content/dam/www/public/us/en/documents/research/2010-vol14-iss-3-intel-technology-journal.pdf)
9. [Rethinking TLB Designs in Virtualized Environments: A Very Large Part-of-Memory TLB](https://www.researchgate.net/publication/317607869_Rethinking_TLB_Designs_in_Virtualized_Environments_A_Very_Large_Part-of-Memory_TLB)
10. [Parallel virtualized memory translation with nested elastic cuckoo page tables](https://ktisis.cut.ac.cy/entities/publication/d3c601bd-4b3a-4600-9ba0-548b2732b9da)
11. [Family 10h AMD Opteron Processor Product Data Sheet](https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/datasheets/40036.pdf)
12. [FHPM: Fine-grained Huge Page Management For Virtualization, arXiv](https://arxiv.org/abs/2307.10618)
13. [Effective Huge Page Strategies for TLB Miss Reduction in Nested Virtualization, IEEE Transactions on Computers](https://researchwith.njit.edu/en/publications/effective-huge-page-strategies-for-tlb-miss-reduction-in-nested-v/)
14. [Machine Check Error Avoidance on Page Size Change, Intel Software Security Guidance](https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/machine-check-error-avoidance-on-page-size-change.html)
15. [T. K. Lengyel, thesis on virtual machine introspection and EPT-based tracing](https://tklengyel.com/thesis.pdf)
16. [Intel Trust Domain Extensions White Paper](https://cdrdv2-public.intel.com/690419/TDX-Whitepaper-February2022.pdf)
17. [AMD SEV-SNP: Strengthening VM Isolation with Integrity Protection and More](https://www.amd.com/content/dam/amd/en/documents/epyc-business-docs/white-papers/SEV-SNP-strengthening-vm-isolation-with-integrity-protection-and-more.pdf)
18. [Nested Virtualization, Microsoft Hyper-V Top Level Functional Specification](https://learn.microsoft.com/fr-fr/virtualization/hyper-v-on-windows/tlfs/nested-virtualization)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › 处理器与处理器工程 › 指令集架构 › CPU运行模式与ISA支持机制

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/second-level-address-translation

English original: https://www.edgepedia.org/second-level-address-translation
