monitor: Do not check TARGET_I386 to build 'info sgx' command
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> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260427080738.77138-16-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Apr 10, 2026 at 19:37 UTC
c9e3f1641050eefb9e50b86571d6086f310b3a5e
5 files changed
+19
-7
MAINTAINERS
+1
@@ -514,6 +514,7 @@ L: kvm@vger.kernel.org
514
S: Supported
515
F: docs/system/i386/amd-memory-encryption.rst
516
F: docs/system/i386/sgx.rst
517
+F: hw/i386/sgx*
518
F: stubs/qmp-i386-sev.c
519
F: stubs/qmp-i386-sgx.c
520
F: target/i386/kvm/
hmp-commands-info.hx
+1
-2
@@ -859,15 +859,14 @@ SRST
859
Display the vcpu dirty page limit information.
860
ERST
861
862
-#if defined(TARGET_I386)
862
{
863
.name = "sgx",
864
.args_type = "",
865
.params = "",
866
.help = "show intel SGX information",
867
.cmd = hmp_info_sgx,
868
+ .arch_bitmask = QEMU_ARCH_I386,
869
},
870
-#endif
870
871
SRST
872
``info sgx``
hw/i386/meson.build
+1
@@ -24,6 +24,7 @@ i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
24
i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
25
i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
26
if_false: files('sgx-stub.c'))
27
+stub_ss.add(files('sgx-hmp-stub.c'))
28
29
i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
30
i386_ss.add(when: 'CONFIG_PC', if_true: files(
hw/i386/sgx-hmp-stub.c
new
+16
@@ -0,0 +1,16 @@
1
+/*
2
+ * Human Monitor 'info sgx' stub (CONFIG_SGX)
3
+ *
4
+ * Copyright (c) Linaro
5
+ *
6
+ * SPDX-License-Identifier: GPL-2.0-or-later
7
+ */
8
+
9
+#include "qemu/osdep.h"
10
+#include "monitor/hmp.h"
11
+#include "monitor/monitor.h"
12
+
13
+void hmp_info_sgx(Monitor *mon, const QDict *qdict)
14
+{
15
+ monitor_printf(mon, "SGX is not available in this QEMU\n");
16
+}
hw/i386/sgx-stub.c
-5
@@ -23,11 +23,6 @@ SgxInfo *qmp_query_sgx_capabilities(Error **errp)
23
return NULL;
24
}
25
26
-void hmp_info_sgx(Monitor *mon, const QDict *qdict)
27
-{
28
- monitor_printf(mon, "SGX is not available in this QEMU\n");
29
-}
30
-
26
void pc_machine_init_sgx_epc(PCMachineState *pcms)
27
{
28
memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState));