Skip to content

Commit 6e81733

Browse files
philmdbonzini
authored andcommitted
hw/i386/sgx: Move qmp_query_sgx() and hmp_info_sgx() to hw/i386/sgx.c
Move qmp_query_sgx() and hmp_info_sgx() from target/i386/monitor.c to hw/i386/sgx.c, removing the sgx_get_info() indirection and the "hw/i386/sgx.h" header. Suggested-by: Paolo Bonzini <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0216585 commit 6e81733

File tree

4 files changed

+32
-42
lines changed

4 files changed

+32
-42
lines changed

hw/i386/sgx-stub.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#include "qemu/osdep.h"
2+
#include "monitor/monitor.h"
3+
#include "monitor/hmp-target.h"
24
#include "hw/i386/pc.h"
35
#include "hw/i386/sgx-epc.h"
4-
#include "hw/i386/sgx.h"
56
#include "qapi/error.h"
67
#include "qapi/qapi-commands-misc-target.h"
78

8-
SGXInfo *sgx_get_info(Error **errp)
9+
SGXInfo *qmp_query_sgx(Error **errp)
910
{
1011
error_setg(errp, "SGX support is not compiled in");
1112
return NULL;
@@ -17,6 +18,11 @@ SGXInfo *qmp_query_sgx_capabilities(Error **errp)
1718
return NULL;
1819
}
1920

21+
void hmp_info_sgx(Monitor *mon, const QDict *qdict)
22+
{
23+
monitor_printf(mon, "SGX is not available in this QEMU\n");
24+
}
25+
2026
void pc_machine_init_sgx_epc(PCMachineState *pcms)
2127
{
2228
memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState));

hw/i386/sgx.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
#include "hw/i386/sgx-epc.h"
1616
#include "hw/mem/memory-device.h"
1717
#include "monitor/qdev.h"
18+
#include "monitor/monitor.h"
19+
#include "monitor/hmp-target.h"
1820
#include "qapi/error.h"
1921
#include "qapi/qapi-commands-misc-target.h"
2022
#include "exec/address-spaces.h"
21-
#include "hw/i386/sgx.h"
2223
#include "sysemu/hw_accel.h"
2324

2425
#define SGX_MAX_EPC_SECTIONS 8
@@ -86,7 +87,7 @@ SGXInfo *qmp_query_sgx_capabilities(Error **errp)
8687
return info;
8788
}
8889

89-
SGXInfo *sgx_get_info(Error **errp)
90+
SGXInfo *qmp_query_sgx(Error **errp)
9091
{
9192
SGXInfo *info = NULL;
9293
X86MachineState *x86ms;
@@ -116,6 +117,27 @@ SGXInfo *sgx_get_info(Error **errp)
116117
return info;
117118
}
118119

120+
void hmp_info_sgx(Monitor *mon, const QDict *qdict)
121+
{
122+
Error *err = NULL;
123+
g_autoptr(SGXInfo) info = qmp_query_sgx(&err);
124+
125+
if (err) {
126+
error_report_err(err);
127+
return;
128+
}
129+
monitor_printf(mon, "SGX support: %s\n",
130+
info->sgx ? "enabled" : "disabled");
131+
monitor_printf(mon, "SGX1 support: %s\n",
132+
info->sgx1 ? "enabled" : "disabled");
133+
monitor_printf(mon, "SGX2 support: %s\n",
134+
info->sgx2 ? "enabled" : "disabled");
135+
monitor_printf(mon, "FLC support: %s\n",
136+
info->flc ? "enabled" : "disabled");
137+
monitor_printf(mon, "size: %" PRIu64 "\n",
138+
info->section_size);
139+
}
140+
119141
bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
120142
{
121143
PCMachineState *pcms = PC_MACHINE(qdev_get_machine());

include/hw/i386/sgx.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

target/i386/monitor.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "qapi/qapi-commands-misc-target.h"
3535
#include "qapi/qapi-commands-misc.h"
3636
#include "hw/i386/pc.h"
37-
#include "hw/i386/sgx.h"
3837

3938
/* Perform linear address sign extension */
4039
static hwaddr addr_canonical(CPUArchState *env, hwaddr addr)
@@ -674,29 +673,3 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict)
674673
monitor_printf(mon, "This command is obsolete and will be "
675674
"removed soon. Please use 'info pic' instead.\n");
676675
}
677-
678-
SGXInfo *qmp_query_sgx(Error **errp)
679-
{
680-
return sgx_get_info(errp);
681-
}
682-
683-
void hmp_info_sgx(Monitor *mon, const QDict *qdict)
684-
{
685-
Error *err = NULL;
686-
g_autoptr(SGXInfo) info = qmp_query_sgx(&err);
687-
688-
if (err) {
689-
error_report_err(err);
690-
return;
691-
}
692-
monitor_printf(mon, "SGX support: %s\n",
693-
info->sgx ? "enabled" : "disabled");
694-
monitor_printf(mon, "SGX1 support: %s\n",
695-
info->sgx1 ? "enabled" : "disabled");
696-
monitor_printf(mon, "SGX2 support: %s\n",
697-
info->sgx2 ? "enabled" : "disabled");
698-
monitor_printf(mon, "FLC support: %s\n",
699-
info->flc ? "enabled" : "disabled");
700-
monitor_printf(mon, "size: %" PRIu64 "\n",
701-
info->section_size);
702-
}

0 commit comments

Comments
 (0)