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>
This commit is contained in:
Brijesh Singh 2018-03-08 06:48:56 -06:00 committed by Paolo Bonzini
parent 6303631467
commit 1b6a034f29
4 changed files with 55 additions and 0 deletions

View File

@ -984,6 +984,7 @@ static void qmp_unregister_commands_hack(void)
#ifndef TARGET_I386 #ifndef TARGET_I386
qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection");
qmp_unregister_command(&qmp_commands, "query-sev"); qmp_unregister_command(&qmp_commands, "query-sev");
qmp_unregister_command(&qmp_commands, "query-sev-launch-measure");
#endif #endif
#ifndef TARGET_S390X #ifndef TARGET_S390X
qmp_unregister_command(&qmp_commands, "dump-skeys"); 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"); error_setg(errp, QERR_FEATURE_DISABLED, "query-sev");
return NULL; return NULL;
} }
SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp)
{
error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-launch-measure");
return NULL;
}
#endif #endif
#ifndef TARGET_S390X #ifndef TARGET_S390X

View File

@ -3293,3 +3293,32 @@
# #
## ##
{ 'command': 'query-sev', 'returns': 'SevInfo' } { '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' }

View File

@ -697,3 +697,20 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "SEV is not enabled\n"); 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;
}

View File

@ -204,6 +204,8 @@ static bool query_is_blacklisted(const char *cmd)
"query-gic-capabilities", /* arm */ "query-gic-capabilities", /* arm */
/* Success depends on target-specific build configuration: */ /* Success depends on target-specific build configuration: */
"query-pci", /* CONFIG_PCI */ "query-pci", /* CONFIG_PCI */
/* Success depends on launching SEV guest */
"query-sev-launch-measure",
/* Success depends on Host or Hypervisor SEV support */ /* Success depends on Host or Hypervisor SEV support */
"query-sev", "query-sev",
NULL NULL