From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bO3-0005yy-Ry for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bNz-0003x1-Pd for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:07 -0400 Received: from mail-sn1nam02on0047.outbound.protection.outlook.com ([104.47.36.47]:9225 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bNz-0003wt-I6 for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:03 -0400 From: Brijesh Singh Date: Tue, 1 Nov 2016 11:53:58 -0400 Message-ID: <147801563839.18237.14009371805896523682.stgit@brijesh-build-machine> In-Reply-To: <147801550845.18237.12915616525154608660.stgit@brijesh-build-machine> References: <147801550845.18237.12915616525154608660.stgit@brijesh-build-machine> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH v3 12/18] sev: add LAUNCH_FINISH command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas.Lendacky@amd.com, ehabkost@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mst@redhat.com, p.fedin@samsung.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, rth@twiddle.net Cc: brijesh.ksingh@gmail.com The command is used to finalize the SEV guest launch process. The command returns a measurement value of the data encrypted through the LAUNCH_UPDATE command. This measurement can be handed to the guest owner to verify that the guest was launched into SEV-enabled mode. Signed-off-by: Brijesh Singh --- sev.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sev.c b/sev.c index fafef6f..ff9266a 100644 --- a/sev.c +++ b/sev.c @@ -278,7 +278,30 @@ sev_launch_start(SEVState *s) static int sev_launch_finish(SEVState *s) { - return 0; + int ret; + struct kvm_sev_launch_finish *data; + + assert(s->state == SEV_STATE_LAUNCHING); + + data = g_malloc0(sizeof(*data)); + if (!data) { + return 1; + } + + ret = sev_ioctl(KVM_SEV_LAUNCH_FINISH, data); + if (ret) { + goto err; + } + + DPRINTF("SEV: LAUNCH_FINISH "); + DPRINTF_U8_PTR(" measurement", data->measurement, + sizeof(data->measurement)); + + s->state = SEV_STATE_RUNNING; +err: + g_free(data); + + return ret; } static int