target/i386: Replace target_monitor_defs -> SysemuCPUOps::monitor_defs
Restrict x86_monitor_defs[] to cpu.c, register it as SysemuCPUOps::monitor_defs hook, allowing to remove the target_monitor_defs() method. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260427080738.77138-28-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Mar 20, 2026 at 14:13 UTC
b17febf45c7e4fea423efaf75f680fd70c1cd9be
2 files changed
+29
-30
target/i386/cpu.c
+29
@@ -41,6 +41,7 @@
41
#include "exec/watchpoint.h"
42
#ifndef CONFIG_USER_ONLY
43
#include "confidential-guest.h"
44
+#include "monitor/hmp.h"
45
#include "system/reset.h"
46
#include "qapi/qapi-commands-machine.h"
47
#include "system/address-spaces.h"
@@ -10843,6 +10844,33 @@ static const Property x86_cpu_properties[] = {
10844
};
10845
10846
#ifndef CONFIG_USER_ONLY
10847
+
10848
+static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
10849
+ int offset)
10850
+{
10851
+ CPUArchState *env = mon_get_cpu_env(mon);
10852
+ int64_t ret = env->eip + env->segs[R_CS].base;
10853
+
10854
+ if (!(env->hflags & HF_CS64_MASK)) {
10855
+ ret = (int32_t)ret;
10856
+ }
10857
+ return ret;
10858
+}
10859
+
10860
+static const MonitorDef x86_monitor_defs[] = {
10861
+#define SEG(name, seg) \
10862
+ { name ".limit", offsetof(CPUX86State, segs[seg].limit) },
10863
+ SEG("cs", R_CS)
10864
+ SEG("ds", R_DS)
10865
+ SEG("es", R_ES)
10866
+ SEG("ss", R_SS)
10867
+ SEG("fs", R_FS)
10868
+ SEG("gs", R_GS)
10869
+ { "pc", 0, monitor_get_pc, },
10870
+ { NULL },
10871
+#undef SEG
10872
+};
10873
+
10874
#include "hw/core/sysemu-cpu-ops.h"
10875
10876
static const struct SysemuCPUOps i386_sysemu_ops = {
@@ -10856,6 +10884,7 @@ static const struct SysemuCPUOps i386_sysemu_ops = {
10884
.write_elf64_note = x86_cpu_write_elf64_note,
10885
.write_elf32_qemunote = x86_cpu_write_elf32_qemunote,
10886
.write_elf64_qemunote = x86_cpu_write_elf64_qemunote,
10887
+ .monitor_defs = x86_monitor_defs,
10888
.legacy_vmsd = &vmstate_x86_cpu,
10889
};
10890
#endif
target/i386/monitor.c
-30
@@ -591,33 +591,3 @@ void hmp_mce(Monitor *mon, const QDict *qdict)
591
flags);
592
}
593
}
594
-
595
-static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md,
596
- int offset)
597
-{
598
- CPUArchState *env = mon_get_cpu_env(mon);
599
- int64_t ret = env->eip + env->segs[R_CS].base;
600
-
601
- if (!(env->hflags & HF_CS64_MASK)) {
602
- ret = (int32_t)ret;
603
- }
604
- return ret;
605
-}
606
-
607
-const MonitorDef monitor_defs[] = {
608
-#define SEG(name, seg) \
609
- { name ".limit", offsetof(CPUX86State, segs[seg].limit) },
610
- SEG("cs", R_CS)
611
- SEG("ds", R_DS)
612
- SEG("es", R_ES)
613
- SEG("ss", R_SS)
614
- SEG("fs", R_FS)
615
- SEG("gs", R_GS)
616
- { "pc", 0, monitor_get_pc, },
617
- { NULL },
618
-};
619
-
620
-const MonitorDef *target_monitor_defs(void)
621
-{
622
- return monitor_defs;
623
-}