Intel SGX - Memory 보호 기법
Gu, Jinyu, et al. "A {Hardware-Software} Co-design for Efficient {Intra-Enclave} Isolation." 31st USENIX Security Symposium (USENIX Security 22). 2022.
SGX protects user-level code/data by providing hardware-enforced trusted execution environments dubbed enclaves.
SGX는 enclaves라고 하는 하드웨어 강제 신뢰 실행 환경을 제공하여 사용자 수준의 코드/데이터를 보호합니다.
Secure memory
SGX reserves some DRAM as secure memory called Enclave Page Cache (EPC) for storing enclave memory pages.
SGX는 일부 DRAM을 enclave 메모리 페이지를 저장하기 위해 EPC(Enclave Page Cache)라는 보안 메모리로 둡니다.
CPU tracks the metadata of each EPC page through Enclave Page Cache Map (EPCM).
CPU는 EPCM(Enclave Page Cache Map)을 통해 각 EPC 페이지의 메타데이터를 추적합니다.
EPCM also resides in the secure memory, holds one entry for each EPC page, and each entry contains the read, write, execute permission, the mapped virtual address, the owner enclave, etc.
For enclave memory accesses, memory management unit (MMU) will check not only the page table information but also the EPCMinformation (e.g., an EPC page can only be accessed by its owner enclave).
또한 EPCM은 보안 메모리에 상주하며 각 EPC 페이지에 대해 하나의 항목을 보유하며 각 항목에는 읽기, 쓰기, 실행 권한, 매핑된 가상 주소, 소유자 엔클로저 등이 포함됩니다.
엔클레이브 메모리 액세스의 경우, MMU(Memory Management Unit)는 페이지 테이블 정보뿐만 아니라 EPC 정보도 확인합니다(예: EPC 페이지는 소유자 엔클레이브만 액세스할 수 있음).
Enclave creation
Enclave creation instructions are privileged and thus are executed by the OS.
enclave 생성 명령은 OS에서 실행됩니다.(엔클레이브 생성 명령은 권한이 있기 때문)
Since SGX does not trust OS, CPU records a measurement during an enclave creation.
SGX는 OS를 신뢰하지 않으므로 CPU는 enclave 생성 중에 측정값을 기록합니다.
Enclave execution
When entering the enclave, a thread exclusively occupies an enclave TCS (one EPC page) which designates one fixed entry point and the State Save Area (SSA) for the execution.
The enclave execution can be interrupted by exceptions or interrupts.
enclave에 들어가면 thread가 enclave TCS(1개의 EPC 페이지)를 독점적으로 점유하는데, enclave TCS는 하나의 고정된 진입점과 실행을 위한 상태 State Save Area(SSA)을 지정합니다.
exceptions 또는 interrupts로 인해 enclave 실행이 중단될 수 있습니다.
The enclave execution can be interrupted by exceptions or interrupts.
exceptions 또는 interrupts로 인해 enclave 실행이 중단될 수 있습니다.
If so, CPU performs Asynchronous Enclave Exit (AEX) which saves the execution context into the SSA within the enclave, scrubs the context, etc.
이 경우 CPU는 실행 컨텍스트를 enclave 내 SSA에 저장하고 컨텍스트를 스크럽하는 Asynchronous Enclave Exit(AEX)를 수행합니다.
An EPC page can be added to a running enclave through the cooperation of the enclave and the OS
EPC 페이지는 enclave와 OS를 통해 실행 중인 enclave에 추가할 수 있습니다.