Message ID | 20180212153715.87555-14-brijesh.singh@amd.com |
---|---|
State | New |
Headers | show |
Series | [v8,01/28] memattrs: add debug attribute | expand |
On 02/12/2018 09:37 AM, Brijesh Singh wrote: > The QMP query command can used to retrieve the SEV information when > memory encryption is enabled on AMD platform. > > Cc: "Daniel P. Berrangé" <berrange@redhat.com> > Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > Cc: Markus Armbruster <armbru@redhat.com> > Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> > --- > +# @SevInfo: > +# > +# Information about Secure Encrypted Virtualization (SEV) support > +# > +# @enabled: true if SEV is active > +# > +# @api-major: SEV API major version > +# > +# @api-minor: SEV API minor version > +# > +# @build-id: SEV FW build id > +# > +# @policy: SEV policy value > +# > +# @state: SEV guest state Is there a finite list of guest states? > +# > +# Since: 2.12 > +## > +{ 'struct': 'SevInfo', > + 'data': { 'enabled': 'bool', > + 'api-major': 'uint8', > + 'api-minor' : 'uint8', > + 'build-id' : 'uint8', > + 'policy' : 'uint32', > + 'state' : 'str' If so, this should be an enum type listing those possible states, rather than an open-coded 'str' that can hold anything.
On 2/12/18 11:27 AM, Eric Blake wrote: > On 02/12/2018 09:37 AM, Brijesh Singh wrote: >> The QMP query command can used to retrieve the SEV information when >> memory encryption is enabled on AMD platform. >> >> Cc: "Daniel P. Berrangé" <berrange@redhat.com> >> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> >> Cc: Markus Armbruster <armbru@redhat.com> >> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> >> --- > >> +# @SevInfo: >> +# >> +# Information about Secure Encrypted Virtualization (SEV) support >> +# >> +# @enabled: true if SEV is active >> +# >> +# @api-major: SEV API major version >> +# >> +# @api-minor: SEV API minor version >> +# >> +# @build-id: SEV FW build id >> +# >> +# @policy: SEV policy value >> +# >> +# @state: SEV guest state > > Is there a finite list of guest states? > Yes, the list is finite. include/sysemu/sev.h defines the enum typedef enum { SEV_STATE_UNINIT = 0, SEV_STATE_LUPDATE, SEV_STATE_SECRET, SEV_STATE_RUNNING, SEV_STATE_SUPDATE, SEV_STATE_RUPDATE, SEV_STATE_MAX } >> +# >> +# Since: 2.12 >> +## >> +{ 'struct': 'SevInfo', >> + 'data': { 'enabled': 'bool', >> + 'api-major': 'uint8', >> + 'api-minor' : 'uint8', >> + 'build-id' : 'uint8', >> + 'policy' : 'uint32', >> + 'state' : 'str' > > If so, this should be an enum type listing those possible states, > rather than an open-coded 'str' that can hold anything. > If the preference is to return enum, then I can convert the state to return enum instead of string.
diff --git a/qapi-schema.json b/qapi-schema.json index 5c06745c7927..9203e28b8aee 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3189,3 +3189,50 @@ # Since: 2.11 ## { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## +# @SevInfo: +# +# Information about Secure Encrypted Virtualization (SEV) support +# +# @enabled: true if SEV is active +# +# @api-major: SEV API major version +# +# @api-minor: SEV API minor version +# +# @build-id: SEV FW build id +# +# @policy: SEV policy value +# +# @state: SEV guest state +# +# Since: 2.12 +## +{ 'struct': 'SevInfo', + 'data': { 'enabled': 'bool', + 'api-major': 'uint8', + 'api-minor' : 'uint8', + 'build-id' : 'uint8', + 'policy' : 'uint32', + 'state' : 'str' + } +} + +## +# @query-sev: +# +# Returns information about SEV +# +# Returns: @SevInfo +# +# Since: 2.12 +# +# Example: +# +# -> { "execute": "query-sev" } +# <- { "return": { "enabled": true, "api-major" : 0, "api-minor" : 0, +# "build-id" : 0, "policy" : 0, "state" : "running" } } +# +## +{ 'command': 'query-sev', 'returns': 'SevInfo' } diff --git a/qmp.c b/qmp.c index 793f6f332302..7907e539c8f2 100644 --- a/qmp.c +++ b/qmp.c @@ -39,6 +39,7 @@ #include "qom/object_interfaces.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/acpi_dev_interface.h" +#include "sysemu/sev.h" NameInfo *qmp_query_name(Error **errp) { @@ -719,3 +720,18 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } + +SevInfo *qmp_query_sev(Error **errp) +{ + SevInfo *info = g_malloc0(sizeof(*info)); + + info->enabled = sev_enabled(); + if (info->enabled) { + sev_get_fw_version(&info->api_major, + &info->api_minor, &info->build_id); + sev_get_policy(&info->policy); + sev_get_current_state(&info->state); + } + + return info; +}
The QMP query command can used to retrieve the SEV information when memory encryption is enabled on AMD platform. Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> --- qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++++++++++++++ qmp.c | 16 ++++++++++++++++ 2 files changed, 63 insertions(+)