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é <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> --- target/i386/cpu.c | 29 +++++++++++++++++++++++++++++ target/i386/monitor.c | 30 ------------------------------ 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index efe7ba014d3..97c66c22262 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -41,6 +41,7 @@ #include "exec/watchpoint.h" #ifndef CONFIG_USER_ONLY #include "confidential-guest.h" +#include "monitor/hmp.h" #include "system/reset.h" #include "qapi/qapi-commands-machine.h" #include "system/address-spaces.h" @@ -10843,6 +10844,33 @@ static const Property x86_cpu_properties[] = { }; #ifndef CONFIG_USER_ONLY + +static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md, + int offset) +{ + CPUArchState *env = mon_get_cpu_env(mon); + int64_t ret = env->eip + env->segs[R_CS].base; + + if (!(env->hflags & HF_CS64_MASK)) { + ret = (int32_t)ret; + } + return ret; +} + +static const MonitorDef x86_monitor_defs[] = { +#define SEG(name, seg) \ + { name ".limit", offsetof(CPUX86State, segs[seg].limit) }, + SEG("cs", R_CS) + SEG("ds", R_DS) + SEG("es", R_ES) + SEG("ss", R_SS) + SEG("fs", R_FS) + SEG("gs", R_GS) + { "pc", 0, monitor_get_pc, }, + { NULL }, +#undef SEG +}; + #include "hw/core/sysemu-cpu-ops.h" static const struct SysemuCPUOps i386_sysemu_ops = { @@ -10856,6 +10884,7 @@ static const struct SysemuCPUOps i386_sysemu_ops = { .write_elf64_note = x86_cpu_write_elf64_note, .write_elf32_qemunote = x86_cpu_write_elf32_qemunote, .write_elf64_qemunote = x86_cpu_write_elf64_qemunote, + .monitor_defs = x86_monitor_defs, .legacy_vmsd = &vmstate_x86_cpu, }; #endif diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 1befb8ea824..a536712c755 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -591,33 +591,3 @@ void hmp_mce(Monitor *mon, const QDict *qdict) flags); } } - -static int64_t monitor_get_pc(Monitor *mon, const struct MonitorDef *md, - int offset) -{ - CPUArchState *env = mon_get_cpu_env(mon); - int64_t ret = env->eip + env->segs[R_CS].base; - - if (!(env->hflags & HF_CS64_MASK)) { - ret = (int32_t)ret; - } - return ret; -} - -const MonitorDef monitor_defs[] = { -#define SEG(name, seg) \ - { name ".limit", offsetof(CPUX86State, segs[seg].limit) }, - SEG("cs", R_CS) - SEG("ds", R_DS) - SEG("es", R_ES) - SEG("ss", R_SS) - SEG("fs", R_FS) - SEG("gs", R_GS) - { "pc", 0, monitor_get_pc, }, - { NULL }, -}; - -const MonitorDef *target_monitor_defs(void) -{ - return monitor_defs; -} -- 2.53.0
