요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
==============
Nitro Enclaves
==============
Overview
========
Nitro Enclaves (NE) is a new Amazon Elastic Compute Cloud (EC2) capability
that allows customers to carve out isolated compute environments within EC2
instances [1].
For example, an application that processes sensitive data and runs in a VM,
can be separated from other applications running in the same VM. This
application then runs in a separate VM than the primary VM, namely an enclave.
It runs alongside the VM that spawned it. This setup matches low latency
applications needs.
The current supported architectures for the NE kernel driver, available in the
upstream Linux kernel, are x86 and ARM64.
The resources that are allocated for the enclave, such as memory and CPUs, are
carved out of the primary VM. Each enclave is mapped to a process running in the
primary VM, that communicates with the NE kernel driver via an ioctl interface.
In this sense, there are two components:
1. An enclave abstraction process - a user space process running in the primary
VM guest that uses the provided ioctl interface of the NE driver to spawn an
enclave VM (that's 2 below).
There is a NE emulated PCI device exposed to the primary VM. The driver for this
new PCI device is included in the NE driver.
The ioctl logic is mapped to PCI device commands e.g. the NE_START_ENCLAVE ioctl
maps to an enclave start PCI command. The PCI device commands are then
translated into actions taken on the hypervisor side; that's the Nitro
hypervisor running on the host where the primary VM is running. The Nitro
hypervisor is based on core KVM technology.
2. The enclave itself - a VM running on the same host as the primary VM that
spawned it. Memory and CPUs are carved out of the primary VM and are dedicated
for the enclave VM. An enclave does not have persistent storage attached.
The memory regions carved out of the primary VM and given to an enclave need to
be aligned 2 MiB / 1 GiB physically contiguous memory regions (or multiple of
this size e.g. 8 MiB). The memory can be allocated e.g. by using hugetlbfs from
user space [2][3][7]. The memory size for an enclave needs to be at least
64 MiB. The enclave memory and CPUs need to be from the same NUMA node.
An enclave runs on dedicated cores. CPU 0 and its CPU siblings need to remain
available for the primary VM. A CPU pool has to be set for NE purposes by an
user with admin capability. See the cpu list section from the kernel
documentation [4] for how a CPU pool format looks.
An enclave communicates with the primary VM via a local communication channel,
using virtio-vsock [5]. The primary VM has virtio-pci vsock emulated device,
while the enclave VM has a virtio-mmio vsock emulated device. The vsock device
uses eventfd for signaling. The enclave VM sees the usual interfaces - local
APIC and IOAPIC - to get interrupts from virtio-vsock device. The virtio-mmio
device is placed in memory below the typical 4 GiB.
The application that runs in the enclave needs to be packaged in an enclave
image together with the OS ( e.g. kernel, ramdisk, init ) that will run in the
enclave VM. The enclave VM has its own kernel and follows the standard Linux
boot protocol [6][8].
The kernel bzImage, the kernel command line, the ramdisk(s) are part of the
Enclave Image Format (EIF); plus an EIF header including metadata such as magic
number, eif version, image size and CRC.
Hash values are computed for the entire enclave image (EIF), the kernel and
ramdisk(s). That's used, for example, to check that the enclave image that is
loaded in the enclave VM is the one that was intended to be run.
These crypto measurements are included in a signed attestation document
generated by the Nitro Hypervisor and further used to prove the identity of the
enclave; KMS is an example of service that NE is integrated with and that checks
the attestation doc.
The enclave image (EIF) is loaded in the enclave memory at offset 8 MiB. The
init process in the enclave connects to the vsock CID of the primary VM and a
predefined port - 9000 - to send a heartbeat value - 0xb7. This mechanism is
used to check in the primary VM that the enclave has booted. The CID of the
primary VM is 3.
If the enclave VM crashes or gracefully exits, an interrupt event is received by
the NE driver. This event is sent further to the user space enclave process
running in the primary VM via a poll notification mechanism. Then the user space
enclave process can exit.
[1] https://aws.amazon.com/ec2/nitro/nitro-enclaves/
[2] https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
[3] https://lwn.net/Articles/807108/
[4] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
[5] https://man7.org/linux/man-pages/man7/vsock.7.html
[6] https://www.kernel.org/doc/html/latest/x86/boot.html
[7] https://www.kernel.org/doc/html/latest/arm64/hugetlbpage.html
[8] https://www.kernel.org/doc/html/latest/arm64/booting.html
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Nitro Enclaves 개요
1-21Nitro Enclaves(NE)는 Amazon EC2 instance 안에서 격리된 compute environment를 떼어 낼 수 있게 하는 기능입니다.
예를 들어 하나의 VM에서 sensitive data를 처리하는 application을 다른 application과 분리할 수 있습니다. 분리한 application은 primary VM과 나란히 실행되는 별도 VM인 enclave에서 동작합니다.
Enclave는 자신을 생성한 primary VM과 같은 host에서 실행되므로 격리를 유지하면서도 low-latency application 요구에 맞는 가까운 통신 경로를 제공합니다.
Upstream Linux kernel의 NE kernel driver가 현재 지원하는 architecture는 x86과 ARM64입니다.
Primary VM 안의 민감 workload를 별도 VM으로 분리합니다.
Application을 enclave image와 함께 별도 VM에서 실행합니다.
.. SPDX-License-Identifier: GPL-2.0
==============
Nitro Enclaves
==============
Overview
========
Nitro Enclaves (NE) is a new Amazon Elastic Compute Cloud (EC2) capability
that allows customers to carve out isolated compute environments within EC2
instances [1].
For example, an application that processes sensitive data and runs in a VM,
can be separated from other applications running in the same VM. This
application then runs in a separate VM than the primary VM, namely an enclave.
It runs alongside the VM that spawned it. This setup matches low latency
applications needs.
The current supported architectures for the NE kernel driver, available in the
upstream Linux kernel, are x86 and ARM64.
Primary VM process와 NE device
22-40Enclave에 할당하는 memory와 CPU는 primary VM에서 carve out합니다. 각 enclave는 primary VM에서 실행되는 하나의 process에 mapping되고, 이 process가 ioctl interface로 NE kernel driver와 통신합니다.
첫 번째 component인 enclave abstraction process는 primary VM guest의 userspace process입니다. NE driver가 제공하는 ioctl을 사용해 두 번째 component인 enclave VM을 생성합니다.
Primary VM에는 NE emulated PCI device가 노출되며 이 새 PCI device의 driver도 NE driver에 포함됩니다.
Ioctl logic은 PCI device command로 mapping됩니다. 예를 들어 `NE_START_ENCLAVE` ioctl은 enclave start PCI command가 됩니다.
PCI command는 primary VM이 실행되는 host의 Nitro Hypervisor 동작으로 번역됩니다. Nitro Hypervisor는 core KVM technology를 기반으로 합니다.
Userspace 관리 process와 실제 enclave VM의 역할입니다.
Userspace request가 host action으로 변환됩니다.
The resources that are allocated for the enclave, such as memory and CPUs, are
carved out of the primary VM. Each enclave is mapped to a process running in the
primary VM, that communicates with the NE kernel driver via an ioctl interface.
In this sense, there are two components:
1. An enclave abstraction process - a user space process running in the primary
VM guest that uses the provided ioctl interface of the NE driver to spawn an
enclave VM (that's 2 below).
There is a NE emulated PCI device exposed to the primary VM. The driver for this
new PCI device is included in the NE driver.
The ioctl logic is mapped to PCI device commands e.g. the NE_START_ENCLAVE ioctl
maps to an enclave start PCI command. The PCI device commands are then
translated into actions taken on the hypervisor side; that's the Nitro
hypervisor running on the host where the primary VM is running. The Nitro
hypervisor is based on core KVM technology.
Enclave memory와 CPU
41-55두 번째 component인 enclave 자체는 primary VM이 생성하고 같은 host에서 실행되는 VM입니다. Memory와 CPU를 primary VM에서 떼어 enclave 전용으로 사용하며 persistent storage는 연결하지 않습니다.
Enclave memory region은 physical contiguous해야 하고 2 MiB 또는 1 GiB에 정렬된 region이어야 합니다. 8 MiB처럼 해당 크기의 배수도 사용할 수 있습니다.
Userspace는 `hugetlbfs` 등을 사용해 memory를 할당할 수 있습니다. Enclave memory size는 최소 64 MiB이며 enclave memory와 CPU는 같은 NUMA node에서 가져와야 합니다.
Enclave는 dedicated core에서 실행됩니다. CPU 0과 그 CPU sibling은 primary VM에 남겨 두어야 합니다.
Admin capability를 가진 사용자가 NE 용도의 CPU pool을 설정해야 합니다. CPU pool 형식은 kernel documentation의 CPU list 형식을 따릅니다.
Memory, CPU, storage의 필수 조건입니다.
Primary VM 자원을 enclave 전용 상태로 전환합니다.
2. The enclave itself - a VM running on the same host as the primary VM that
spawned it. Memory and CPUs are carved out of the primary VM and are dedicated
for the enclave VM. An enclave does not have persistent storage attached.
The memory regions carved out of the primary VM and given to an enclave need to
be aligned 2 MiB / 1 GiB physically contiguous memory regions (or multiple of
this size e.g. 8 MiB). The memory can be allocated e.g. by using hugetlbfs from
user space [2][3][7]. The memory size for an enclave needs to be at least
64 MiB. The enclave memory and CPUs need to be from the same NUMA node.
An enclave runs on dedicated cores. CPU 0 and its CPU siblings need to remain
available for the primary VM. A CPU pool has to be set for NE purposes by an
user with admin capability. See the cpu list section from the kernel
documentation [4] for how a CPU pool format looks.
Primary VM과 enclave 통신
56-62Enclave는 local communication channel인 `virtio-vsock`으로 primary VM과 통신합니다.
Primary VM에는 `virtio-pci` vsock emulated device가 있고 enclave VM에는 `virtio-mmio` vsock emulated device가 있습니다. Vsock device는 signaling에 `eventfd`를 사용합니다.
Enclave VM은 virtio-vsock interrupt를 받기 위해 일반적인 local APIC과 IOAPIC interface를 봅니다. `virtio-mmio` device는 일반적인 4 GiB 경계 아래 memory에 배치됩니다.
Primary VM과 enclave의 transport 차이입니다.
같은 host의 두 VM이 device model을 달리해 연결됩니다.
An enclave communicates with the primary VM via a local communication channel,
using virtio-vsock [5]. The primary VM has virtio-pci vsock emulated device,
while the enclave VM has a virtio-mmio vsock emulated device. The vsock device
uses eventfd for signaling. The enclave VM sees the usual interfaces - local
APIC and IOAPIC - to get interrupts from virtio-vsock device. The virtio-mmio
device is placed in memory below the typical 4 GiB.
EIF image와 attestation
63-80Enclave에서 실행할 application은 enclave VM의 OS와 함께 하나의 enclave image로 packaging해야 합니다. OS 구성에는 kernel, ramdisk, init 등이 포함되고 enclave VM은 자체 kernel로 standard Linux boot protocol을 따릅니다.
EIF(Enclave Image Format)에는 kernel `bzImage`, kernel command line, 하나 이상의 ramdisk가 들어갑니다.
EIF header에는 magic number, EIF version, image size와 CRC 같은 metadata가 포함됩니다.
전체 EIF, kernel, ramdisk 각각에 hash를 계산합니다. 이를 통해 enclave VM에 load한 image가 실행하도록 의도한 image와 일치하는지 확인할 수 있습니다.
Nitro Hypervisor는 이 cryptographic measurement를 signed attestation document에 넣어 enclave identity를 증명합니다. KMS는 NE와 통합되어 attestation document를 검사하는 service의 예입니다.
Boot payload와 integrity metadata입니다.
Packaging한 payload를 측정하고 identity로 연결합니다.
The application that runs in the enclave needs to be packaged in an enclave
image together with the OS ( e.g. kernel, ramdisk, init ) that will run in the
enclave VM. The enclave VM has its own kernel and follows the standard Linux
boot protocol [6][8].
The kernel bzImage, the kernel command line, the ramdisk(s) are part of the
Enclave Image Format (EIF); plus an EIF header including metadata such as magic
number, eif version, image size and CRC.
Hash values are computed for the entire enclave image (EIF), the kernel and
ramdisk(s). That's used, for example, to check that the enclave image that is
loaded in the enclave VM is the one that was intended to be run.
These crypto measurements are included in a signed attestation document
generated by the Nitro Hypervisor and further used to prove the identity of the
enclave; KMS is an example of service that NE is integrated with and that checks
the attestation doc.
Boot heartbeat와 종료 통지
81-91EIF는 enclave memory offset 8 MiB에 load됩니다. Enclave의 init process는 primary VM의 vsock CID와 미리 정한 port `9000`에 연결합니다.
Init은 heartbeat 값 `0xb7`을 보내고 primary VM은 이를 받아 enclave가 boot되었는지 확인합니다. Primary VM의 CID는 `3`입니다.
Enclave VM이 crash하거나 정상 종료하면 NE driver가 interrupt event를 받습니다. Driver는 poll notification으로 primary VM의 userspace enclave process에 event를 전달합니다.
종료 notification을 받은 userspace enclave process는 lifecycle 정리를 마친 뒤 exit할 수 있습니다.
Boot 확인과 종료 통지에 쓰는 값입니다.
Image load부터 userspace process 정리까지입니다.
The enclave image (EIF) is loaded in the enclave memory at offset 8 MiB. The
init process in the enclave connects to the vsock CID of the primary VM and a
predefined port - 9000 - to send a heartbeat value - 0xb7. This mechanism is
used to check in the primary VM that the enclave has booted. The CID of the
primary VM is 3.
If the enclave VM crashes or gracefully exits, an interrupt event is received by
the NE driver. This event is sent further to the user space enclave process
running in the primary VM via a poll notification mechanism. Then the user space
enclave process can exit.
참고 자료
92-100원문은 Nitro Enclaves 소개, huge page와 kernel parameter, vsock, x86·ARM64 boot protocol 자료를 함께 제시합니다.
이 링크들은 architecture별 memory 준비와 boot image 구성, primary VM과 enclave의 통신 interface를 더 자세히 확인하는 출발점입니다.
번호와 주제를 보존했습니다.
[1] https://aws.amazon.com/ec2/nitro/nitro-enclaves/
[2] https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
[3] https://lwn.net/Articles/807108/
[4] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
[5] https://man7.org/linux/man-pages/man7/vsock.7.html
[6] https://www.kernel.org/doc/html/latest/x86/boot.html
[7] https://www.kernel.org/doc/html/latest/arm64/hugetlbpage.html
[8] https://www.kernel.org/doc/html/latest/arm64/booting.html
요약·해설
ne_overview.rst:1-100Primary VM에서 memory와 CPU를 떼어 격리 enclave를 만들고 ioctl·PCI command로 lifecycle을 제어하는 구조를 설명합니다.
Resource alignment, vsock device 차이, EIF measurement와 attestation, boot heartbeat 및 종료 notification을 구조화했습니다.