From nobody Mon Feb 9 19:53:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633623538; cv=none; d=zohomail.com; s=zohoarc; b=ITJsJVd/KyQNWAdgDl2kPwfqsIwJHeFHVhqEmBqrlj8E+0umFa+u6o0YOue1CFxzeyd7gzUBmAi16NHtlHV9KF/t+JpXRiR42bZ2ADSNqG3C4hItOsYIbupc4IcOYvmukGTKVYKA03Ih1H0dizdQ+QjOMQQwhCA20UeokFvqPKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633623538; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=eCfS+Asf+f1waC4AVoz1E9eLdrSZudUp689oYCk0mwY=; b=TVH6phL+PBr1UsWu74uHmxWF1XvBKddHZc6n1DH8/hoLSdg2YvU0Rztu08iPvSA9yS/nZDEfKINzA0ZLgopTVu+GCXH5qGfH5RJ8YUmak4L/XnqP8YjQv5x/8rhxPQM7BAxCaZEF3Z9nxA0BfdQEeGi6mZWV0rRkvsaQ7GL/NS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1633623538006907.4773729690111; Thu, 7 Oct 2021 09:18:58 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-ES_6Tqc6PaW_fmrrEfuUBg-1; Thu, 07 Oct 2021 12:18:56 -0400 Received: by mail-wr1-f71.google.com with SMTP id r21-20020adfa155000000b001608162e16dso5105017wrr.15 for ; Thu, 07 Oct 2021 09:18:55 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id o6sm130018wri.49.2021.10.07.09.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 09:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633623536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eCfS+Asf+f1waC4AVoz1E9eLdrSZudUp689oYCk0mwY=; b=J3ad5I2VsxAU1XRJ8Sf7uHgBZI9+swNsZ3nFaTVhB41DK3aFtzT+vFJq8OuwXsB15qIA8g OkoQhkdzAv3fvc735/3hO0h/J80cCkHlNICNDdrNKOzuyL1JwgwVOZ0JsJjy2tOMB0LKbx JcYbkajbiJrqUdGWoFiFNq5gA3iogo8= X-MC-Unique: ES_6Tqc6PaW_fmrrEfuUBg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eCfS+Asf+f1waC4AVoz1E9eLdrSZudUp689oYCk0mwY=; b=D+/XMtZn+B1DDllt3X5xBbLJa+GX5zPYmVDscEmIGH6F0DuXpiKx5hZ1w/ZKs09gcr Z+9asumWRSCj1/uVH+xT952OqizxyR3Q5TJptweXX8koCHfS4//QPAogBqBx3QQd2yXR ci4wUkcTwrCnHLpKNc7sD/oSNYuN2izGWSnBO9+QcGHkKy3KevEZ36HnaGIJWpift6Yw JHPh3Z9954Uagc7edAgw5PYjfAbOSlGUONMXuar5CBbeCjy0FM00OZNWEEkI2wKzKAlu qF+D++9pmHrIjkM96H+drK/l9bThaSwiaB2lXPrejJL/XxqhdXQes/fCZlW2ZFJfFIAw kJUg== X-Gm-Message-State: AOAM5321ZbCLzRQkMS+nxwgmRSplqlmImnrV79paRtrhAW4Glk7Vbfyw UXGTkmWPD4TkOkCXBcF6W4Ts0yJaUfiNCui01woOggA9SL/4XZEy4zdhzhdvRNX/vp5I0XqP0k1 69kCdEHOVhuyQXw== X-Received: by 2002:a7b:c351:: with SMTP id l17mr5734550wmj.120.1633623534006; Thu, 07 Oct 2021 09:18:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMiBCCsPqIpoUFMotzmt5Xfmuwzj1LGT3FXGJkJ2kFOsOJzE9yp1pWqRATIf7s0cH57Uvvhg== X-Received: by 2002:a7b:c351:: with SMTP id l17mr5734533wmj.120.1633623533832; Thu, 07 Oct 2021 09:18:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , kvm@vger.kernel.org, "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , James Bottomley , Brijesh Singh , Sergio Lopez , Dov Murik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 21/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c Date: Thu, 7 Oct 2021 18:17:14 +0200 Message-Id: <20211007161716.453984-22-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211007161716.453984-1-philmd@redhat.com> References: <20211007161716.453984-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633623539428100001 Move qmp_query_sev() & hmp_info_sev()() from monitor.c to sev.c and make sev_get_info() static. We don't need the stub anymore, remove it. Add a stub for hmp_info_sev(). Reviewed-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/sev.h | 2 -- target/i386/monitor.c | 35 -------------------------------- target/i386/sev-sysemu-stub.c | 10 ++++++++- target/i386/sev.c | 38 +++++++++++++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/target/i386/sev.h b/target/i386/sev.h index dda350779f9..3fba1884a0d 100644 --- a/target/i386/sev.h +++ b/target/i386/sev.h @@ -19,7 +19,6 @@ #endif =20 #include "exec/confidential-guest-support.h" -#include "qapi/qapi-types-misc-target.h" =20 #define SEV_POLICY_NODBG 0x1 #define SEV_POLICY_NOKS 0x2 @@ -47,7 +46,6 @@ bool sev_es_enabled(void); #define sev_es_enabled() 0 #endif =20 -extern SevInfo *sev_get_info(void); extern uint32_t sev_get_cbit_position(void); extern uint32_t sev_get_reduced_phys_bits(void); extern bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Erro= r **errp); diff --git a/target/i386/monitor.c b/target/i386/monitor.c index bd24d0d4737..680d282591c 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -31,7 +31,6 @@ #include "qapi/qmp/qerror.h" #include "sysemu/kvm.h" #include "qapi/error.h" -#include "sev.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" #include "hw/i386/pc.h" @@ -676,40 +675,6 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict) "removed soon. Please use 'info pic' instead.\n"); } =20 -SevInfo *qmp_query_sev(Error **errp) -{ - SevInfo *info; - - info =3D sev_get_info(); - if (!info) { - error_setg(errp, "SEV feature is not available"); - return NULL; - } - - return info; -} - -void hmp_info_sev(Monitor *mon, const QDict *qdict) -{ - SevInfo *info =3D 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"); - } - - qapi_free_SevInfo(info); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 8d97d7c7e14..68518fd3f9d 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -12,13 +12,16 @@ */ =20 #include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "monitor/hmp.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "sev.h" =20 -SevInfo *sev_get_info(void) +SevInfo *qmp_query_sev(Error **errp) { + error_setg(errp, "SEV is not available in this QEMU"); return NULL; } =20 @@ -60,3 +63,8 @@ SevAttestationReport *qmp_query_sev_attestation_report(co= nst char *mnonce, error_setg(errp, "SEV is not available in this QEMU"); return NULL; } + +void hmp_info_sev(Monitor *mon, const QDict *qdict) +{ + monitor_printf(mon, "SEV is not available in this QEMU\n"); +} diff --git a/target/i386/sev.c b/target/i386/sev.c index ec874b3df82..19504796fb7 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -32,6 +32,7 @@ #include "migration/blocker.h" #include "qom/object.h" #include "monitor/monitor.h" +#include "monitor/hmp.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "exec/confidential-guest-support.h" @@ -402,8 +403,7 @@ sev_get_reduced_phys_bits(void) return sev_guest ? sev_guest->reduced_phys_bits : 0; } =20 -SevInfo * -sev_get_info(void) +static SevInfo *sev_get_info(void) { SevInfo *info; =20 @@ -422,6 +422,40 @@ sev_get_info(void) return info; } =20 +SevInfo *qmp_query_sev(Error **errp) +{ + SevInfo *info; + + info =3D sev_get_info(); + if (!info) { + error_setg(errp, "SEV feature is not available"); + return NULL; + } + + return info; +} + +void hmp_info_sev(Monitor *mon, const QDict *qdict) +{ + SevInfo *info =3D 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"); + } + + qapi_free_SevInfo(info); +} + static int sev_get_pdh_info(int fd, guchar **pdh, size_t *pdh_len, guchar **cert_chai= n, size_t *cert_chain_len, Error **errp) --=20 2.31.1