From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5Nv-0001rd-D1 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5Nq-0008Am-7g for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:58 -0400 Received: from mail-co1nam03on0051.outbound.protection.outlook.com ([104.47.40.51]:8349 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5Np-0008AP-UN for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:54 -0400 From: Brijesh Singh Date: Thu, 22 Sep 2016 10:53:46 -0400 Message-ID: <147455602652.8519.16942814867897007687.stgit@brijesh-build-machine> In-Reply-To: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> References: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH v2 11/16] sev: add LAUNCH_FINISH command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 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 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. User can retrieve the measurement via 'measurement' property defined in 'sev-launch-info' object. Signed-off-by: Brijesh Singh --- sev.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sev.c b/sev.c index dcd7c48..21c491c 100644 --- a/sev.c +++ b/sev.c @@ -955,7 +955,21 @@ sev_launch_start(SEVState *s) static int sev_launch_finish(SEVState *s) { - // add the command to finalize the launch in next patches + int ret; + struct kvm_sev_launch_finish *finish = s->launch_finish; + + assert(s->state == SEV_STATE_LAUNCHING); + + ret = sev_ioctl(KVM_SEV_LAUNCH_FINISH, finish); + if (ret) { + return -1; + } + + DPRINTF("SEV: LAUNCH_FINISH "); + DPRINTF_U8_PTR(" measurement", finish->measurement, + sizeof(finish->measurement)); + + s->state = SEV_STATE_RUNNING; return 0; } @@ -1058,7 +1072,6 @@ sev_guest_launch_finish(void *handle) if (s->state == SEV_STATE_LAUNCHING) { return sev_launch_finish(s); - // use launch_finish commands } else if (s->state == SEV_STATE_RECEIVING) { // use receive_finish commands } else {