diff mbox

[RFC,v3,12/18] sev: add LAUNCH_FINISH command

Message ID 147801563839.18237.14009371805896523682.stgit@brijesh-build-machine (mailing list archive)
State New, archived
Headers show

Commit Message

Brijesh Singh Nov. 1, 2016, 3:53 p.m. UTC
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 <brijesh.singh@amd.com>
---
 sev.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
diff mbox

Patch

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