qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dorjoy Chowdhury <dorjoychy111@gmail.com>
To: qemu-devel@nongnu.org
Cc: graf@amazon.com, agraf@csgraf.de, stefanha@redhat.com,
	pbonzini@redhat.com, slp@redhat.com,
	richard.henderson@linaro.org, eduardo@habkost.net,
	mst@redhat.com, marcel.apfelbaum@gmail.com, berrange@redhat.com,
	philmd@linaro.org
Subject: [PATCH v5 8/8] docs/nitro-enclave: Documentation for nitro-enclave machine type
Date: Thu, 22 Aug 2024 21:08:49 +0600	[thread overview]
Message-ID: <20240822150849.21759-9-dorjoychy111@gmail.com> (raw)
In-Reply-To: <20240822150849.21759-1-dorjoychy111@gmail.com>

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
---
 docs/system/i386/nitro-enclave.rst | 85 ++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 docs/system/i386/nitro-enclave.rst

diff --git a/docs/system/i386/nitro-enclave.rst b/docs/system/i386/nitro-enclave.rst
new file mode 100644
index 0000000000..966691c396
--- /dev/null
+++ b/docs/system/i386/nitro-enclave.rst
@@ -0,0 +1,85 @@
+'nitro-enclave' virtual machine (``nitro-enclave``)
+===================================================
+
+``nitro-enclave`` is a machine type which emulates an ``AWS nitro enclave``
+virtual machine. `AWS nitro enclaves`_ is an `Amazon EC2`_ feature that allows
+creating isolated execution environments, called enclaves, from Amazon EC2
+instances which are used for processing highly sensitive data. Enclaves have
+no persistent storage and no external networking. The enclave VMs are based
+on Firecracker microvm with a vhost-vsock device for communication with the
+parent EC2 instance that spawned it and a Nitro Secure Module (NSM) device
+for cryptographic attestation. The parent instance VM always has CID 3 while
+the enclave VM gets a dynamic CID. Enclaves use an EIF (`Enclave Image Format`_)
+file which contains the necessary kernel, cmdline and ramdisk(s) to boot.
+
+In QEMU, ``nitro-enclave`` is a machine type based on ``microvm`` similar to how
+``AWS nitro enclaves`` are based on ``Firecracker`` microvm. This is useful for
+local testing of EIF files using QEMU instead of running real AWS Nitro Enclaves
+which can be difficult for debugging due to its roots in security. The vsock
+device emulation is done using vhost-user-vsock which means another process that
+can do the userspace emulation, like `vhost-device-vsock`_ from rust-vmm crate,
+must be run alongside nitro-enclave for the vsock communication to work.
+
+``libcbor`` and ``gnutls`` are required dependencies for nitro-enclave machine
+support to be added when building QEMU from source.
+
+.. _AWS nitro enlaves: https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html
+.. _Amazon EC2: https://aws.amazon.com/ec2/
+.. _Enclave Image Format: https://github.com/aws/aws-nitro-enclaves-image-format
+.. _vhost-device-vsock: https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-vsock
+
+Using the nitro-enclave machine type
+------------------------------
+
+Machine-specific options
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+It supports the following machine-specific options:
+
+- nitro-enclave.vsock=string (required) (Id of the chardev from '-chardev' option that vhost-user-vsock device will use)
+- nitro-enclave.id=string (optional) (Set enclave identifier)
+- nitro-enclave.parent-role=string (optional) (Set parent instance IAM role ARN)
+- nitro-enclave.parent-id=string (optional) (Set parent instance identifier)
+
+
+Running a nitro-enclave VM
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+First, run vhost-device-vsock (or a similar tool that supports vhost-user-vsock)
+
+  $ vhost-device-vsock \
+     --vm guest-cid=4,uds-path=/tmp/vm4.vsock,socket=/tmp/vhost4.socket \
+     --vm guest-cid=3,uds-path=/tmp/vm3.vsock,socket=/tmp/vhost3.socket
+
+Then, run the parent VM that has the necessary vsock communication support.
+
+  $ qemu-system-x86_64 -machine q35,memory-backend=mem0 -enable-kvm -m 8G \
+     -nic user,model=virtio -drive file=test_vm.qcow2,media=disk,if=virtio \
+     --display sdl -object memory-backend-memfd,id=mem0,size=8G \
+     -chardev socket,id=char0,reconnect=0,path=/tmp/vhost3.socket \
+     -device vhost-user-vsock-pci,chardev=char0
+
+Inside this VM the necessary applications should be run so that the nitro-enclave
+VM applications' vsock communication works. For example, the nitro-enclave VM's
+init process connects to CID 3 and sends a single byte hello heartbeat (0xB7) to
+let the parent VM know that it booted expecting a heartbeat (0xB7) response.
+
+Now run the nitro-enclave VM using the following command where ``hello.eif`` is
+an EIF file you would use to spawn a real AWS nitro enclave virtual machine:
+
+  $ qemu-system-x86_64 -M nitro-enclave,vsock=c,id=hello-world \
+     -kernel hello-world.eif -nographic -m 4G --enable-kvm -cpu host \
+     -chardev socket,id=c,path=/tmp/vhost4.socket
+
+In this example, the nitro-enclave VM has CID 4.
+
+
+Limitations
+-----------
+
+AWS nitro enclave emulation support in QEMU requires users to run vhost-device-vsock
+or similar tool for vhost-user-vsock support and another VM with CID 3 with necessary
+vsock communication support. Requirement of running another VM and necessary applications
+inside it can be lifted if some proxying support is added to vhost-device-vsock to
+forward all packets to the host machine, in which case, users can run the necessary
+applications in the host machine instead of the parent VM with CID 3.
-- 
2.39.2



  parent reply	other threads:[~2024-08-22 15:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 15:08 [PATCH v5 0/8] AWS Nitro Enclave emulation support Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 1/8] crypto: Define macros for hash algorithm digest lengths Dorjoy Chowdhury
2024-08-28 15:33   ` Daniel P. Berrangé
2024-08-22 15:08 ` [PATCH v5 2/8] crypto: Support SHA384 hash when using glib Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 3/8] crypto: Introduce x509 utils Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 4/8] tests/lcitool: Update libvirt-ci and add libcbor dependency Dorjoy Chowdhury
2024-08-28 15:34   ` Daniel P. Berrangé
2024-08-22 15:08 ` [PATCH v5 5/8] device/virtio-nsm: Support for Nitro Secure Module device Dorjoy Chowdhury
2024-08-28 18:28   ` Michael S. Tsirkin
2024-08-28 19:04     ` Dorjoy Chowdhury
2024-08-28 19:11       ` Michael S. Tsirkin
2024-09-03 19:58         ` Dorjoy Chowdhury
2024-09-03 20:32           ` Michael S. Tsirkin
2024-09-03 20:47             ` Dorjoy Chowdhury
2024-09-04 18:30               ` Dorjoy Chowdhury
2024-09-04 20:27                 ` Michael S. Tsirkin
2024-09-04 20:45                   ` Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 6/8] hw/core: Add Enclave Image Format (EIF) related helpers Dorjoy Chowdhury
2024-08-28 15:42   ` Daniel P. Berrangé
2024-08-22 15:08 ` [PATCH v5 7/8] machine/nitro-enclave: New machine type for AWS Nitro Enclaves Dorjoy Chowdhury
2024-08-28 15:39   ` Daniel P. Berrangé
2024-08-28 15:50     ` Dorjoy Chowdhury
2024-08-29  8:14       ` Daniel P. Berrangé
2024-09-05 20:00         ` Dorjoy Chowdhury
2024-08-22 15:08 ` Dorjoy Chowdhury [this message]
2024-09-05 20:03 ` [PATCH v5 0/8] AWS Nitro Enclave emulation support Dorjoy Chowdhury

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240822150849.21759-9-dorjoychy111@gmail.com \
    --to=dorjoychy111@gmail.com \
    --cc=agraf@csgraf.de \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=graf@amazon.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).