Skip to content

Commit

Permalink
sev/i386: hmp: add 'info sev' command
Browse files Browse the repository at this point in the history
The command can be used to show the SEV information when memory
encryption is enabled on AMD platform.

Cc: Eric Blake <eblake@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Reviewed-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
codomania authored and bonzini committed Mar 13, 2018
1 parent 6cb8f2a commit 6303631
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions hmp-commands-info.hx
Expand Up @@ -867,6 +867,22 @@ Display the amount of initially allocated and present hotpluggable (if
enabled) memory in bytes.
ETEXI

#if defined(TARGET_I386)
{
.name = "sev",
.args_type = "",
.params = "",
.help = "show SEV information",
.cmd = hmp_info_sev,
},
#endif

STEXI
@item info sev
@findex info sev
Show SEV information.
ETEXI

STEXI
@end table
ETEXI
Expand Down
1 change: 1 addition & 0 deletions hmp.h
Expand Up @@ -143,5 +143,6 @@ void hmp_info_ramblock(Monitor *mon, const QDict *qdict);
void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict);
void hmp_info_sev(Monitor *mon, const QDict *qdict);

#endif
20 changes: 20 additions & 0 deletions target/i386/monitor.c
Expand Up @@ -29,6 +29,7 @@
#include "qapi/qmp/qdict.h"
#include "hw/i386/pc.h"
#include "sysemu/kvm.h"
#include "sysemu/sev.h"
#include "hmp.h"
#include "qapi/error.h"
#include "sev_i386.h"
Expand Down Expand Up @@ -677,3 +678,22 @@ SevInfo *qmp_query_sev(Error **errp)

return info;
}

void hmp_info_sev(Monitor *mon, const QDict *qdict)
{
SevInfo *info = sev_get_info();

if (info && info->enabled) {
monitor_printf(mon, "handle: %d\n", info->handle);
monitor_printf(mon, "state: %s\n", SevState_str(info->state));
monitor_printf(mon, "build: %d\n", info->build_id);
monitor_printf(mon, "api version: %d.%d\n",
info->api_major, info->api_minor);
monitor_printf(mon, "debug: %s\n",
info->policy & SEV_POLICY_NODBG ? "off" : "on");
monitor_printf(mon, "key-sharing: %s\n",
info->policy & SEV_POLICY_NOKS ? "off" : "on");
} else {
monitor_printf(mon, "SEV is not enabled\n");
}
}

0 comments on commit 6303631

Please sign in to comment.