diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2018-03-08 06:48:56 -0600 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-13 17:36:05 +0100 |
commit | 1b6a034f293a8928b48765a496ce95bed0cdddc4 (patch) | |
tree | c869fb2cda1e614b3425c17c598f86b139b87d96 | |
parent | 630363146765dd9379893d5b78ae9356ef6c766d (diff) | |
download | qemu-1b6a034f293a8928b48765a496ce95bed0cdddc4.zip qemu-1b6a034f293a8928b48765a496ce95bed0cdddc4.tar.gz qemu-1b6a034f293a8928b48765a496ce95bed0cdddc4.tar.bz2 |
sev/i386: qmp: add query-sev-launch-measure command
The command can be used by libvirt to retrieve the measurement of SEV guest.
This measurement is a signature of the memory contents that was encrypted
through the LAUNCH_UPDATE_DATA.
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | monitor.c | 7 | ||||
-rw-r--r-- | qapi/misc.json | 29 | ||||
-rw-r--r-- | target/i386/monitor.c | 17 | ||||
-rw-r--r-- | tests/qmp-test.c | 2 |
4 files changed, 55 insertions, 0 deletions
@@ -984,6 +984,7 @@ static void qmp_unregister_commands_hack(void) #ifndef TARGET_I386 qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); qmp_unregister_command(&qmp_commands, "query-sev"); + qmp_unregister_command(&qmp_commands, "query-sev-launch-measure"); #endif #ifndef TARGET_S390X qmp_unregister_command(&qmp_commands, "dump-skeys"); @@ -4110,6 +4111,12 @@ SevInfo *qmp_query_sev(Error **errp) error_setg(errp, QERR_FEATURE_DISABLED, "query-sev"); return NULL; } + +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) +{ + error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-launch-measure"); + return NULL; +} #endif #ifndef TARGET_S390X diff --git a/qapi/misc.json b/qapi/misc.json index 7b628c2..b8318f5 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3293,3 +3293,32 @@ # ## { 'command': 'query-sev', 'returns': 'SevInfo' } + +## +# @SevLaunchMeasureInfo: +# +# SEV Guest Launch measurement information +# +# @data: the measurement value encoded in base64 +# +# Since: 2.12 +# +## +{ 'struct': 'SevLaunchMeasureInfo', 'data': {'data': 'str'} } + +## +# @query-sev-launch-measure: +# +# Query the SEV guest launch information. +# +# Returns: The @SevLaunchMeasureInfo for the guest +# +# Since: 2.12 +# +# Example: +# +# -> { "execute": "query-sev-launch-measure" } +# <- { "return": { "data": "4l8LXeNlSPUDlXPJG5966/8%YZ" } } +# +## +{ 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo' } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 64b5e6e..f8a0e4b 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -697,3 +697,20 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict) monitor_printf(mon, "SEV is not enabled\n"); } } + +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) +{ + char *data; + SevLaunchMeasureInfo *info; + + data = sev_get_launch_measurement(); + if (!data) { + error_setg(errp, "Measurement is not available"); + return NULL; + } + + info = g_malloc0(sizeof(*info)); + info->data = data; + + return info; +} diff --git a/tests/qmp-test.c b/tests/qmp-test.c index a77ff92..ec8c7c7 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -204,6 +204,8 @@ static bool query_is_blacklisted(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + /* Success depends on launching SEV guest */ + "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ "query-sev", NULL |