[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 15/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c |
Date: |
Wed, 16 Jun 2021 22:43:20 +0200 |
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().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Note: what is left in sev_i386.h eventually belong to "sysemu/sev.h"
meaning we could remove this local header.
---
target/i386/sev_i386.h | 2 --
target/i386/monitor.c | 37 ---------------------------------
target/i386/sev-sysemu-stub.c | 10 ++++++++-
target/i386/sev.c | 39 +++++++++++++++++++++++++++++++++--
4 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h
index 615cebea1a8..1ddb8df9c99 100644
--- a/target/i386/sev_i386.h
+++ b/target/i386/sev_i386.h
@@ -15,7 +15,6 @@
#define QEMU_SEV_I386_H
#include "sysemu/sev.h"
-#include "qapi/qapi-types-misc-target.h"
#define SEV_POLICY_NODBG 0x1
#define SEV_POLICY_NOKS 0x2
@@ -25,7 +24,6 @@
#define SEV_POLICY_SEV 0x20
extern bool sev_es_enabled(void);
-extern SevInfo *sev_get_info(void);
extern uint32_t sev_get_cbit_position(void);
extern uint32_t sev_get_reduced_phys_bits(void);
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index d2289d1fb47..af3501095e5 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -28,11 +28,8 @@
#include "monitor/hmp-target.h"
#include "monitor/hmp.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qerror.h"
#include "sysemu/kvm.h"
-#include "sysemu/sev.h"
#include "qapi/error.h"
-#include "sev_i386.h"
#include "qapi/qapi-commands-misc-target.h"
#include "qapi/qapi-commands-misc.h"
#include "hw/i386/pc.h"
@@ -675,37 +672,3 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "This command is obsolete and will be "
"removed soon. Please use 'info pic' instead.\n");
}
-
-SevInfo *qmp_query_sev(Error **errp)
-{
- SevInfo *info;
-
- info = 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 = 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);
-}
diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c
index f5e7536f987..7a35f0432b2 100644
--- a/target/i386/sev-sysemu-stub.c
+++ b/target/i386/sev-sysemu-stub.c
@@ -12,13 +12,16 @@
*/
#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_i386.h"
-SevInfo *sev_get_info(void)
+SevInfo *qmp_query_sev(Error **errp)
{
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
@@ -59,3 +62,8 @@ SevAttestationReport *qmp_query_sev_attestation_report(const
char *mnonce, Error
error_setg(errp, QERR_UNSUPPORTED);
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 4ddd24f6bdd..faa3a4015c4 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -27,10 +27,12 @@
#include "sev_i386.h"
#include "sysemu/sysemu.h"
#include "sysemu/runstate.h"
+#include "sysemu/sev.h"
#include "trace.h"
#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"
@@ -375,8 +377,7 @@ sev_get_reduced_phys_bits(void)
return sev_guest ? sev_guest->reduced_phys_bits : 0;
}
-SevInfo *
-sev_get_info(void)
+static SevInfo *sev_get_info(void)
{
SevInfo *info;
@@ -395,6 +396,40 @@ sev_get_info(void)
return info;
}
+SevInfo *qmp_query_sev(Error **errp)
+{
+ SevInfo *info;
+
+ info = 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 = 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_chain,
size_t *cert_chain_len, Error **errp)
--
2.31.1
- [PATCH v2 04/23] target/i386/monitor: Return QMP error when SEV is disabled in build, (continued)
- [PATCH v2 04/23] target/i386/monitor: Return QMP error when SEV is disabled in build, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 06/23] target/i386/sev_i386.h: Remove unused headers, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 07/23] target/i386/sev: Remove sev_get_me_mask(), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 08/23] target/i386/sev: Mark unreachable code with g_assert_not_reached(), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 09/23] target/i386/sev: sev_get_attestation_report use g_autofree, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 10/23] target/i386/sev: Restrict SEV to system emulation, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 11/23] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 12/23] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 13/23] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 14/23] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 15/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c,
Philippe Mathieu-Daudé <=
- [PATCH v2 16/23] monitor: Restrict 'info sev' to x86 targets, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 17/23] hw/i386/acpi-common: Remove unused includes, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 18/23] hw/i386: Rename acpi-build.c -> acpi-pc.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 20/23] hw/acpi: Do not restrict ACPI core routines to x86 architecture, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 21/23] hw/i386: Introduce X86_FW_OVMF Kconfig symbol, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 22/23] hw/acpi/Kconfig: Add missing Kconfig dependencies (build error), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 19/23] hw/i386: Move pc_madt_cpu_entry() to acpi-pc.c, Philippe Mathieu-Daudé, 2021/06/16