monitor/hmp: Reduce target-specific definitions
cover monitor/hmp: Reduce target-specific definitions
Move most of target-agnostic definitions from
"monitor/hmp-target.h" to "monitor/hmp.h" to
reduce files target-poisoning.
Philippe Mathieu-Daudé (2):
target/i386: Include missing 'svm.h' header in 'sev.h' monitor/hmp: Reduce target-specific definitions
include/monitor/hmp-target.h | 28 +++++----------------------- include/monitor/hmp.h | 23 +++++++++++++++++++++++ target/i386/sev.h | 2 ++ hw/i386/sgx-stub.c | 2 +- hw/i386/sgx.c | 1 - monitor/hmp-cmds.c | 1 - stubs/target-monitor-defs.c | 2 +- target/i386/cpu-apic.c | 2 +- target/i386/sev-system-stub.c | 2 +- target/i386/sev.c | 1 - target/m68k/monitor.c | 1 + target/riscv/monitor.c | 1 + target/sh4/monitor.c | 1 - target/xtensa/monitor.c | 1 - 14 files changed, 36 insertions(+), 32 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/2 target/i386: Include missing 'svm.h' header in 'sev.h'
"target/i386/sev.h" uses the vmcb_seg structure type, which is defined in "target/i386/svm.h". Include the latter, otherwise the following patch triggers:
../target/i386/sev.h:62:21: error: field has incomplete type 'struct vmcb_seg'
62 | struct vmcb_seg es;
| ^--- target/i386/sev.h | 2 ++ 1 file changed, 2 insertions(+)
target/i386/sev.h +2 -0
@@ -14,6 +14,8 @@#ifndef I386_SEV_H #define I386_SEV_H +#include "target/i386/svm.h" +#ifndef CONFIG_USER_ONLY #include CONFIG_DEVICES /* CONFIG_SEV */ #endif
Signature · 1 line
2.52.0
PATCH 2/2 monitor/hmp: Reduce target-specific definitions
In reply to Philippe Mathieu-DaudéFrom "monitor/hmp-target.h", only the MonitorDef structure is target specific (by using the 'target_long' type). All the rest (even target_monitor_defs and target_get_monitor_def) can be exposed to target-agnostic units, allowing to build some of them in meson common source set.
--- include/monitor/hmp-target.h | 28 +++++----------------------- include/monitor/hmp.h | 23 +++++++++++++++++++++++ hw/i386/sgx-stub.c | 2 +- hw/i386/sgx.c | 1 - monitor/hmp-cmds.c | 1 - stubs/target-monitor-defs.c | 2 +- target/i386/cpu-apic.c | 2 +- target/i386/sev-system-stub.c | 2 +- target/i386/sev.c | 1 - target/m68k/monitor.c | 1 + target/riscv/monitor.c | 1 + target/sh4/monitor.c | 1 - target/xtensa/monitor.c | 1 - 13 files changed, 34 insertions(+), 32 deletions(-)
include/monitor/hmp-target.h +5 -23
@@ -25,9 +25,12 @@ #ifndef MONITOR_HMP_TARGET_H #define MONITOR_HMP_TARGET_H -typedef struct MonitorDef MonitorDef; +#include "monitor/hmp.h" + +#ifndef COMPILING_PER_TARGET +#error hmp-target.h included from common code +#endif -#ifdef COMPILING_PER_TARGET #include "cpu.h" struct MonitorDef { const char *name;
@@ -36,29 +39,8 @@ struct MonitorDef { int val); int type; }; -#endif #define MD_TLONG 0#define MD_I32 1 -const MonitorDef *target_monitor_defs (void ); -int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval); - -CPUArchState *mon_get_cpu_env (Monitor *mon); -CPUState *mon_get_cpu (Monitor *mon); - -void hmp_info_mem (Monitor *mon,const QDict *qdict); -void hmp_info_tlb (Monitor *mon,const QDict *qdict); -void hmp_mce (Monitor *mon,const QDict *qdict); -void hmp_info_local_apic (Monitor *mon,const QDict *qdict); -void hmp_info_sev (Monitor *mon,const QDict *qdict); -void hmp_info_sgx (Monitor *mon,const QDict *qdict); -void hmp_info_via (Monitor *mon,const QDict *qdict); -void hmp_memory_dump (Monitor *mon,const QDict *qdict); -void hmp_physical_memory_dump (Monitor *mon,const QDict *qdict); -void hmp_info_registers (Monitor *mon,const QDict *qdict); -void hmp_gva2gpa (Monitor *mon,const QDict *qdict); -void hmp_gpa2hva (Monitor *mon,const QDict *qdict); -void hmp_gpa2hpa (Monitor *mon,const QDict *qdict); -#endif /* MONITOR_HMP_TARGET_H */
include/monitor/hmp.h +23 -0
@@ -17,6 +17,29 @@#include "qemu/readline.h" #include "qapi/qapi-types-common.h" +typedef struct MonitorDef MonitorDef ; + +const MonitorDef *target_monitor_defs (void ); + +int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval); + +CPUArchState *mon_get_cpu_env (Monitor *mon); +CPUState *mon_get_cpu (Monitor *mon); + +void hmp_info_mem (Monitor *mon,const QDict *qdict); +void hmp_info_tlb (Monitor *mon,const QDict *qdict); +void hmp_mce (Monitor *mon,const QDict *qdict); +void hmp_info_local_apic (Monitor *mon,const QDict *qdict); +void hmp_info_sev (Monitor *mon,const QDict *qdict); +void hmp_info_sgx (Monitor *mon,const QDict *qdict); +void hmp_info_via (Monitor *mon,const QDict *qdict); +void hmp_memory_dump (Monitor *mon,const QDict *qdict); +void hmp_physical_memory_dump (Monitor *mon,const QDict *qdict); +void hmp_info_registers (Monitor *mon,const QDict *qdict); +void hmp_gva2gpa (Monitor *mon,const QDict *qdict); +void hmp_gpa2hva (Monitor *mon,const QDict *qdict); +void hmp_gpa2hpa (Monitor *mon,const QDict *qdict); +bool hmp_handle_error (Monitor *mon,Error *err);void hmp_help_cmd (Monitor *mon,const char *name);strList *hmp_split_at_comma (const char *str);
hw/i386/sgx-stub.c +1 -1
@@ -1,6 +1,6 @@#include "qemu/osdep.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" +#include "monitor/hmp.h" #include "hw/i386/pc.h" #include "hw/i386/sgx-epc.h" #include "qapi/qapi-commands-misc-i386.h"
hw/i386/sgx.c +0 -1
@@ -16,7 +16,6 @@#include "hw/mem/memory-device.h" #include "monitor/qdev.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qapi/qapi-commands-misc-i386.h"
monitor/hmp-cmds.c +0 -1
@@ -21,7 +21,6 @@#include "gdbstub/enums.h" #include "monitor/hmp.h" #include "qemu/help_option.h" -#include "monitor/hmp-target.h" #include "monitor/monitor-internal.h" #include "qapi/error.h" #include "qapi/qapi-commands-control.h"
stubs/target-monitor-defs.c +1 -1
@@ -1,5 +1,5 @@#include "qemu/osdep.h" -#include "monitor/hmp-target.h" +#include "monitor/hmp.h" const MonitorDef *target_monitor_defs (void ) {
target/i386/cpu-apic.c +1 -1
@@ -10,7 +10,7 @@#include "qobject/qdict.h" #include "qapi/error.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" +#include "monitor/hmp.h" #include "system/hw_accel.h" #include "system/kvm.h" #include "system/xen.h"
target/i386/sev-system-stub.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" +#include "monitor/hmp.h" #include "qapi/error.h" #include "sev.h"
target/i386/sev.c +0 -1
@@ -36,7 +36,6 @@#include "migration/blocker.h" #include "qom/object.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" #include "qapi/qapi-commands-misc-i386.h" #include "confidential-guest.h" #include "hw/i386/pc.h"
target/m68k/monitor.c +1 -0
@@ -7,6 +7,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "monitor/hmp.h" #include "monitor/hmp-target.h" #include "monitor/monitor.h"
target/riscv/monitor.c +1 -0
@@ -22,6 +22,7 @@#include "cpu.h" #include "cpu_bits.h" #include "monitor/monitor.h" +#include "monitor/hmp.h" #include "monitor/hmp-target.h" #include "system/memory.h"
target/sh4/monitor.c +0 -1
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "cpu.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" #include "monitor/hmp.h" static void print_tlb (Monitor *mon,int idx,tlb_t *tlb)
target/xtensa/monitor.c +0 -1
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "cpu.h" #include "monitor/monitor.h" -#include "monitor/hmp-target.h" #include "monitor/hmp.h" void hmp_info_tlb (Monitor *mon,const QDict *qdict)
Signature · 1 line
2.52.0
Quoted 7 lines · Philippe Mathieu-Daudé
From "
monitor/hmp-target.h", only the MonitorDef structure is target specific (by using the 'target_long' type). All the rest (eventarget_monitor_defsandtarget_get_monitor_def) can be exposed to target-agnostic units, allowing to build some of them in meson common source set.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
The only use of the ->get_value() callback I can see is in get_monitor_def(), to implement HMP's $register feature. I can't see the callback being set. Is it dead?
Quoted 8 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 6 lines · Philippe Mathieu-Daudé
From "
monitor/hmp-target.h", only the MonitorDef structure is target specific (by using the 'target_long' type). All the rest (eventarget_monitor_defsandtarget_get_monitor_def) can be exposed to target-agnostic units, allowing to build some of them in meson common source set.
Quoted 5 lines
Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>The only use of the ->get_value() callback I can see is in
get_monitor_def(), to implement HMP's $register feature. I can't see the callback being set. Is it dead?
I think I see that being used in ppc;target/ppc/ppc-qmp-cmds.c
const MonitorDef monitor_defs[] = {
{ "fpscr", offsetof(CPUPPCState, fpscr) },
/* Next instruction pointer */
{ "nip|pc", offsetof(CPUPPCState, nip) },
{ "lr", offsetof(CPUPPCState, lr) },
{ "ctr", offsetof(CPUPPCState, ctr) },
{ "decr", 0, &monitor_get_decr, },
{ "ccr|cr", 0, &monitor_get_ccr, },
/* Machine state register */
{ "xer", 0, &monitor_get_xer },
{ "msr", offsetof(CPUPPCState, msr) },
{ "tbu", 0, &monitor_get_tbu, },
#if defined(TARGET_PPC64)
{ "tb", 0, &monitor_get_tbl, },
#else
{ "tbl", 0, &monitor_get_tbl, },
#endif
{ NULL },
};those monitor_get_* functions are that get_value() aren't they?
Dave
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Quoted 38 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 6 lines · Philippe Mathieu-Daudé
From "
monitor/hmp-target.h", only the MonitorDef structure is target specific (by using the 'target_long' type). All the rest (eventarget_monitor_defsandtarget_get_monitor_def) can be exposed to target-agnostic units, allowing to build some of them in meson common source set.Quoted 5 lines
Quoted 1 line
Signed-off-by Philippe Mathieu-Daudé <[email protected]>The only use of the ->get_value() callback I can see is in
get_monitor_def(), to implement HMP's $register feature. I can't see the callback being set. Is it dead?I think I see that being used in ppc;
target/ppc/ppc-qmp-cmds.cconst MonitorDef monitor_defs[] = { { "fpscr", offsetof(CPUPPCState, fpscr) }, /* Next instruction pointer */ { "nip|pc", offsetof(CPUPPCState, nip) }, { "lr", offsetof(CPUPPCState, lr) }, { "ctr", offsetof(CPUPPCState, ctr) }, { "decr", 0, &monitor_get_decr, }, { "ccr|cr", 0, &monitor_get_ccr, }, /* Machine state register */ { "xer", 0, &monitor_get_xer }, { "msr", offsetof(CPUPPCState, msr) }, { "tbu", 0, &monitor_get_tbu, }, #if defined(TARGET_PPC64) { "tb", 0, &monitor_get_tbl, }, #else { "tbl", 0, &monitor_get_tbl, }, #endif { NULL }, };
Quoted 1 line
those monitor_get_* functions are that
get_value()aren't they?
You're right.
target/sparc/monitor.c and target/i386/monitor.c have more.
I prefer .member = initial-value when member is optional.
Thanks!
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 1 line
From "
monitor/hmp-target.h", only the MonitorDef structureis target specific (by using the '
target_long' type). All the rest (eventarget_monitor_defsandtarget_get_monitor_def) can be exposed to target-agnostic units, allowing to build some of them in meson common source set.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
target_long is only used as return type of MonitorDef method get_value(). Its only caller is
int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
{
[...]
for(; md->name != NULL; md++) {
if (hmp_compare_cmd(name, md->name)) {
if (md->get_value) {
---> *pval = md->get_value(mon, md, md->offset);
} else {We store the return value in an int64_t.
Change the return type to match?
Quoted 8 lines · Philippe Mathieu-Daudé
Move most of target-agnostic definitions from
"monitor/hmp-target.h" to "monitor/hmp.h" to
reduce files target-poisoning.Philippe Mathieu-Daudé (2):
target/i386: Include missing 'svm.h' header in 'sev.h' monitor/hmp: Reduce target-specific definitions
Quoted 16 lines
include/monitor/hmp-target.h | 28 +++++----------------------- include/monitor/hmp.h | 23 +++++++++++++++++++++++ target/i386/sev.h | 2 ++ hw/i386/sgx-stub.c | 2 +- hw/i386/sgx.c | 1 - monitor/hmp-cmds.c | 1 - stubs/target-monitor-defs.c | 2 +- target/i386/cpu-apic.c | 2 +- target/i386/sev-system-stub.c | 2 +- target/i386/sev.c | 1 - target/m68k/monitor.c | 1 + target/riscv/monitor.c | 1 + target/sh4/monitor.c | 1 - target/xtensa/monitor.c | 1 - 14 files changed, 36 insertions(+), 32 deletions(-)
(in private),
build issues:
https://github.com/pbo-linaro/qemu-ci/actions/runs/20792272184/job/59717050408