# 软件防护扩展

**软件防护扩展**（Software Guard Extensions，SGX）是英特尔推出的一套 x86 指令与内存访问机制，允许应用程序将选定的代码和数据放入一块受硬件保护的内存区域，称为“安全区”（enclave）。即便操作系统、虚拟机监控器或 BIOS 已被攻破，安全区内的内容仍能保持机密与完整。<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup><sup> • </sup><sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> SGX 于 2015 年随第六代英特尔酷睿处理器首次出货，2018 年进入英特尔至强服务器平台；2026 年 10 月，英特尔宣布将在至强“钻石激流”代之后停止提供 SGX，转而主推信任域扩展（Trust Domain Extensions，TDX）——一种虚拟机级别的机密计算技术。<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup><sup> • </sup><sup>[3](https://www.intel.com/content/www/us/en/security/confidential-computing.html)</sup><sup> • </sup><sup>[4](https://www.tomshardware.com/pc-components/cpus/intel-to-phase-out-sgx-after-xeon-diamond-rapids-in-favor-of-tdx-confidential-computing-pivot-adds-trusted-i-o-and-post-quantum-crypto-for-agentic-ai)</sup>

| 关键事实 | 详情 |
|---|---|
| 保护对象 | 安全区内的选定代码与数据，与操作系统、虚拟机监控器、BIOS 及其他应用（包括特权软件）相隔离<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup><sup> • </sup><sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> |
| 受保护内存 | 安全区页缓存（Enclave Page Cache，EPC），由 4 KB 页构成，每页的安全属性记录在安全区页缓存映射表（Enclave Page Cache Map，EPCM）中<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> |
| EPC 容量 | 第一代 SGX（SGXv1）最大 256 MiB，SGXv2 为 512 MiB；Windows SDK 文档给出的典型硬上限为 64 MB 或 128 MB<sup>[5](https://www.cse.cuhk.edu.hk/~pclee/www/pubs/pvldb26sack.pdf)</sup><sup> • </sup><sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup> |
| 认证 | 远程认证允许第三方在共享数据之前核验安全区的身份与代码度量值；消费级与至强 E 系列处理器使用 EPID，较新的至强可扩展处理器使用基于 ECDSA 的认证<sup>[6](https://www.intel.com/content/www/us/en/products/details/processors/xeon/features/software-guard-extensions.html)</sup><sup> • </sup><sup>[7](https://www.intel.com/content/www/us/en/support/articles/000092568/software/intel-security-products.html)</sup> |
| 可用性 | 客户端从第六代英特尔酷睿（2015 年）及更新型号开始支持；服务器端至强自 2018 年起支持<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup><sup> • </sup><sup>[3](https://www.intel.com/content/www/us/en/security/confidential-computing.html)</sup> |
| 生命周期终止 | 钻石激流是最后一代支持 SGX 的至强；现有 SGX 平台的安全更新将持续到 2030 年代初<sup>[4](https://www.tomshardware.com/pc-components/cpus/intel-to-phase-out-sgx-after-xeon-diamond-rapids-in-favor-of-tdx-confidential-computing-pivot-adds-trusted-i-o-and-post-quantum-crypto-for-agentic-ai)</sup> |
| 性能代价 | 对高性能计算负载的实测结果显示，执行耗时为非安全执行的 1.2 至 126 倍，主要归因于安全内存容量有限及编程模型<sup>[8](https://escholarship.org/uc/item/6cr1d9zp)</sup> |

## 安全区的工作方式

安全区是应用程序地址空间内一块隔离的代码与数据区域。安全区内的数据只能由同一安全区内的代码访问，来自外部的访问企图——包括来自虚拟机监控器、操作系统或 BIOS 的访问——都会被处理器阻止。<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> 受保护的内存即安全区页缓存，是处理器用于存放运行中安全区页面的安全存储。EPC 由按 4 KB 边界对齐的 4 KB 页构成，每页的安全属性保存在安全区页缓存映射表中；EPCM 是软件无法访问的内部微架构结构，负责跟踪每页的内容并实施访问控制。<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> 安全区内存还经过加密，内存加密引擎可防御损坏与重放攻击。<sup>[9](https://cdrdv2-public.intel.com/631121/631121_TGL%20Datasheet%20Volume1of2%20rev012_PUBLIC.pdf)</sup>

**指令与特权环。** SGX 在两个特权级别上新增了指令。Ring 0 指令——ECREATE、EADD 和 EINIT——用于管理 EPC，由操作系统或虚拟机监控器等特权软件执行。Ring 3 指令——EENTER、EEXIT、EGETKEY、EREPORT 和 ERESUME——由用户态软件用来进入、离开安全区以及与安全区通信。<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> 不受信任的应用代码通常通过 EENTER 叶子函数启动一个已初始化的安全区，该函数将控制权转交给驻留在受保护 EPC 中的安全区代码。<sup>[10](https://device.report/m/4322021ebaf4e104857473a85be5c1aa70a70b0bdebddf6d9af045c7ef6187c7)</sup>

**度量与认证。** 初始化时，系统会计算安全区代码与数据的密码学哈希值，即度量值，用来核验所加载的安全区与其声明的身份相符。<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)</sup> 通过远程认证，远程一方可以在共享任何数据之前，确认某个安全区是真正的 SGX 安全区、运行的是预期代码且已安装当前安全更新；核验通过后，机密数据便可安全地推入安全区。<sup>[6](https://www.intel.com/content/www/us/en/products/details/processors/xeon/features/software-guard-extensions.html)</sup><sup> • </sup><sup>[11](https://builders.intel.com/docs/networkbuilders/zero-trust-rethink-zero-trust-with-intel-confidential-computing-technology-guide-1678432160.pdf)</sup> 消费级与至强 E 处理器使用 EPID 认证，较新的至强可扩展处理器则转向基于 ECDSA 的认证，这让数据中心客户拥有更多控制权，减少对英特尔基础设施的依赖。<sup>[7](https://www.intel.com/content/www/us/en/support/articles/000092568/software/intel-security-products.html)</sup> 对于希望自行运行认证、而不依赖第三方服务的企业与云服务商，英特尔 SGX 数据中心认证原语（Intel SGX Data Center Attestation Primitives，DCAP）提供了所需的基础组件。<sup>[12](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/sgx-product-brief-enhanced-security.pdf)</sup>

## 开发模型

SGX 要求开发者将应用拆分为可信与不可信两部分，英特尔 SDK 通过 API、库、工具和示例代码，以 C 和 C++ 支持这一过程。<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup><sup> • </sup><sup>[13](https://github.com/intel/confidential-computing.sgx)</sup> 安全区用安全区定义语言（Enclave Definition Language）描述，SDK 将底层指令细节封装在熟悉的编程环境之后。<sup>[14](https://www.intel.com/content/www/us/en/developer/videos/introduction-to-the-enclave-definition-language-intel-sgx.html)</sup> 安全区可以构建并加载为 Windows DLL。有两点需要注意：安全区文件可以被反汇编，因此其中包含的算法无法保密；受保护内存的硬上限——SDK 文档中通常为 64 MB 或 128 MB——限制了同一时间可驻留内存的安全区数量，用例表明视各自占用大小，可同时运行 5 到 20 个安全区。<sup>[1](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)</sup> SCONE、Fortanix、Anjuna 等厂商的软件工具可以让应用无需完全重写即可运行在 SGX 安全区内。<sup>[11](https://builders.intel.com/docs/networkbuilders/zero-trust-rethink-zero-trust-with-intel-confidential-computing-technology-guide-1678432160.pdf)</sup>

## SGX 与虚拟机级机密计算

SGX 是 x86 上当前一代机密计算技术中最早出现的，提供基于进程的保护，效率高但使用困难；AMD 的 SEV 后来将范式转向基于虚拟机的保护，使遗留应用基本无需改动即可部署。<sup>[15](https://www.sciencedirect.com/science/article/pii/S0167404825001464)</sup> 这里的权衡在于信任边界的大小与兼容性：进程级 TEE 的可信计算基更小，但需要专门的开发与定制；系统级 TEE 的可信计算基更大，但应用兼容性更好、迁移工作量更少。<sup>[16](https://doi.org/10.1049/cmu2.12759)</sup> 使用 SGX 时，信任边界只圈住安全区及其机密数据，云平台栈、宿主操作系统、虚拟机监控器和客户操作系统都在边界之外。<sup>[17](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/2023-07/enabling-sovereign-landing-zones-with-confidential-computing-white-paper.pdf)</sup>

这一区别解释了英特尔 2026 年 10 月的公告。SGX 隔离的是应用内选定的代码与数据，而 TDX 将整台虚拟机与宿主、虚拟机监控器及其他虚拟机隔离开来，无需对每个应用做大量改动即可保护现有工作负载。英特尔给出的理由是可扩展性、部署简便性以及大规模采用机密计算所需的运营模式，并未提及安全方面的顾虑；钻石激流将是最后一代支持 SGX 的至强，现有平台的安全更新将持续到 2030 年代初。<sup>[4](https://www.tomshardware.com/pc-components/cpus/intel-to-phase-out-sgx-after-xeon-diamond-rapids-in-favor-of-tdx-confidential-computing-pivot-adds-trusted-i-o-and-post-quantum-crypto-for-agentic-ai)</sup> TDX 已在[阿里云](https://www.edgepedia.org/zh/alibaba-cloud)、谷歌云、IBM 云、微软 Azure 和火山云等云服务商处提供。<sup>[4](https://www.tomshardware.com/pc-components/cpus/intel-to-phase-out-sgx-after-xeon-diamond-rapids-in-favor-of-tdx-confidential-computing-pivot-adds-trusted-i-o-and-post-quantum-crypto-for-agentic-ai)</sup>

## 应用

凡是在他人运营的基础设施上处理数据之处，SGX 都能派上用场。微软 Azure 提供基于 SGX 的机密计算实例（DCsv3 与 DCdsv3），通过处理器级内存加密保护使用中的数据；微软报告称，其机密计算每年保护约 250 亿美元的客户支付处理。<sup>[18](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/2024-02/microsoft-azure-confidential-computing-solution-brief.pdf)</sup> OVHcloud 等云服务商提供 SGX 实例用于基于硬件的内存加密；厂商们还构建了基于 SGX 的产品，用于安全的远程数据访问、机密数据库，以及账本数据在安全区内解密之前始终保持加密的区块链系统。<sup>[19](https://www.intel.com/content/www/us/en/architecture-and-technology/sgx-product-offerings.html)</sup><sup> • </sup><sup>[20](https://www.intel.com/content/dam/www/public/us/en/documents/solution-briefs/intro-to-confidential-computing-solution-brief.pdf)</sup> 在数据库系统中，SGX 已被用于保护表、索引和元数据，即便面对恶意的数据库管理员或已被攻破的操作系统、虚拟机监控器也是如此。<sup>[13](https://github.com/intel/confidential-computing.sgx)</sup>

## 安全记录

自推出以来，大量研究对 SGX 发起了攻击。“预兆”（Foreshadow）是一种推测执行攻击，能够可靠地从 [CPU 缓存](https://www.edgepedia.org/zh/cpu-cache)中泄露安全区的明文机密，并能提取机器的私有认证密钥；由于 SGX 认证报告无法与其签名者的身份关联，一台 SGX 机器被攻破就会侵蚀整个 SGX 生态的信任。<sup>[21](https://foreshadowattack.eu/foreshadow.pdf)</sup><sup> • </sup><sup>[22](https://www.youtube.com/watch?v=LVeWUq_mciM)</sup> 页表攻击让对抗性的系统软件通过撤销安全区页面的访问权限并记录由此产生的缺页异常，来提取敏感数据。<sup>[23](https://www.usenix.org/conference/usenixsecurity17/technical-sessions/presentation/van-bulck)</sup> 分支影子攻击在真实 SGX 硬件上揭示安全区程序的细粒度控制流，SgxPectre 则通过推测执行从安全区窃取机密。<sup>[24](https://arxiv.org/abs/1611.06952)</sup><sup> • </sup><sup>[25](https://arxiv.org/abs/1802.09085)</sup> 一份关于 SGX 攻击的综述梳理了英特尔如何在推出新微架构的同时反复修补 SGX，使得追踪哪些技术适用于哪些 SGX 设计变得十分困难。<sup>[26](https://ieeexplore.ieee.org/document/10646750/)</sup> 英特尔安全中心持续发布 SGX 安全公告，包括 2026 年 4 月一份关于 SGX 密钥可能泄露的公告。<sup>[27](https://www.intel.com/content/www/us/en/security-center/announcement/default.html)</sup>

**性能是第二重限制。** 一项针对科学计算负载的研究测得，SGX 的执行耗时为非安全执行的 1.2 至 126 倍，并得出结论：鉴于安全内存容量有限且编程模型缺乏灵活性，SGX 不适合高性能计算；同一研究发现 AMD SEV 更为合适，但对大型 NUMA 机器上的内存布局较为敏感。<sup>[8](https://escholarship.org/uc/item/6cr1d9zp)</sup> 频繁从安全区向外调用同样会降低性能，这是应用设计者必须与所获安全性相权衡的代价。<sup>[16](https://doi.org/10.1049/cmu2.12759)</sup>

## References

1. [Intel® Software Guard Extensions SDK Developer Reference for Windows* OS, Intel](https://cdrdv2-public.intel.com/671508/sgx-sdk-developer-reference-for-windows-os.pdf)
2. [Overview of an Intel Software Guard Extensions Enclave Life Cycle, Intel](https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-an-intel-software-guard-extensions-enclave-life-cycle.html?language=en%3Flanguage%3Den)
3. [Confidential Computing Solutions, Intel](https://www.intel.com/content/www/us/en/security/confidential-computing.html)
4. [Intel to phase out SGX after Xeon Diamond Rapids in favor of TDX, Tom's Hardware](https://www.tomshardware.com/pc-components/cpus/intel-to-phase-out-sgx-after-xeon-diamond-rapids-in-favor-of-tdx-confidential-computing-pivot-adds-trusted-i-o-and-post-quantum-crypto-for-agentic-ai)
5. [SGX enables fine-grained security protection (PVLD 2026 paper), CUHK](https://www.cse.cuhk.edu.hk/~pclee/www/pubs/pvldb26sack.pdf)
6. [Intel® Software Guard Extensions (Intel® SGX), Intel](https://www.intel.com/content/www/us/en/products/details/processors/xeon/features/software-guard-extensions.html)
7. [Which Processors Support Intel® Software Guard Extensions, Intel](https://www.intel.com/content/www/us/en/support/articles/000092568/software/intel-security-products.html)
8. [Performance Analysis of Scientific Computing Workloads on General Purpose TEEs, eScholarship](https://escholarship.org/uc/item/6cr1d9zp)
9. [11th Generation Intel® Core™ Processor Datasheet, Volume 1 of 2, Intel](https://cdrdv2-public.intel.com/631121/631121_TGL%20Datasheet%20Volume1of2%20rev012_PUBLIC.pdf)
10. [Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 3: System Programming Guide](https://device.report/m/4322021ebaf4e104857473a85be5c1aa70a70b0bdebddf6d9af045c7ef6187c7)
11. [Zero Trust – Rethink Zero Trust with Intel Confidential Computing Technology Guide, Intel Network Builders](https://builders.intel.com/docs/networkbuilders/zero-trust-rethink-zero-trust-with-intel-confidential-computing-technology-guide-1678432160.pdf)
12. [Enhanced Security Features for Confidential Computing Product Brief, Intel](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/sgx-product-brief-enhanced-security.pdf)
13. [github - intel/confidential-computing.sgx:intel® software guard extensions (intel® sgx) · github](https://github.com/intel/confidential-computing.sgx)
14. [Introduction to the Enclave Definition Language, Intel](https://www.intel.com/content/www/us/en/developer/videos/introduction-to-the-enclave-definition-language-intel-sgx.html)
15. [An experimental evaluation of TEE technology: Benchmarking transparent approaches based on SGX, SEV, and TDX, Computers & Security](https://www.sciencedirect.com/science/article/pii/S0167404825001464)
16. [Survey of research on confidential computing, IET Communications](https://doi.org/10.1049/cmu2.12759)
17. [Enabling Sovereign Landing Zones with Confidential Computing white paper, Intel](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/2023-07/enabling-sovereign-landing-zones-with-confidential-computing-white-paper.pdf)
18. [Microsoft Deploys Confidential Computing To Protect $25B per Year in Customer Payments, Intel solution brief](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/2024-02/microsoft-azure-confidential-computing-solution-brief.pdf)
19. [Intel® SGX Product Offerings, Intel](https://www.intel.com/content/www/us/en/architecture-and-technology/sgx-product-offerings.html)
20. [An Introduction to Confidential Computing, Intel solution brief](https://www.intel.com/content/dam/www/public/us/en/documents/solution-briefs/intro-to-confidential-computing-solution-brief.pdf)
21. [FORESHADOW: Extracting the Keys to the Intel SGX Kingdom with Transient Out-of-Order Execution](https://foreshadowattack.eu/foreshadow.pdf)
22. [Foreshadow-SGX talk, Duo Security](https://www.youtube.com/watch?v=LVeWUq_mciM)
23. [Telling Your Secrets without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution, USENIX Security 2017](https://www.usenix.org/conference/usenixsecurity17/technical-sessions/presentation/van-bulck)
24. [Inferring Fine-grained Control Flow Inside SGX Enclaves with Branch Shadowing, arXiv](https://arxiv.org/abs/1611.06952)
25. [SgxPectre Attacks: Stealing Intel Secrets from SGX Enclaves via Speculative Execution, arXiv](https://arxiv.org/abs/1802.09085)
26. [SoK: SGX.Fail: How Stuff Gets eXposed, IEEE](https://ieeexplore.ieee.org/document/10646750/)
27. [Intel® Security Bulletins, Intel](https://www.intel.com/content/www/us/en/security-center/announcement/default.html)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Processors & processor engineering › Instruction set architectures › x86 ISA extensions

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/software-guard-extensions

English original: https://www.edgepedia.org/software-guard-extensions
