This command is filtered at build-time for i386/x86_64 binaries.
By using the recently introduced HMPCommand::arch_bitmask flag
we can filter it at runtime, making it possible to compile
hmp-commands-info.hx once.
Since the method depends on the CONFIG_SGX definition, define it
in its own stub file.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 1 +
hw/i386/sgx-hmp-stub.c | 16 ++++++++++++++++
hw/i386/sgx-stub.c | 5 -----
hmp-commands-info.hx | 3 +--
hw/i386/meson.build | 1 +
5 files changed, 19 insertions(+), 7 deletions(-)
create mode 100644 hw/i386/sgx-hmp-stub.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 458951bc051..31e973fdeb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ L: kvm@vger.kernel.org
S: Supported
F: docs/system/i386/amd-memory-encryption.rst
F: docs/system/i386/sgx.rst
+F: hw/i386/sgx*
F: stubs/qmp-i386-sev.c
F: stubs/qmp-i386-sgx.c
F: target/i386/kvm/
diff --git a/hw/i386/sgx-hmp-stub.c b/hw/i386/sgx-hmp-stub.c
new file mode 100644
index 00000000000..cf1d9a6344b
--- /dev/null
+++ b/hw/i386/sgx-hmp-stub.c
@@ -0,0 +1,16 @@
+/*
+ * Human Monitor 'info sgx' stub (CONFIG_SGX)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
+
+void hmp_info_sgx(Monitor *mon, const QDict *qdict)
+{
+ monitor_printf(mon, "SGX is not available in this QEMU\n");
+}
diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c
index 6e82773a86d..59d58926311 100644
--- a/hw/i386/sgx-stub.c
+++ b/hw/i386/sgx-stub.c
@@ -22,11 +22,6 @@ SgxInfo *qmp_query_sgx_capabilities(Error **errp)
return NULL;
}
-void hmp_info_sgx(Monitor *mon, const QDict *qdict)
-{
- monitor_printf(mon, "SGX is not available in this QEMU\n");
-}
-
void pc_machine_init_sgx_epc(PCMachineState *pcms)
{
memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState));
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index b575e4ac993..da9fdc0ab7b 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -866,15 +866,14 @@ SRST
Display the vcpu dirty page limit information.
ERST
-#if defined(TARGET_I386)
{
.name = "sgx",
.args_type = "",
.params = "",
.help = "show intel SGX information",
.cmd = hmp_info_sgx,
+ .arch_bitmask = QEMU_ARCH_I386,
},
-#endif
SRST
``info sgx``
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 63ae57baa51..b611fbb5a7f 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -24,6 +24,7 @@ i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
if_false: files('sgx-stub.c'))
+stub_ss.add(files('sgx-hmp-stub.c'))
i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
i386_ss.add(when: 'CONFIG_PC', if_true: files(
--
2.53.0