[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/40] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to s
From: |
Paolo Bonzini |
Subject: |
[PULL 26/40] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c |
Date: |
Wed, 13 Oct 2021 11:07:14 +0200 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
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 <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211007161716.453984-22-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/monitor.c | 35 --------------------------------
target/i386/sev-sysemu-stub.c | 10 ++++++++-
target/i386/sev.c | 38 +++++++++++++++++++++++++++++++++--
target/i386/sev.h | 2 --
4 files changed, 45 insertions(+), 40 deletions(-)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index bd24d0d473..680d282591 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");
}
-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);
-}
-
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 8d97d7c7e1..68518fd3f9 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.h"
-SevInfo *sev_get_info(void)
+SevInfo *qmp_query_sev(Error **errp)
{
+ error_setg(errp, "SEV is not available in this QEMU");
return NULL;
}
@@ -60,3 +63,8 @@ SevAttestationReport *qmp_query_sev_attestation_report(const
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 ec874b3df8..19504796fb 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;
}
-SevInfo *
-sev_get_info(void)
+static SevInfo *sev_get_info(void)
{
SevInfo *info;
@@ -422,6 +422,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)
diff --git a/target/i386/sev.h b/target/i386/sev.h
index 9ee1429395..83e82aa42c 100644
--- a/target/i386/sev.h
+++ b/target/i386/sev.h
@@ -19,7 +19,6 @@
#endif
#include "exec/confidential-guest-support.h"
-#include "qapi/qapi-types-misc-target.h"
#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
-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, Error
**errp);
--
2.31.1
- [PULL 10/40] target/i386/sev: Prefix QMP errors with 'SEV', (continued)
- [PULL 10/40] target/i386/sev: Prefix QMP errors with 'SEV', Paolo Bonzini, 2021/10/13
- [PULL 17/40] target/i386/sev: Use g_autofree in sev_launch_get_measure(), Paolo Bonzini, 2021/10/13
- [PULL 22/40] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 06/40] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines, Paolo Bonzini, 2021/10/13
- [PULL 11/40] target/i386/monitor: Return QMP error when SEV is not enabled for guest, Paolo Bonzini, 2021/10/13
- [PULL 14/40] target/i386/sev: Remove sev_get_me_mask(), Paolo Bonzini, 2021/10/13
- [PULL 19/40] target/i386/sev: Rename sev_i386.h -> sev.h, Paolo Bonzini, 2021/10/13
- [PULL 25/40] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 15/40] target/i386/sev: Mark unreachable code with g_assert_not_reached(), Paolo Bonzini, 2021/10/13
- [PULL 21/40] target/i386/sev: Remove stubs by using code elision, Paolo Bonzini, 2021/10/13
- [PULL 26/40] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c,
Paolo Bonzini <=
- [PULL 28/40] MAINTAINERS: Cover SEV-related files with X86/KVM section, Paolo Bonzini, 2021/10/13
- [PULL 29/40] qapi: Make some ObjectTypes depend on the build settings, Paolo Bonzini, 2021/10/13
- [PULL 30/40] tests: tcg: Fix PVH test with binutils 2.36+, Paolo Bonzini, 2021/10/13
- [PULL 12/40] target/i386/cpu: Add missing 'qapi/error.h' header, Paolo Bonzini, 2021/10/13
- [PULL 13/40] target/i386/sev_i386.h: Remove unused headers, Paolo Bonzini, 2021/10/13
- [PULL 18/40] target/i386/sev: Restrict SEV to system emulation, Paolo Bonzini, 2021/10/13
- [PULL 16/40] target/i386/sev: sev_get_attestation_report use g_autofree, Paolo Bonzini, 2021/10/13
- [PULL 24/40] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 27/40] monitor: Reduce hmp_info_sev() declaration, Paolo Bonzini, 2021/10/13
- [PULL 23/40] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c, Paolo Bonzini, 2021/10/13