From nobody Sun Nov 24 12:46:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1723981480; cv=none; d=zohomail.com; s=zohoarc; b=VWBzgqaJALRz/14tfxllFA+i35qDeycj3i7m6O4ShvD0aYqVBYpQmTyOMQ5yB+SPJbPebnCGVCUYHrLTjtQcfEYyrKqokz5rDRck/rx9VXNGi2n2bTIkjo2QrPX2gQJd8T0C8Qmt1LosiYIl++UYQsYisMI5uPX6itnOxJ1sWcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723981480; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BpttYhHnPM+huelBNQ4yO/oz0L1BTguXsb4YaRzWkMg=; b=Wn6wdaQeAir74Pu+qWPFRrInY065TcsuO2X9tF3NYOLrx9xSOcDhYy+NAvHeY7sKh3F5DiHmqYKrqAT4dF0R62PkEuJsu9uv+GIsAQosMySZzhkt1+KlkpazcCG+VSDKAiunQwqjzaMd7nfCYgZVpMXWIyF6oukHx/cuymklpRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1723981480974712.1802962469951; Sun, 18 Aug 2024 04:44:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfeK7-0003bs-Rl; Sun, 18 Aug 2024 07:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfeK2-0003am-CQ for qemu-devel@nongnu.org; Sun, 18 Aug 2024 07:43:47 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfeJr-0001bY-7V for qemu-devel@nongnu.org; Sun, 18 Aug 2024 07:43:45 -0400 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-70938328a0aso1789426a34.1 for ; Sun, 18 Aug 2024 04:43:34 -0700 (PDT) Received: from localhost.localdomain ([103.103.35.174]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3e2c61fe4sm5303617a91.4.2024.08.18.04.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 04:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723981413; x=1724586213; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BpttYhHnPM+huelBNQ4yO/oz0L1BTguXsb4YaRzWkMg=; b=Jm+sDatnt+1q7hpclkZWYmBPvDkx5MAJyH5Jf3ktegxynhTrFKWkGX1FuTcrduIxU6 DHhhpyCaQPoOk0WMpz6aucbeJ2433A4HryRlARLw4kKrF10Cs7oqm1ZmpO5qpxZCxvof 1fhSw2OWoRY7Y9d4H/pYsWgHCJ4FxBNHqtkUYi458p4MIw2xumsq4mHAN7qIzu+AdqP+ 7b5zt1f7Q5XduB+sUc96vpUippPJ1Kg0NYqMot3JfIXLGzupncMLzHlHLQCvmkXJUh7U CTfXGBU/mgeG9gRasDL7jJJ2Qb4FV3o48y9QEl8MUW8ZMd4xzE8sdtsa3kh+31yZV968 Soww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723981413; x=1724586213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BpttYhHnPM+huelBNQ4yO/oz0L1BTguXsb4YaRzWkMg=; b=R+c3cZzvoIPdYBq8geIIV1n5e9XH7pizmJZnKuD9z9SLLfChPAq5Dt+91nKI6onM4F fxakivFxz/pF0MFddY9r9bT5Y1lgyjyqOhSymMuGoWCYo2GKWwo9HaeOz4jIm1NJ9sKB prdS4CwclZ1uoM92ydYs91Vg3fsfRfh2uEsRP/L+E1BxA8US/KaBIb55/JsSashfyc44 snvmztfvhXHY52vTOhvHTLlcZ7oDzgvszKTKZ3S0ojs3kfaTXaFJBWuEHEtZt3BEOGw0 I3P9miTIYL+WKwneYh8fCKiWVn8jifZkgI7jaGdtFjNkkQqdnCaiLvHmlO6xi+lx+a0k rMag== X-Gm-Message-State: AOJu0YyMYvlCsgVimB2DMYEgtkOMTGPGSjKl+aYo/VmOVW460iOTnu5Q XZzyRxDDHHFmkVL0sxg13TNQBtgqr1jVhtLWOcAHsrngMzBO2wqmTK3qBw== X-Google-Smtp-Source: AGHT+IF1J4K3U9XS6GEFJOWEZIZ0oPYirSJvpkyZeRHTfC4wk6pHfoIMgCI2mlveufknE8CfxsBQ5g== X-Received: by 2002:a05:6830:2656:b0:708:f88a:e3e7 with SMTP id 46e09a7af769-70cac8d4e13mr12141825a34.34.1723981413510; Sun, 18 Aug 2024 04:43:33 -0700 (PDT) From: Dorjoy Chowdhury 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 v4 6/6] docs/nitro-enclave: Documentation for nitro-enclave machine type Date: Sun, 18 Aug 2024 17:42:57 +0600 Message-Id: <20240818114257.21456-7-dorjoychy111@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240818114257.21456-1-dorjoychy111@gmail.com> References: <20240818114257.21456-1-dorjoychy111@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::32b; envelope-from=dorjoychy111@gmail.com; helo=mail-ot1-x32b.google.com X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1723981482202116600 Content-Type: text/plain; charset="utf-8" --- docs/system/i386/nitro-enclave.rst | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 docs/system/i386/nitro-enclave.rst diff --git a/docs/system/i386/nitro-enclave.rst b/docs/system/i386/nitro-en= clave.rst new file mode 100644 index 0000000000..291a8ae357 --- /dev/null +++ b/docs/system/i386/nitro-enclave.rst @@ -0,0 +1,82 @@ +'nitro-enclave' virtual machine (``nitro-enclave``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +``nitro-enclave`` is a machine type which emulates an ``AWS nitro enclave`` +virtual machine. `AWS nitro enclaves`_ is an `Amazon EC2`_ feature that al= lows +creating isolated execution environments, called enclaves, from Amazon EC2 +instances which are used for processing highly sensitive data. Enclaves ha= ve +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 whi= le +the enclave VM gets a dynamic CID. Enclaves use an EIF (`Enclave Image For= mat`_) +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 usefu= l for +local testing of EIF files using QEMU instead of running real AWS Nitro En= claves +which can be difficult for debugging due to its roots in security. The vso= ck +device emulation is done using vhost-user-vsock which means another proces= s that +can do the userspace emulation, like `vhost-device-vsock`_ from rust-vmm c= rate, +must be run alongside nitro-enclave for the vsock communication to work. + +.. _AWS nitro enlaves: https://docs.aws.amazon.com/enclaves/latest/user/ni= tro-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=3Dstring (required) (Id of the chardev from '-charde= v' option that vhost-user-vsock device will use) +- nitro-enclave.id=3Dstring (optional) (Set enclave identifier) +- nitro-enclave.parent-role=3Dstring (optional) (Set parent instance IAM r= ole ARN) +- nitro-enclave.parent-id=3Dstring (optional) (Set parent instance identif= ier) + + +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=3D4,uds-path=3D/tmp/vm4.vsock,socket=3D/tmp/vhost4.soc= ket \ + --vm guest-cid=3D3,uds-path=3D/tmp/vm3.vsock,socket=3D/tmp/vhost3.soc= ket + +Then, run the parent VM that has the necessary vsock communication support. + + $ qemu-system-x86_64 -machine q35,memory-backend=3Dmem0 -enable-kvm -m 8= G \ + -nic user,model=3Dvirtio -drive file=3Dtest_vm.qcow2,media=3Ddisk,if= =3Dvirtio \ + --display sdl -object memory-backend-memfd,id=3Dmem0,size=3D8G \ + -chardev socket,id=3Dchar0,reconnect=3D0,path=3D/tmp/vhost3.socket \ + -device vhost-user-vsock-pci,chardev=3Dchar0 + +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 (0x= B7) to +let the parent VM know that it booted expecting a heartbeat (0xB7) respons= e. + +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 machin= e: + + $ qemu-system-x86_64 -M nitro-enclave,vsock=3Dc,id=3Dhello-world \ + -kernel hello-world.eif -nographic -m 4G --enable-kvm -cpu host \ + -chardev socket,id=3Dc,path=3D/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-de= vice-vsock +or similar tool for vhost-user-vsock support and another VM with CID 3 wit= h necessary +vsock communication support. Requirement of running another VM and necessa= ry 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. --=20 2.39.2