NestedSGX: Bootstrapping Trust to Enclaves within Confidential VMs

Wenhao Wang, Linke Song, Benshan Mei, Shuang Liu, Shijun Zhao, Shoumeng Yan, XiaoFeng Wang, Dan Meng, Rui Hou · DOI

Abstract

Confidential Virtual Machines (CVMs) like AMD SEV-SNP and Intel TDX provide isolation from hypervisors but leave a significant "trust gap" within the VM itself: the guest operating system. NestedSGX bridges this gap by enabling secure hardware enclaves inside CVMs. By leveraging hardware privilege levels (VMPL), NestedSGX achieves performance nearly two orders of magnitude faster than previous virtualization attempts while maintaining compatibility with the Intel SGX ecosystem.

Introduction: The Intra-VM Trust Gap

Confidential Computing has traditionally focused on protecting workloads from malicious cloud providers or hypervisors. Technologies such as AMD SEV and Intel TDX create isolated CVMs to achieve this. However, the guest OS remains a massive, untrusted attack surface. A compromise at the OS level grants an attacker full access to applications within that CVM.

While Intel SGX was designed to isolate applications from the OS via enclaves, it is not natively available on non-Intel platforms. Previous attempts to virtualize SGX (e.g., vSGX) suffered from extreme performance overhead—often 160x slower than native hardware—due to the cost of hypervisor-mediated context switching. NestedSGX addresses these challenges by providing a high-performance, intra-VM enclave environment.

Architecture and Methods

NestedSGX introduces a "defense-in-depth" approach by nesting enclave isolation within a single CVM. The core innovation lies in the use of Virtual Machine Privilege Levels (VMPL), a feature of AMD SEV-SNP.

NestedSGX architecture utilizing AMD SEV-SNP privilege levels (VMPL).

The system architecture is divided into two primary privilege domains:

  1. Higher Privilege (VMPL0): Hosts a small, trusted Security Monitor (~5,500 lines of code) and the sensitive Enclave.
  2. Lower Privilege (VMPL1): Hosts the untrusted Guest OS and the non-sensitive portions of the Application.

Because AMD hardware does not natively support SGX instructions, NestedSGX emulates them. When an application initiates an enclave entry (e.g., EENTER), it triggers a transition to the Security Monitor at VMPL0. The monitor handles context switching and manages memory isolation via a shadow page table scheme, ensuring the Guest OS cannot access enclave memory. To ensure practicality, the authors ported the Intel SGX SDK, Rust SGX SDK, and Occlum library OS, allowing existing SGX apps to run with minimal modification.

Evaluation and Key Results

The authors evaluated NestedSGX using micro-benchmarks and real-world applications, including SQLite, Redis, and TLS servers.

Performance Benchmarks

  • Context Switching: NestedSGX context switches take approximately 32,000–34,000 cycles. While this is ~2x slower than native Intel SGX, it is 160x faster than vSGX.
  • Computational Overhead: For compute-heavy workloads like nbench, the overhead is negligible (under 2%).
  • I/O Intensive Workloads: In scenarios like Redis, the overhead reaches approximately 15.68% due to frequent system calls, which remains practical for production environments.

Comparative Analysis

NestedSGX distinguishes itself from prior work by supporting multi-threading, exception handling, and an unlimited number of enclaves without requiring hypervisor modifications.

Feature comparison between NestedSGX and existing virtualization frameworks.

Insights and Future Directions

The primary breakthrough of NestedSGX is the shift from inter-VM to intra-VM isolation. By using hardware privilege levels rather than separate VMs, the system eliminates the massive overhead of cross-VM communication. This significantly reduces the Trusted Computing Base (TCB) by removing the requirement to trust the full Linux kernel.

Future work aims to address current limitations, such as the lack of enclave memory swapping and the inability of the guest OS to inject interrupts directly into VMPL0. The authors also suggest that this architectural pattern is portable to other platforms, such as Intel TDX (via TD partitioning) and ARM CCA.

Summary updated

BibTeX
@inproceedings{wang2025nestedsgx,
  author = {Wenhao Wang and Linke Song and Benshan Mei and Shuang Liu and Shijun Zhao and Shoumeng Yan and XiaoFeng Wang and Dan Meng and Rui Hou},
  title = {{NestedSGX: Bootstrapping Trust to Enclaves within Confidential VMs}},
  booktitle = {Ndss},
  year = {2025},
}
Figure