sev/i386: qmp: add query-sev-capabilities command
authorBrijesh Singh <brijesh.singh@amd.com>
Thu, 8 Mar 2018 12:48:59 +0000 (06:48 -0600)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 13 Mar 2018 16:36:05 +0000 (17:36 +0100)
The command can be used by libvirt to query the SEV capabilities.

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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
monitor.c
qapi/misc.json
target/i386/monitor.c
tests/qmp-test.c

index 36ed0879e43566f8d6f4f008d1ac569f1415fec7..3117a3e68936b90aa474137f4b9c06881c5d1508 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -985,6 +985,7 @@ static void qmp_unregister_commands_hack(void)
     qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection");
     qmp_unregister_command(&qmp_commands, "query-sev");
     qmp_unregister_command(&qmp_commands, "query-sev-launch-measure");
+    qmp_unregister_command(&qmp_commands, "query-sev-capabilities");
 #endif
 #ifndef TARGET_S390X
     qmp_unregister_command(&qmp_commands, "dump-skeys");
@@ -4117,6 +4118,12 @@ SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp)
     error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-launch-measure");
     return NULL;
 }
+
+SevCapability *qmp_query_sev_capabilities(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-capabilities");
+    return NULL;
+}
 #endif
 
 #ifndef TARGET_S390X
index b8318f5d8be6c5d01f0d79a87232f6b528cbf1bf..6150b9a00330838780b1f1e1e5d1fe3e3aedd016 100644 (file)
 #
 ##
 { 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo' }
+
+##
+# @SevCapability:
+#
+# The struct describes capability for a Secure Encrypted Virtualization
+# feature.
+#
+# @pdh:  Platform Diffie-Hellman key (base64 encoded)
+#
+# @cert-chain:  PDH certificate chain (base64 encoded)
+#
+# @cbitpos: C-bit location in page table entry
+#
+# @reduced-phys-bits: Number of physical Address bit reduction when SEV is
+#                     enabled
+#
+# Since: 2.12
+##
+{ 'struct': 'SevCapability',
+  'data': { 'pdh': 'str',
+            'cert-chain': 'str',
+            'cbitpos': 'int',
+            'reduced-phys-bits': 'int'} }
+
+##
+# @query-sev-capabilities:
+#
+# This command is used to get the SEV capabilities, and is supported on AMD
+# X86 platforms only.
+#
+# Returns: SevCapability objects.
+#
+# Since: 2.12
+#
+# Example:
+#
+# -> { "execute": "query-sev-capabilities" }
+# <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE",
+#                  "cbitpos": 47, "reduced-phys-bits": 5}}
+#
+##
+{ 'command': 'query-sev-capabilities', 'returns': 'SevCapability' }
index f8a0e4b26854278ef31a79413155e869586ea3d2..8a786fb79a22d5608ac5c7f11318bf001c58bdc3 100644 (file)
@@ -714,3 +714,9 @@ SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp)
 
     return info;
 }
+
+SevCapability *qmp_query_sev_capabilities(Error **errp)
+{
+    error_setg(errp, "SEV feature is not available");
+    return NULL;
+}
index ec8c7c78b7ef960291ca5b15d3279fda2d203734..7470c6b754bca3dbbf25825338d93c50206a29aa 100644 (file)
@@ -208,6 +208,7 @@ static bool query_is_blacklisted(const char *cmd)
         "query-sev-launch-measure",
         /* Success depends on Host or Hypervisor SEV support */
         "query-sev",
+        "query-sev-capabilities",
         NULL
     };
     int i;