From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: [PATCH v12 09/28] qmp: add query-sev command Date: Thu, 8 Mar 2018 06:48:42 -0600 Message-ID: <20180308124901.83533-10-brijesh.singh@amd.com> References: <20180308124901.83533-1-brijesh.singh@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Peter Maydell , Brijesh Singh , kvm@vger.kernel.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Alexander Graf , "Edgar E. Iglesias" , Markus Armbruster , Bruce Rogers , Christian Borntraeger , Marcel Apfelbaum , Borislav Petkov , Thomas Lendacky , Eduardo Habkost , Richard Henderson , "Dr. David Alan Gilbert" , Alistair Francis , Cornelia Huck , Peter Crosthwaite , Paolo Bonzini To: qemu-devel@nongnu.org Return-path: In-Reply-To: <20180308124901.83533-1-brijesh.singh@amd.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel2=m.gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org The QMP query command can used to retrieve the SEV information when memory encryption is enabled on AMD platform. Cc: Eric Blake Cc: "Daniel P. Berrang=C3=A9" Cc: "Dr. David Alan Gilbert" Cc: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Brijesh Singh --- monitor.c | 7 +++++ qapi/misc.json | 76 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ target/i386/monitor.c | 8 ++++++ 3 files changed, 91 insertions(+) diff --git a/monitor.c b/monitor.c index 3f4ba902266b..2225cf5030dc 100644 --- a/monitor.c +++ b/monitor.c @@ -983,6 +983,7 @@ static void qmp_unregister_commands_hack(void) #endif #ifndef TARGET_I386 qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); + qmp_unregister_command(&qmp_commands, "query-sev"); #endif #ifndef TARGET_S390X qmp_unregister_command(&qmp_commands, "dump-skeys"); @@ -4103,6 +4104,12 @@ void qmp_rtc_reset_reinjection(Error **errp) { error_setg(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection"); } + +SevInfo *qmp_query_sev(Error **errp) +{ + error_setg(errp, QERR_FEATURE_DISABLED, "query-sev"); + return NULL; +} #endif =20 #ifndef TARGET_S390X diff --git a/qapi/misc.json b/qapi/misc.json index bd04469a4ba2..14681729f8fc 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3201,3 +3201,79 @@ # Since: 2.9 ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } + + +## +# @SevState: +# +# An enumeration of SEV state information used during @query-sev. +# +# @uninit: The guest is uninitialized. +# +# @lupdate: The guest is currently being launched and plaintext and +# reigster state is being imported. +# +# @lsecret: The guest is currently being launched and ciphertext data +# are being imported. +# +# @running: The guest is fully launched or migrated in. +# +# @supdate: The guest is currently being migrated out to another machine. +# +# @rupdate: The guest is currently being migrated from another machine. +# +# Since: 2.12 +## +{ 'enum': 'SevState', + 'data': ['uninit', 'lupdate', 'lsecret', 'running', 'supdate', 'rupdate'= ] } + +## +# @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 +# +# @handle: SEV firmware handle +# +# Since: 2.12 +## +{ 'struct': 'SevInfo', + 'data': { 'enabled': 'bool', + 'api-major': 'uint8', + 'api-minor' : 'uint8', + 'build-id' : 'uint8', + 'policy' : 'uint32', + 'state' : 'SevState', + 'handle' : 'uint32' + } +} + +## +# @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", +# "handle" : 1 } } +# +## +{ 'command': 'query-sev', 'returns': 'SevInfo' } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 55ea10deb8ef..27b99adf395b 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -30,6 +30,8 @@ #include "hw/i386/pc.h" #include "sysemu/kvm.h" #include "hmp.h" +#include "sev_i386.h" +#include "qapi/qapi-commands-misc.h" =20 =20 static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr, @@ -665,3 +667,9 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict) ioapic_dump_state(mon, qdict); } } + +SevInfo *qmp_query_sev(Error **errp) +{ + error_setg(errp, "SEV feature is not available"); + return NULL; +} --=20 2.14.3