From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elGBY-0003Th-Qy for qemu-devel@nongnu.org; Mon, 12 Feb 2018 10:38:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elGBV-0004DP-Kd for qemu-devel@nongnu.org; Mon, 12 Feb 2018 10:38:28 -0500 Received: from mail-by2nam01on0070.outbound.protection.outlook.com ([104.47.34.70]:50592 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elGBV-0004C9-EU for qemu-devel@nongnu.org; Mon, 12 Feb 2018 10:38:25 -0500 From: Brijesh Singh Date: Mon, 12 Feb 2018 09:37:00 -0600 Message-ID: <20180212153715.87555-14-brijesh.singh@amd.com> In-Reply-To: <20180212153715.87555-1-brijesh.singh@amd.com> References: <20180212153715.87555-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v8 13/28] qmp: add query-sev command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alistair Francis , Christian Borntraeger , Cornelia Huck , "Daniel P . Berrange" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Eric Blake , kvm@vger.kernel.org, Marcel Apfelbaum , Markus Armbruster , Paolo Bonzini , Peter Crosthwaite , Peter Maydell , Richard Henderson , Stefan Hajnoczi , Thomas Lendacky , Borislav Petkov , Alexander Graf , Bruce Rogers , Brijesh Singh The QMP query command can used to retrieve the SEV information when memory encryption is enabled on AMD platform. Cc: "Daniel P. Berrang=C3=A9" Cc: "Dr. David Alan Gilbert" Cc: Markus Armbruster Signed-off-by: Brijesh Singh --- qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++++++++++++++ qmp.c | 16 ++++++++++++++++ 2 files changed, 63 insertions(+) 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" =20 NameInfo *qmp_query_name(Error **errp) { @@ -719,3 +720,18 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp= ) =20 return mem_info; } + +SevInfo *qmp_query_sev(Error **errp) +{ + SevInfo *info =3D g_malloc0(sizeof(*info)); + + info->enabled =3D 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; +} --=20 2.14.3