Multi-target 20261015
Subsystems (2)
The following changes since commit 7e8d3c7fc460fe7cd28a3e423d7466fa292bc269:
Merge tag 'pull-aspeed-20261015' of https://github.com/legoater/qemu into staging (2026-10-15 14:58:28 +0200)
are available in the Git repository at:
https://gitlab.com/p-b-o/qemu tags/pbouvier/pr/multi_target-20261015
for you to fetch changes up to 269cab810cd7ee2f6955be2048979b206a711817:
qmp: reimplement qmp_query_cpu_definitions as a dispatcher function (2026-10-15 19:30:24 +0000)
----------------------------------------------------------------
Changes:
- [PATCH v3 00/12] multi-target: add hexagon (Pierrick Bouvier <[email protected]>)
- [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication (Pierrick Bouvier <[email protected]>)
----------------------------------------------------------------
Pierrick Bouvier (20):
target/hexagon: prefix helpers conflicting with other arch
target-info: add target_hexagon
hw/hexagon/virt: make machine available for hexagon target only hw/core/cpu: restrict tcg_ops to CONFIG_TCG only
semihosting: declare semihosting cpu ops
target/riscv/cpu: constify cpu parameter for riscv_cpu_mxl target/riscv: declare semihosting ops
target/hexagon: declare semihosting ops
target/arm: declare semihosting ops
semihosting: use new semihosting ops
semihosting: remove common_* functions
meson.build: add hexagon-softmmu to multi-target
target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions target/loongarch: rename to qmp_query_loongarch_cpu_definitions target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions
qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
hw/core/machine-qmp-cmds.c | 32 ++++++++++++++++++++ hw/hexagon/virt.c | 2 ++ include/hw/core/cpu.h | 8 +++++ include/qemu/target-info.h | 7 +++++ include/semihosting/common-semi.h | 24 ++++++++++----- include/system/qmp-cpu.h | 20 +++++++++++++ meson.build | 1 + semihosting/arm-compat-semi.c | 56 +++++++++++++++++------------------ stubs/meson.build | 6 ++++ stubs/qmp-cpu-arm.c | 9 ++++++ stubs/qmp-cpu-i386.c | 9 ++++++ stubs/qmp-cpu-loongarch.c | 9 ++++++ stubs/qmp-cpu-mips.c | 9 ++++++ stubs/qmp-cpu-ppc.c | 9 ++++++ stubs/qmp-cpu-riscv.c | 9 ++++++ stubs/qmp-cpu-s390x.c | 6 ++++ stubs/qmp-cpu.c | 7 ----- target-info.c | 5 ++++ target/arm/arm-qmp-cmds.c | 3 +- target/arm/common-semi-target.c | 33 ++++++++++++++------- target/arm/cpu.c | 4 +++ target/arm/internals.h | 2 ++ target/hexagon/common-semi-target.c | 30 ++++++++++++------- target/hexagon/cpu.c | 2 ++ target/hexagon/gen_tcg.h | 2 +- target/hexagon/gen_tcg_sys.h | 2 +- target/hexagon/helper.h | 4 +-- target/hexagon/hex_mmu.c | 2 +- target/hexagon/hex_mmu.h | 2 +- target/hexagon/internal.h | 2 ++ target/hexagon/op_helper.c | 4 +-- target/hexagon/translate.c | 4 +-- target/i386/cpu.c | 3 +- target/loongarch/loongarch-qmp-cmds.c | 3 +- target/mips/system/mips-qmp-cmds.c | 3 +- target/ppc/ppc-qmp-cmds.c | 3 +- target/riscv/common-semi-target.c | 37 +++++++++++++++-------- target/riscv/cpu.c | 4 +++ target/riscv/cpu.h | 2 +- target/riscv/internals.h | 2 ++ target/riscv/riscv-qmp-cmds.c | 3 +- target/s390x/cpu_models_system.c | 3 +- 42 files changed, 293 insertions(+), 94 deletions(-) create mode 100644 include/system/qmp-cpu.h create mode 100644 stubs/qmp-cpu-arm.c create mode 100644 stubs/qmp-cpu-i386.c create mode 100644 stubs/qmp-cpu-loongarch.c create mode 100644 stubs/qmp-cpu-mips.c create mode 100644 stubs/qmp-cpu-ppc.c create mode 100644 stubs/qmp-cpu-riscv.c
[PULL 10/20] semihosting: use new semihosting ops
Now that all targets implement this interface, we can replace function calls with the new interface.
We assume semihosting ops are set on this code path, and do not perform a NULL check.
--- semihosting/arm-compat-semi.c | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-)
semihosting/arm-compat-semi.c +28 -28
@@ -188,7 +188,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)*/ #define GET_ARG (n) do { \ - if (is_64bit_semihosting(env)) { \ + if (cs->cc->semi_ops->is_64bit(cs)) { \ if (get_user_u64(arg ## n, args + (n) * 8)) { \ goto do_fault; \ } \
@@ -200,7 +200,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs) }while (0 ) #define SET_ARG(n, val) \ - (is_64bit_semihosting (env) ? \ + (cs->cc->semi_ops->is_64bit (cs) ? \put_user_u64 (val, args + (n) *8 ) : \put_user_u32 (val, args + (n) *4 ))
@@ -237,10 +237,10 @@ void common_semi_cb(CPUState *cs, uint64_t ret, int err) ts->swi_errno = err;#else syscall_err = err; -common_semi_set_err (cs, err); + cs->cc->semi_ops->set_err (cs, err);#endif } -common_semi_set_ret (cs, ret); + cs->cc->semi_ops->set_ret (cs, ret); }/*
@@ -249,7 +249,7 @@ void common_semi_cb(CPUState *cs, uint64_t ret, int err)*/ static void common_semi_dead_cb (CPUState *cs,uint64_t ret,int err) { -common_semi_set_ret (cs,0xdeadbeef ); + cs->cc->semi_ops->set_ret (cs,0xdeadbeef ); }/*
@@ -260,7 +260,7 @@ static void common_semi_rw_cb(CPUState *cs, uint64_t ret, int err) {/* Recover the original length from the third argument. */ CPUArchState *env G_GNUC_UNUSED = cpu_env(cs); -uint64_t args =common_semi_arg (cs,1 ); +uint64_t args = cs->cc->semi_ops->arg (cs,1 );uint64_t arg2;GET_ARG (2 );
@@ -268,7 +268,7 @@ static void common_semi_rw_cb(CPUState *cs, uint64_t ret, int err) do_fault: ret =0 ;/* error: no bytes transmitted */ } -common_semi_set_ret (cs, arg2 - ret); + cs->cc->semi_ops->set_ret (cs, arg2 - ret); }/*
@@ -302,7 +302,7 @@ static void common_semi_seek_cb(CPUState *cs, uint64_t ret, int err)*/ static uint64_t common_semi_flen_buf (CPUState *cs) { -vaddr sp =common_semi_stack_bottom (cs); +vaddr sp = cs->cc->semi_ops->stack_bottom (cs);return sp -64 ; }
@@ -330,7 +330,7 @@ common_semi_readc_cb(CPUState *cs, uint64_t ret, int err) CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);uint8_t ch; -if (get_user_u8 (ch,common_semi_stack_bottom (cs) -1 )) { +if (get_user_u8 (ch, cs->cc->semi_ops->stack_bottom (cs) -1 )) { ret =-1 , err =EFAULT ; }else { ret = ch;
@@ -385,7 +385,7 @@ void semihosting_arm_compatible_init(void)*/ void do_common_semihosting (CPUState *cs) { -CPUArchState *env =cpu_env (cs); + CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);uint64_t args;uint64_t arg0, arg1, arg2, arg3;uint64_t ul_ret;
@@ -393,8 +393,8 @@ void do_common_semihosting(CPUState *cs)int nr;int64_t elapsed; - nr =common_semi_arg (cs,0 ) &0xffffffffU ; - args =common_semi_arg (cs,1 ); + nr = cs->cc->semi_ops->arg (cs,0 ) &0xffffffffU ; + args = cs->cc->semi_ops->arg (cs,1 );switch (nr) {case TARGET_SYS_OPEN :
@@ -494,15 +494,15 @@ void do_common_semihosting(CPUState *cs)case TARGET_SYS_READC :semihost_sys_read_gf (cs, common_semi_readc_cb, &console_in_gf, -common_semi_stack_bottom (cs) -1 ,1 ); + cs->cc->semi_ops->stack_bottom (cs) -1 ,1 );break ;case TARGET_SYS_ISERROR : {GET_ARG (0 ); -bool ret =is_64bit_semihosting (env) ? +bool ret = cs->cc->semi_ops->is_64bit (cs) ? (int64_t )arg0 <0 : (int32_t )arg0 <0 ; -common_semi_set_ret (cs, ret); + cs->cc->semi_ops->set_ret (cs, ret);break ; }case TARGET_SYS_ISTTY :
@@ -533,7 +533,7 @@ void do_common_semihosting(CPUState *cs) len =asprintf (&s,"%s/qemu-%x%02x" ,g_get_tmp_dir (),getpid (), (int )arg1 &0xff );if (len <0 ) { -common_semi_set_ret (cs,-1 ); + cs->cc->semi_ops->set_ret (cs,-1 );break ; }
@@ -542,7 +542,7 @@ void do_common_semihosting(CPUState *cs)/* Make sure there's enough space in the buffer */ if (len > arg2) {free (s); -common_semi_set_ret (cs,-1 ); + cs->cc->semi_ops->set_ret (cs,-1 );break ; } p =lock_user (VERIFY_WRITE , arg0, len,0 );
@@ -553,7 +553,7 @@ void do_common_semihosting(CPUState *cs)memcpy (p, s, len);unlock_user (p, arg0, len);free (s); -common_semi_set_ret (cs,0 ); + cs->cc->semi_ops->set_ret (cs,0 );break ; }
@@ -572,7 +572,7 @@ void do_common_semihosting(CPUState *cs)break ;case TARGET_SYS_CLOCK : -common_semi_set_ret (cs,clock () / (CLOCKS_PER_SEC /100 )); + cs->cc->semi_ops->set_ret (cs,clock () / (CLOCKS_PER_SEC /100 ));break ;case TARGET_SYS_TIME :
@@ -587,7 +587,7 @@ void do_common_semihosting(CPUState *cs)break ;case TARGET_SYS_ERRNO : -common_semi_set_ret (cs,get_swi_errno (cs)); + cs->cc->semi_ops->set_ret (cs,get_swi_errno (cs));break ;case TARGET_SYS_GET_CMDLINE :
@@ -734,7 +734,7 @@ void do_common_semihosting(CPUState *cs)for (i =0 ; i <ARRAY_SIZE (retvals); i++) {bool fail; -if (is_64bit_semihosting (env)) { +if (cs->cc->semi_ops->is_64bit (cs)) { fail =put_user_u64 (retvals[i], arg0 + i *8 ); }else { fail =put_user_u32 (retvals[i], arg0 + i *4 );
@@ -745,7 +745,7 @@ void do_common_semihosting(CPUState *cs) goto do_fault; } } -common_semi_set_ret (cs,0 ); + cs->cc->semi_ops->set_ret (cs,0 ); }break ;
@@ -755,7 +755,7 @@ void do_common_semihosting(CPUState *cs)uint32_t ret;if (nr ==TARGET_SYS_EXIT_EXTENDED || -common_semi_sys_exit_is_extended (cs)) { + cs->cc->semi_ops->sys_exit_is_extended (cs)) {/* * The A64 version of SYS_EXIT takes a parameter block, * so the application-exit type can return a subcode which
@@ -786,7 +786,7 @@ void do_common_semihosting(CPUState *cs)case TARGET_SYS_ELAPSED : elapsed =get_clock () - clock_start; -if (is_64bit_semihosting (env)) { +if (cs->cc->semi_ops->is_64bit (cs)) {if (SET_ARG (0 , elapsed)) { goto do_fault; }
@@ -796,12 +796,12 @@ void do_common_semihosting(CPUState *cs) goto do_fault; } } -common_semi_set_ret (cs,0 ); + cs->cc->semi_ops->set_ret (cs,0 );break ;case TARGET_SYS_TICKFREQ :/* qemu always uses nsec */ -common_semi_set_ret (cs,1000000000 ); + cs->cc->semi_ops->set_ret (cs,1000000000 );break ;case TARGET_SYS_SYNCCACHE :
@@ -810,8 +810,8 @@ void do_common_semihosting(CPUState *cs)* virtual address range. This is a nop for us since we don't * implement caches. This is only present on A64. */ -if (common_semi_has_synccache (env)) { -common_semi_set_ret (cs,0 ); +if (cs->cc->semi_ops->has_synccache (cs)) { + cs->cc->semi_ops->set_ret (cs,0 );break ; }/* fall through */
Signature · 1 line
2.43.0
[PULL 01/20] target/hexagon: prefix helpers conflicting with other arch
In reply to Pierrick Bouvier--- target/hexagon/gen_tcg.h | 2 +- target/hexagon/gen_tcg_sys.h | 2 +- target/hexagon/helper.h | 4 ++-- target/hexagon/hex_mmu.c | 2 +- target/hexagon/hex_mmu.h | 2 +- target/hexagon/op_helper.c | 4 ++-- target/hexagon/translate.c | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-)
target/hexagon/gen_tcg.h +1 -1
@@ -1135,7 +1135,7 @@#define fGEN_TCG_J2_pause (SHORTCODE ) \ do { \ uiV = uiV; \ - gen_helper_raise_exception(tcg_env, \ + gen_helper_hexagon_raise_exception(tcg_env, \ tcg_constant_i32(EXCP_YIELD), \ tcg_constant_i32(ctx->next_PC)); \ } while (0)
target/hexagon/gen_tcg_sys.h +1 -1
@@ -80,7 +80,7 @@#define fGEN_TCG_Y2_wait (SHORTCODE ) \ do { \ RsV = RsV; \ - gen_helper_wait(tcg_env); \ + gen_helper_hexagon_wait(tcg_env); \ } while (0)#define fGEN_TCG_Y2_resume (SHORTCODE ) \
target/hexagon/helper.h +2 -2
@@ -18,7 +18,7 @@#include "internal.h" #include "helper_protos_generated.h.inc" -DEF_HELPER_FLAGS_3(raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32, i32) +DEF_HELPER_FLAGS_3(hexagon_raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32, i32) DEF_HELPER_2(commit_store, void, env, int) DEF_HELPER_3(gather_store, void, env, i32, int)DEF_HELPER_1 (commit_hvx_stores, void, env)
@@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32) DEF_HELPER_3(setprio, void, env, i32, i32) DEF_HELPER_2(start, void, env, i32) DEF_HELPER_1(stop, void, env) -DEF_HELPER_1(wait, void, env) +DEF_HELPER_1(hexagon_wait, void, env) DEF_HELPER_2(resume, void, env, i32) DEF_HELPER_1(resched, void, env)DEF_HELPER_3 (modify_ssr, void, env, i32, i32)
target/hexagon/hex_mmu.c +1 -1
@@ -115,7 +115,7 @@ int hex_tlb_check_overlap(CPUHexagonState *env, uint64_t entry, uint64_t index) }#ifdef CONFIG_HMP -void dump_mmu (MonitorHMP *hmp,CPUHexagonState *env) +void hexagon_dump_mmu (MonitorHMP *hmp,CPUHexagonState *env) {HexagonCPU *cpu =env_archcpu (env);hexagon_tlb_dump (hmp, cpu->tlb);
target/hexagon/hex_mmu.h +1 -1
@@ -24,5 +24,5 @@ extern int hex_tlb_check_overlap(CPUHexagonState *env, uint64_t entry, uint64_t index);extern void hex_tlb_lock (CPUHexagonState *env,uint32_t PC );extern void hex_tlb_unlock (CPUHexagonState *env); -void dump_mmu (MonitorHMP *hmp,CPUHexagonState *env); +void hexagon_dump_mmu (MonitorHMP *hmp,CPUHexagonState *env);#endif
target/hexagon/op_helper.c +2 -2
@@ -93,7 +93,7 @@ G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,do_raise_exception (env, exception, pc,0 ); } -G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp, +G_NORETURN void HELPER(hexagon_raise_exception)(CPUHexagonState *env, uint32_t excp,uint32_t PC ) {hexagon_raise_exception_err (env, excp,PC );
@@ -1837,7 +1837,7 @@ void HELPER(resched)(CPUHexagonState *env)resched (env); } -void HELPER (wait )(CPUHexagonState *env) +void HELPER (hexagon_wait )(CPUHexagonState *env) {BQL_LOCK_GUARD ();
target/hexagon/translate.c +2 -2
@@ -140,7 +140,7 @@ intptr_t ctx_tmp_vreg_off(DisasContext *ctx, int regnum,static void gen_precise_exception (int cause,uint32_t PC ) {tcg_gen_movi_i32 (hex_cause_code, cause); -gen_helper_raise_exception (tcg_env,tcg_constant_i32 (HEX_EVENT_PRECISE ), +gen_helper_hexagon_raise_exception (tcg_env,tcg_constant_i32 (HEX_EVENT_PRECISE ),tcg_constant_i32 (PC )); }
@@ -1163,7 +1163,7 @@ static void check_imprecise_exception(DisasContext *ctx)TCGLabel *label =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , hex_imprecise_exception,0 , label); -gen_helper_raise_exception (tcg_env, hex_imprecise_exception,PC ); +gen_helper_hexagon_raise_exception (tcg_env, hex_imprecise_exception,PC ); gen_set_label(label); }#endif
Signature · 1 line
2.43.0
[PULL 04/20] hw/core/cpu: restrict tcg_ops to CONFIG_TCG only
In reply to Pierrick BouvierWe introduce this since upcoming semihosting ops will be in the same ifdef.
--- include/hw/core/cpu.h | 2 ++ 1 file changed, 2 insertions(+)
include/hw/core/cpu.h +2 -0
@@ -183,8 +183,10 @@ struct CPUClass {/* when system emulation is not available, this pointer is NULL */ const struct SysemuCPUOps *sysemu_ops; +#ifdef CONFIG_TCG /* when TCG is not available, this pointer is NULL */ const TCGCPUOps *tcg_ops; +#endif /* * Keep non-pointer data at the end to minimize holes.
Signature · 1 line
2.43.0
[PULL 09/20] target/arm: declare semihosting ops
In reply to Pierrick BouvierFor now, we keep the global common_* symbols defined.
--- target/arm/common-semi-target.c | 72 +++++++++++++++++++++++++++------ target/arm/cpu.c | 4 ++ target/arm/internals.h | 2 + 3 files changed, 65 insertions(+), 13 deletions(-)
target/arm/common-semi-target.c +59 -13
@@ -10,9 +10,10 @@#include "qemu/osdep.h" #include "cpu.h" #include "semihosting/common-semi.h" +#include "internals.h" #include "target/arm/cpu-qom.h" -uint64_t common_semi_arg (CPUState *cs,int argno) +static uint64_t arm_semi_arg (const CPUState *cs,int argno) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;
@@ -23,7 +24,7 @@ uint64_t common_semi_arg(CPUState *cs, int argno) } } -void common_semi_set_ret (CPUState *cs,uint64_t ret) +static void arm_semi_set_ret (CPUState *cs,uint64_t ret) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;
@@ -34,29 +35,74 @@ void common_semi_set_ret(CPUState *cs, uint64_t ret) } } +static void arm_semi_set_err (CPUState *cs,int err) +{ +} + +static bool arm_semi_is_64bit (const CPUState *cs) +{ +return is_a64 (cpu_env (cs)); +} + +static bool arm_semi_sys_exit_is_extended (const CPUState *cs) +{ +return is_a64 (cpu_env (cs)); +} + +static uint64_t arm_semi_stack_bottom (const CPUState *cs) +{ +const ARMCPU *cpu =ARM_CPU (cs); +const CPUARMState *env = &cpu->env; +return is_a64 (env) ? env->xregs[31 ] : env->regs[13 ]; +} + +static bool arm_semi_has_synccache (const CPUState *cs) +{ +/* Ok for A64, invalid for A32/T32 */ +return is_a64 (cpu_env (cs)); +} + +const SemihostingCPUOps arm_semihosting_ops = { + .arg = arm_semi_arg, + .set_ret = arm_semi_set_ret, + .set_err = arm_semi_set_err, + .is_64bit = arm_semi_is_64bit, + .sys_exit_is_extended = arm_semi_sys_exit_is_extended, + .stack_bottom = arm_semi_stack_bottom, + .has_synccache = arm_semi_has_synccache, +}; + +uint64_t common_semi_arg (CPUState *cs,int argno) +{ +return arm_semi_arg (cs, argno); +} + +void common_semi_set_ret (CPUState *cs,uint64_t ret) +{ +arm_semi_set_ret (cs, ret); +} +void common_semi_set_err (CPUState *cs,int err) { -} - -bool common_semi_sys_exit_is_extended (CPUState *cs) -{ -return is_a64 (cpu_env (cs)); +arm_semi_set_err (cs, err); }bool is_64bit_semihosting (CPUArchState *env) { -return is_a64 (env); +return arm_semi_is_64bit (env_cpu (env)); +} + +bool common_semi_sys_exit_is_extended (CPUState *cs) +{ +return arm_semi_sys_exit_is_extended (cs); }uint64_t common_semi_stack_bottom (CPUState *cs) { -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -return is_a64 (env) ? env->xregs[31 ] : env->regs[13 ]; +return arm_semi_stack_bottom (cs); }bool common_semi_has_synccache (CPUArchState *env) { -/* Ok for A64, invalid for A32/T32 */ -return is_a64 (env); +return arm_semi_has_synccache (env_cpu (env)); }
target/arm/cpu.c +4 -0
@@ -2663,6 +2663,10 @@ static void arm_cpu_class_init(ObjectClass *oc, const void *data)#ifdef CONFIG_TCG cc->tcg_ops = &arm_tcg_ops; +#if !defined(CONFIG_USER_ONLY ) || defined(CONFIG_LINUX ) +/* semihosting is not supported for bsd-user */ + cc->semi_ops = &arm_semihosting_ops; +#endif #endif /* CONFIG_TCG */ }
target/arm/internals.h +2 -0
@@ -437,6 +437,8 @@ bool arm_cpu_exec_halt(CPUState *cs);int arm_cpu_mmu_index (CPUState *cs,bool ifetch);#endif /* CONFIG_TCG */ +extern const struct SemihostingCPUOps arm_semihosting_ops; + typedef enum ARMFPRounding { FPROUNDING_TIEEVEN, FPROUNDING_POSINF,
Signature · 1 line
2.43.0
[PULL 14/20] target/i386: rename qmp_query_cpu_definitions to qmp_query_i386_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/i386/cpu.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -10,5 +10,6 @@#include "qapi/qapi-types-machine.h" CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp);#endif
target/i386/cpu.c +7 -1
@@ -45,6 +45,7 @@#include "monitor/hmp.h" #include "system/reset.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "system/address-spaces.h" #include "hw/core/boards.h" #include "hw/i386/sgx-epc.h"
@@ -8191,7 +8192,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list =get_sorted_cpu_model_list ();
@@ -8200,6 +8201,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return cpu_list; } +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_i386_cpu_definitions (errp); +} +#endif /* !CONFIG_USER_ONLY */ static uint8_t x86_cpu_get_host_avx10_version (void )
Signature · 1 line
2.43.0
[PULL 08/20] target/hexagon: declare semihosting ops
In reply to Pierrick BouvierFor now, we keep the global common_* symbols defined.
--- target/hexagon/common-semi-target.c | 65 ++++++++++++++++++++++++----- target/hexagon/cpu.c | 2 + target/hexagon/internal.h | 2 + 3 files changed, 59 insertions(+), 10 deletions(-)
target/hexagon/common-semi-target.c +55 -10
@@ -8,44 +8,89 @@#include "qemu/osdep.h" #include "cpu.h" -#include "cpu_helper.h" #include "semihosting/common-semi.h" +#include "internal.h" -uint64_t common_semi_arg (CPUState *cs,int argno) +static uint64_t hexagon_semi_arg (const CPUState *cs,int argno) { -CPUHexagonState *env =cpu_env (cs); +const CPUHexagonState *env =cpu_env (cs);return env->gpr[HEX_REG_R00 + argno]; } -void common_semi_set_ret (CPUState *cs,uint64_t ret) +static void hexagon_semi_set_ret (CPUState *cs,uint64_t ret) {CPUHexagonState *env =cpu_env (cs); env->gpr[HEX_REG_R00 ] = ret; } -void common_semi_set_err (CPUState *cs,int err) +static void hexagon_semi_set_err (CPUState *cs,int err) {CPUHexagonState *env =cpu_env (cs); env->gpr[HEX_REG_R01 ] = err; } -bool common_semi_sys_exit_is_extended (CPUState *cs) +static bool hexagon_semi_is_64bit (const CPUState *cs) {return false; } +static bool hexagon_semi_sys_exit_is_extended (const CPUState *cs) +{ +return false; +} + +static uint64_t hexagon_semi_stack_bottom (const CPUState *cs) +{ +const CPUHexagonState *env =cpu_env (cs); +return env->gpr[HEX_REG_SP ]; +} + +static bool hexagon_semi_has_synccache (const CPUState *cs) +{ +return false; +} + +const SemihostingCPUOps hexagon_semihosting_ops = { + .arg = hexagon_semi_arg, + .set_ret = hexagon_semi_set_ret, + .set_err = hexagon_semi_set_err, + .is_64bit = hexagon_semi_is_64bit, + .sys_exit_is_extended = hexagon_semi_sys_exit_is_extended, + .stack_bottom = hexagon_semi_stack_bottom, + .has_synccache = hexagon_semi_has_synccache, +}; + +uint64_t common_semi_arg (CPUState *cs,int argno) +{ +return hexagon_semi_arg (cs, argno); +} + +void common_semi_set_ret (CPUState *cs,uint64_t ret) +{ +hexagon_semi_set_ret (cs, ret); +} + +void common_semi_set_err (CPUState *cs,int err) +{ +hexagon_semi_set_err (cs, err); +} +bool is_64bit_semihosting (CPUArchState *env) { -return false; +return hexagon_semi_is_64bit (env_cpu (env)); +} + +bool common_semi_sys_exit_is_extended (CPUState *cs) +{ +return hexagon_semi_sys_exit_is_extended (cs); }uint64_t common_semi_stack_bottom (CPUState *cs) { -CPUHexagonState *env =cpu_env (cs); -return env->gpr[HEX_REG_SP ]; +return hexagon_semi_stack_bottom (cs); }bool common_semi_has_synccache (CPUArchState *env) { -return false; +return hexagon_semi_has_synccache (env_cpu (env)); }
target/hexagon/cpu.c +2 -0
@@ -851,6 +851,8 @@ static void hexagon_cpu_class_init(ObjectClass *c, const void *data)#ifndef CONFIG_USER_ONLY cc->sysemu_ops = &hexagon_sysemu_ops; dc->vmsd = &vmstate_hexagon_cpu; +/* semihosting is only supported in system mode for Hexagon */ + cc->semi_ops = &hexagon_semihosting_ops;#endif #ifdef CONFIG_TCG cc->tcg_ops = &hexagon_tcg_ops;
target/hexagon/internal.h +2 -0
@@ -34,6 +34,8 @@ void hexagon_debug_qreg(CPUHexagonState *env, int regnum);void hexagon_debug (CPUHexagonState *env);void hexagon_dump (CPUHexagonState *env,FILE *f,int flags); +extern const struct SemihostingCPUOps hexagon_semihosting_ops; +extern const char *const hexagon_regnames[TOTAL_PER_THREAD_REGS ];#ifndef CONFIG_USER_ONLY extern const char *const hexagon_sregnames[];
Signature · 1 line
2.43.0
[PULL 03/20] hw/hexagon/virt: make machine available for hexagon target only
In reply to Pierrick Bouvier--- hw/hexagon/virt.c | 2 ++ 1 file changed, 2 insertions(+)
hw/hexagon/virt.c +2 -0
@@ -20,6 +20,7 @@#include "hw/core/register.h" #include "qemu/error-report.h" #include "qemu/guest-random.h" +#include "qemu/target-info.h" #include "qemu/units.h" #include "machine_cfg_v68n_1024.h.inc" #include "system/address-spaces.h"
@@ -379,6 +380,7 @@ static const TypeInfo virt_machine_types[] = { { .parent = TYPE_HEXAGON_COMMON_MACHINE, .instance_size = sizeof(HexagonVirtMachineState), .class_init = virt_class_init, + .is_available = target_hexagon, } };DEFINE_TYPES (virt_machine_types)
Signature · 1 line
2.43.0
[PULL 02/20] target-info: add target_hexagon
In reply to Pierrick Bouvier--- include/qemu/target-info.h | 7 +++++++ target-info.c | 5 +++++ 2 files changed, 12 insertions(+)
include/qemu/target-info.h +7 -0
@@ -70,6 +70,13 @@ bool target_aarch64(void);*/ bool target_m68k (void ); +/** +* target_hexagon: +* +* Returns whether the target architecture is Hexagon. +*/ +bool target_hexagon (void ); +/** * target_or1k: *
target-info.c +5 -0
@@ -68,6 +68,11 @@ bool target_m68k(void)return target_arch () ==SYS_EMU_TARGET_M68K ; } +bool target_hexagon (void ) +{ +return target_arch () ==SYS_EMU_TARGET_HEXAGON ; +} +bool target_or1k (void ) {return target_arch () ==SYS_EMU_TARGET_OR1K ;
Signature · 1 line
2.43.0
[PULL 13/20] target/arm: rename qmp_query_cpu_definitions to qmp_query_arm_cpu_definitions
In reply to Pierrick BouvierIn a future commit, a single target-agnostic qmp_query_cpu_definitions() will dispatch call to the per-architecture implementations based on target_arch(). Introduce the header holding those declarations and rename the arm implementation.
We keep the existing qmp_query_cpu_definitions() function to not break the build.
--- include/system/qmp-cpu.h | 14 ++++++++++++++ target/arm/arm-qmp-cmds.c | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 include/system/qmp-cpu.h
include/system/qmp-cpu.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Per-architecture implementations of CPU-related QMP commands. +*/ + +#ifndef SYSTEM_QMP_CPU_H +#define SYSTEM_QMP_CPU_H + +#include "qapi/error.h" +#include "qapi/qapi-types-machine.h" + +CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp); + +#endif
target/arm/arm-qmp-cmds.c +7 -1
@@ -28,6 +28,7 @@#include "qapi/visitor.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "qapi/qapi-commands-misc-arm.h" #include "qobject/qdict.h" #include "qom/qom-qobject.h"
@@ -216,7 +217,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
@@ -227,3 +228,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return cpu_list; } + +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_arm_cpu_definitions (errp); +}
Signature · 1 line
2.43.0
[PULL 20/20] qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
In reply to Pierrick BouvierNow that we have per target implementations of this function, we simply dispatch the call to relevant implementation.
This eliminates duplication of qmp_query_cpu_definitions symbol.
We need to define individual stubs for targets function since each existing binary only has one variant defined. Stub mechanism works per compilation unit, thus we need one file per symbol.
--- hw/core/machine-qmp-cmds.c | 32 +++++++++++++++++++++++++++ stubs/meson.build | 6 +++++ stubs/qmp-cpu-arm.c | 9 ++++++++ stubs/qmp-cpu-i386.c | 9 ++++++++ stubs/qmp-cpu-loongarch.c | 9 ++++++++ stubs/qmp-cpu-mips.c | 9 ++++++++ stubs/qmp-cpu-ppc.c | 9 ++++++++ stubs/qmp-cpu-riscv.c | 9 ++++++++ stubs/qmp-cpu-s390x.c | 6 +++++ stubs/qmp-cpu.c | 7 ------ target/arm/arm-qmp-cmds.c | 5 ----- target/i386/cpu.c | 5 ----- target/loongarch/loongarch-qmp-cmds.c | 5 ----- target/mips/system/mips-qmp-cmds.c | 5 ----- target/ppc/ppc-qmp-cmds.c | 5 ----- target/riscv/riscv-qmp-cmds.c | 5 ----- target/s390x/cpu_models_system.c | 5 ----- 17 files changed, 98 insertions(+), 42 deletions(-) create mode 100644 stubs/qmp-cpu-arm.c create mode 100644 stubs/qmp-cpu-i386.c create mode 100644 stubs/qmp-cpu-loongarch.c create mode 100644 stubs/qmp-cpu-mips.c create mode 100644 stubs/qmp-cpu-ppc.c create mode 100644 stubs/qmp-cpu-riscv.c
hw/core/machine-qmp-cmds.c +32 -0
@@ -27,6 +27,7 @@#include "system/hostmem.h" #include "system/hw_accel.h" #include "system/numa.h" +#include "system/qmp-cpu.h" #include "system/ramlist.h" #include "system/runstate.h" #include "system/system.h"
@@ -93,6 +94,37 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)return head; } +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +switch (target_arch ()) { +case SYS_EMU_TARGET_AARCH64 : +case SYS_EMU_TARGET_ARM : +return qmp_query_arm_cpu_definitions (errp); +case SYS_EMU_TARGET_I386 : +case SYS_EMU_TARGET_X86_64 : +return qmp_query_i386_cpu_definitions (errp); +case SYS_EMU_TARGET_LOONGARCH64 : +return qmp_query_loongarch_cpu_definitions (errp); +case SYS_EMU_TARGET_MIPS : +case SYS_EMU_TARGET_MIPS64 : +case SYS_EMU_TARGET_MIPS64EL : +case SYS_EMU_TARGET_MIPSEL : +return qmp_query_mips_cpu_definitions (errp); +case SYS_EMU_TARGET_PPC : +case SYS_EMU_TARGET_PPC64 : +return qmp_query_ppc_cpu_definitions (errp); +case SYS_EMU_TARGET_RISCV32 : +case SYS_EMU_TARGET_RISCV64 : +return qmp_query_riscv_cpu_definitions (errp); +case SYS_EMU_TARGET_S390X : +return qmp_query_s390x_cpu_definitions (errp); +default : +error_setg (errp, +"CPU model definitions are not supported on this target" ); +return NULL ; + } +} +MachineInfoList *qmp_query_machines (bool has_compat_props,bool compat_props,Error **errp) {
stubs/meson.build +6 -0
@@ -86,6 +86,12 @@ if have_system stub_ss.add(files('qmp-i386-sgx.c')) stub_ss.add(files('qmp-i386-xen.c')) stub_ss.add(files('qmp-cpu.c')) + stub_ss.add(files('qmp-cpu-arm.c')) + stub_ss.add(files('qmp-cpu-i386.c')) + stub_ss.add(files('qmp-cpu-loongarch.c')) + stub_ss.add(files('qmp-cpu-mips.c')) + stub_ss.add(files('qmp-cpu-ppc.c')) + stub_ss.add(files('qmp-cpu-riscv.c')) stub_ss.add(files('qmp-cpu-s390x.c')) stub_ss.add(files('qmp-cpu-s390x-kvm.c')) if have_hmp
stubs/qmp-cpu-arm.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-i386.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-loongarch.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-mips.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-ppc.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-riscv.c new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}
stubs/qmp-cpu-s390x.c +6 -0
@@ -3,6 +3,12 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" + +CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions (Error **errp) +{ +g_assert_not_reached (); +}CpuModelCompareInfo * qmp_query_cpu_model_comparison(CpuModelInfo *infoa,
stubs/qmp-cpu.c +0 -7
@@ -12,10 +12,3 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,error_setg (errp,"CPU model expansion is not supported on this target" );return NULL ; } - -CpuDefinitionInfoList * -qmp_query_cpu_definitions (Error **errp) -{ -error_setg (errp,"CPU model definitions are not supported on this target" ); -return NULL ; -}
target/arm/arm-qmp-cmds.c +0 -5
@@ -228,8 +228,3 @@ CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp)return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_arm_cpu_definitions (errp); -}
target/i386/cpu.c +0 -5
@@ -8201,11 +8201,6 @@ CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp) return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_i386_cpu_definitions (errp); -} -#endif /* !CONFIG_USER_ONLY */ static uint8_t x86_cpu_get_host_avx10_version (void )
target/loongarch/loongarch-qmp-cmds.c +0 -5
@@ -41,11 +41,6 @@ CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp)return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_loongarch_cpu_definitions (errp); -} -static const char *cpu_model_advertised_features[] = {"lsx" ,"lasx" ,"lbt" ,"pmu" ,"kvm-pv-ipi" ,"kvm-steal-time" ,"msgint" ,"ptw" ,NULL
target/mips/system/mips-qmp-cmds.c +0 -5
@@ -48,8 +48,3 @@ CpuDefinitionInfoList *qmp_query_mips_cpu_definitions(Error **errp)return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_mips_cpu_definitions (errp); -}
target/ppc/ppc-qmp-cmds.c +0 -5
@@ -83,8 +83,3 @@ CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions(Error **errp)return cpu_list; } - -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_ppc_cpu_definitions (errp); -}
target/riscv/riscv-qmp-cmds.c +0 -5
@@ -66,11 +66,6 @@ CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions(Error **errp)return cpu_list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_riscv_cpu_definitions (errp); -} -static void riscv_check_if_cpu_available (RISCVCPU *cpu,Error **errp) {if (!riscv_cpu_accelerator_compatible (cpu)) {
target/s390x/cpu_models_system.c +0 -5
@@ -97,11 +97,6 @@ CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions(Error **errp)return list_data.list; } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -return qmp_query_s390x_cpu_definitions (errp); -} -static void cpu_model_from_info (S390CPUModel *model,const CpuModelInfo *info,const char *info_arg_name,Error **errp) {
Signature · 1 line
2.43.0
[PULL 15/20] target/loongarch: rename to qmp_query_loongarch_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/loongarch/loongarch-qmp-cmds.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -11,5 +11,6 @@CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp);#endif
target/loongarch/loongarch-qmp-cmds.c +7 -1
@@ -10,6 +10,7 @@#include "qemu/target-info.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "cpu.h" #include "qobject/qdict.h" #include "qapi/qobject-input-visitor.h"
@@ -28,7 +29,7 @@ static void loongarch_cpu_add_definition(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
@@ -40,6 +41,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return cpu_list; } +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_loongarch_cpu_definitions (errp); +} +static const char *cpu_model_advertised_features[] = {"lsx" ,"lasx" ,"lbt" ,"pmu" ,"kvm-pv-ipi" ,"kvm-steal-time" ,"msgint" ,"ptw" ,NULL
Signature · 1 line
2.43.0
[PULL 17/20] target/ppc: rename qmp_query_cpu_definitions to qmp_query_ppc_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/ppc/ppc-qmp-cmds.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -13,5 +13,6 @@ CpuDefinitionInfoList *qmp_query_arm_cpu_definitions(Error **errp);CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions (Error **errp);#endif
target/ppc/ppc-qmp-cmds.c +7 -1
@@ -27,6 +27,7 @@#include "qemu/ctype.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "cpu-models.h" #include "cpu-qom.h"
@@ -53,7 +54,7 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*first, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
@@ -82,3 +83,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return cpu_list; } + +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_ppc_cpu_definitions (errp); +}
Signature · 1 line
2.43.0
[PULL 07/20] target/riscv: declare semihosting ops
In reply to Pierrick BouvierFor now, we keep the global common_* symbols defined.
--- target/riscv/common-semi-target.c | 66 ++++++++++++++++++++++++++----- target/riscv/cpu.c | 4 ++ target/riscv/internals.h | 2 + 3 files changed, 62 insertions(+), 10 deletions(-)
target/riscv/common-semi-target.c +56 -10
@@ -11,43 +11,89 @@#include "qemu/osdep.h" #include "cpu.h" #include "semihosting/common-semi.h" +#include "internals.h" -uint64_t common_semi_arg (CPUState *cs,int argno) +static uint64_t riscv_semi_arg (const CPUState *cs,int argno) { -RISCVCPU *cpu =RISCV_CPU (cs); -CPURISCVState *env = &cpu->env; +const RISCVCPU *cpu =RISCV_CPU (cs); +const CPURISCVState *env = &cpu->env;return env->gpr[xA0 + argno]; } -void common_semi_set_ret (CPUState *cs,uint64_t ret) +static void riscv_semi_set_ret (CPUState *cs,uint64_t ret) {RISCVCPU *cpu =RISCV_CPU (cs);CPURISCVState *env = &cpu->env; env->gpr[xA0] = ret; } +static void riscv_semi_set_err (CPUState *cs,int err) +{ +} + +static bool riscv_semi_is_64bit (const CPUState *cs) +{ +return riscv_cpu_mxl (cpu_env (cs)) !=MXL_RV32 ; +} + +static bool riscv_semi_sys_exit_is_extended (const CPUState *cs) +{ +return riscv_semi_is_64bit (cs); +} + +static uint64_t riscv_semi_stack_bottom (const CPUState *cs) +{ +const RISCVCPU *cpu =RISCV_CPU (cs); +const CPURISCVState *env = &cpu->env; +return env->gpr[xSP]; +} + +static bool riscv_semi_has_synccache (const CPUState *cs) +{ +return true; +} + +const SemihostingCPUOps riscv_semihosting_ops = { + .arg = riscv_semi_arg, + .set_ret = riscv_semi_set_ret, + .set_err = riscv_semi_set_err, + .is_64bit = riscv_semi_is_64bit, + .sys_exit_is_extended = riscv_semi_sys_exit_is_extended, + .stack_bottom = riscv_semi_stack_bottom, + .has_synccache = riscv_semi_has_synccache, +}; + +uint64_t common_semi_arg (CPUState *cs,int argno) +{ +return riscv_semi_arg (cs, argno); +} + +void common_semi_set_ret (CPUState *cs,uint64_t ret) +{ +riscv_semi_set_ret (cs, ret); +} +void common_semi_set_err (CPUState *cs,int err) { +riscv_semi_set_err (cs, err); }bool is_64bit_semihosting (CPUArchState *env) { -return riscv_cpu_mxl (env) !=MXL_RV32 ; +return riscv_semi_is_64bit (env_cpu (env)); }bool common_semi_sys_exit_is_extended (CPUState *cs) { -return is_64bit_semihosting (cpu_env (cs)); +return riscv_semi_sys_exit_is_extended (cs); }uint64_t common_semi_stack_bottom (CPUState *cs) { -RISCVCPU *cpu =RISCV_CPU (cs); -CPURISCVState *env = &cpu->env; -return env->gpr[xSP]; +return riscv_semi_stack_bottom (cs); }bool common_semi_has_synccache (CPUArchState *env) { -return true; +return riscv_semi_has_synccache (env_cpu (env)); }
target/riscv/cpu.c +4 -0
@@ -3053,6 +3053,10 @@ static void riscv_cpu_common_class_init(ObjectClass *c, const void *data) cc->gdb_arch_name = riscv_gdb_arch_name;#ifdef CONFIG_TCG cc->tcg_ops = &riscv_tcg_ops; +#if !defined(CONFIG_USER_ONLY ) || defined(CONFIG_LINUX ) +/* semihosting is not supported for bsd-user */ + cc->semi_ops = &riscv_semihosting_ops; +#endif #endif /* CONFIG_TCG */ device_class_set_props (dc, riscv_cpu_properties);
target/riscv/internals.h +2 -0
@@ -206,6 +206,8 @@ static inline target_ulong get_xepc_mask(CPURISCVState *env)bool riscv_cpu_has_work (CPUState *cs);#endif +extern const struct SemihostingCPUOps riscv_semihosting_ops; +/* Zjpm addr masking routine */ static inline target_ulong adjust_addr_body(CPURISCVState *env, target_ulong addr,
Signature · 1 line
2.43.0
[PULL 19/20] target/s390x: rename qmp_query_cpu_definitions to qmp_query_s390x_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/s390x/cpu_models_system.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -15,5 +15,6 @@ CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions(Error **errp);CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions (Error **errp);#endif
target/s390x/cpu_models_system.c +7 -1
@@ -20,6 +20,7 @@#include "qapi/qobject-input-visitor.h" #include "qobject/qdict.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" static void list_add_feat (const char *name,void *opaque);
@@ -82,7 +83,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_s390x_cpu_definitions (Error **errp) {struct CpuDefinitionInfoListData list_data = { .list =NULL ,
@@ -96,6 +97,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return list_data.list; } +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_s390x_cpu_definitions (errp); +} +static void cpu_model_from_info (S390CPUModel *model,const CpuModelInfo *info,const char *info_arg_name,Error **errp) {
Signature · 1 line
2.43.0
[PULL 05/20] semihosting: declare semihosting cpu ops
In reply to Pierrick BouvierThis allows a specific target to declare its implementation of semihosting.
--- include/hw/core/cpu.h | 6 ++++++ include/semihosting/common-semi.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+)
include/hw/core/cpu.h +6 -0
@@ -98,6 +98,9 @@ struct AccelCPUClass;/* see sysemu-cpu-ops.h */ struct SysemuCPUOps ; +/* see semihosting/common-semi.h */ +struct SemihostingCPUOps ; +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
@@ -186,6 +189,9 @@ struct CPUClass {#ifdef CONFIG_TCG /* when TCG is not available, this pointer is NULL */ const TCGCPUOps *tcg_ops; + +/* when target does not implement semihosting, this pointer is NULL */ +const struct SemihostingCPUOps *semi_ops;#endif /*
include/semihosting/common-semi.h +17 -0
@@ -34,6 +34,23 @@#ifndef COMMON_SEMI_H #define COMMON_SEMI_H +typedef struct SemihostingCPUOps { +/* Return argument @argno */ +uint64_t (*arg)(const CPUState *cs,int argno); +/* Set return value for semihosting call */ +void (*set_ret)(CPUState *cs,uint64_t ret); +/* Set an error for a semihosting call */ +void (*set_err)(CPUState *cs,int err); +/* True if the guest is using the 64-bit semihosting ABI */ +bool (*is_64bit)(const CPUState *cs); +/* True if SYS_EXIT takes an extended parameter block */ +bool (*sys_exit_is_extended)(const CPUState *cs); +/* Return lowest address until which stack can grow */ +uint64_t (*stack_bottom)(const CPUState *cs); +/* True if SYS_SYNCCACHE is implemented */ +bool (*has_synccache)(const CPUState *cs); +}SemihostingCPUOps ; +void common_semi_cb (CPUState *cs,uint64_t ret,int err);void do_common_semihosting (CPUState *cs);uint64_t common_semi_arg (CPUState *cs,int argno);
Signature · 1 line
2.43.0
[PULL 11/20] semihosting: remove common_* functions
In reply to Pierrick BouvierNow that both targets and semihosting implementation both use the semihosting ops interface, we can remove all common_* functions. This allows us to link together the three targets concerned: arm, hexagon and riscv.
--- include/semihosting/common-semi.h | 7 ------ target/arm/common-semi-target.c | 35 ----------------------------- target/hexagon/common-semi-target.c | 35 ----------------------------- target/riscv/common-semi-target.c | 35 ----------------------------- 4 files changed, 112 deletions(-)
include/semihosting/common-semi.h +0 -7
@@ -53,12 +53,5 @@ typedef struct SemihostingCPUOps {void common_semi_cb (CPUState *cs,uint64_t ret,int err);void do_common_semihosting (CPUState *cs); -uint64_t common_semi_arg (CPUState *cs,int argno); -void common_semi_set_ret (CPUState *cs,uint64_t ret); -void common_semi_set_err (CPUState *cs,int err); -bool is_64bit_semihosting (CPUArchState *env); -bool common_semi_sys_exit_is_extended (CPUState *cs); -uint64_t common_semi_stack_bottom (CPUState *cs); -bool common_semi_has_synccache (CPUArchState *env);#endif /* COMMON_SEMI_H */
target/arm/common-semi-target.c +0 -35
@@ -71,38 +71,3 @@ const SemihostingCPUOps arm_semihosting_ops = { .stack_bottom = arm_semi_stack_bottom, .has_synccache = arm_semi_has_synccache, }; - -uint64_t common_semi_arg (CPUState *cs,int argno) -{ -return arm_semi_arg (cs, argno); -} - -void common_semi_set_ret (CPUState *cs,uint64_t ret) -{ -arm_semi_set_ret (cs, ret); -} - -void common_semi_set_err (CPUState *cs,int err) -{ -arm_semi_set_err (cs, err); -} - -bool is_64bit_semihosting (CPUArchState *env) -{ -return arm_semi_is_64bit (env_cpu (env)); -} - -bool common_semi_sys_exit_is_extended (CPUState *cs) -{ -return arm_semi_sys_exit_is_extended (cs); -} - -uint64_t common_semi_stack_bottom (CPUState *cs) -{ -return arm_semi_stack_bottom (cs); -} - -bool common_semi_has_synccache (CPUArchState *env) -{ -return arm_semi_has_synccache (env_cpu (env)); -}
target/hexagon/common-semi-target.c +0 -35
@@ -59,38 +59,3 @@ const SemihostingCPUOps hexagon_semihosting_ops = { .stack_bottom = hexagon_semi_stack_bottom, .has_synccache = hexagon_semi_has_synccache, }; - -uint64_t common_semi_arg (CPUState *cs,int argno) -{ -return hexagon_semi_arg (cs, argno); -} - -void common_semi_set_ret (CPUState *cs,uint64_t ret) -{ -hexagon_semi_set_ret (cs, ret); -} - -void common_semi_set_err (CPUState *cs,int err) -{ -hexagon_semi_set_err (cs, err); -} - -bool is_64bit_semihosting (CPUArchState *env) -{ -return hexagon_semi_is_64bit (env_cpu (env)); -} - -bool common_semi_sys_exit_is_extended (CPUState *cs) -{ -return hexagon_semi_sys_exit_is_extended (cs); -} - -uint64_t common_semi_stack_bottom (CPUState *cs) -{ -return hexagon_semi_stack_bottom (cs); -} - -bool common_semi_has_synccache (CPUArchState *env) -{ -return hexagon_semi_has_synccache (env_cpu (env)); -}
target/riscv/common-semi-target.c +0 -35
@@ -62,38 +62,3 @@ const SemihostingCPUOps riscv_semihosting_ops = { .stack_bottom = riscv_semi_stack_bottom, .has_synccache = riscv_semi_has_synccache, }; - -uint64_t common_semi_arg (CPUState *cs,int argno) -{ -return riscv_semi_arg (cs, argno); -} - -void common_semi_set_ret (CPUState *cs,uint64_t ret) -{ -riscv_semi_set_ret (cs, ret); -} - -void common_semi_set_err (CPUState *cs,int err) -{ -riscv_semi_set_err (cs, err); -} - -bool is_64bit_semihosting (CPUArchState *env) -{ -return riscv_semi_is_64bit (env_cpu (env)); -} - -bool common_semi_sys_exit_is_extended (CPUState *cs) -{ -return riscv_semi_sys_exit_is_extended (cs); -} - -uint64_t common_semi_stack_bottom (CPUState *cs) -{ -return riscv_semi_stack_bottom (cs); -} - -bool common_semi_has_synccache (CPUArchState *env) -{ -return riscv_semi_has_synccache (env_cpu (env)); -}
Signature · 1 line
2.43.0
[PULL 16/20] target/mips: rename qmp_query_cpu_definitions to qmp_query_mips_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/mips/system/mips-qmp-cmds.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -12,5 +12,6 @@CpuDefinitionInfoList *qmp_query_arm_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_i386_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp);#endif
target/mips/system/mips-qmp-cmds.c +7 -1
@@ -10,6 +10,7 @@#include "qemu/target-info.h" #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "cpu.h" CpuModelExpansionInfo *
@@ -36,7 +37,7 @@ static void mips_cpu_add_definition(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list;
@@ -47,3 +48,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return cpu_list; } + +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_mips_cpu_definitions (errp); +}
Signature · 1 line
2.43.0
[PULL 18/20] target/riscv: rename to qmp_query_cpu_definitions to qmp_query_riscv_cpu_definitions
In reply to Pierrick Bouvier--- include/system/qmp-cpu.h | 1 + target/riscv/riscv-qmp-cmds.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/system/qmp-cpu.h +1 -0
@@ -14,5 +14,6 @@ CpuDefinitionInfoList *qmp_query_i386_cpu_definitions(Error **errp);CpuDefinitionInfoList *qmp_query_loongarch_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_mips_cpu_definitions (Error **errp);CpuDefinitionInfoList *qmp_query_ppc_cpu_definitions (Error **errp); +CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions (Error **errp);#endif
target/riscv/riscv-qmp-cmds.c +7 -1
@@ -26,6 +26,7 @@#include "qapi/error.h" #include "qapi/qapi-commands-machine.h" +#include "system/qmp-cpu.h" #include "qobject/qbool.h" #include "qobject/qdict.h" #include "qapi/qobject-input-visitor.h"
@@ -54,7 +55,7 @@ static void riscv_cpu_add_definition(gpointer data, gpointer user_data)QAPI_LIST_PREPEND (*cpu_list, info); } -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +CpuDefinitionInfoList *qmp_query_riscv_cpu_definitions (Error **errp) {CpuDefinitionInfoList *cpu_list =NULL ;GSList *list =object_class_get_list (TYPE_RISCV_CPU , false);
@@ -65,6 +66,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)return cpu_list; } +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +return qmp_query_riscv_cpu_definitions (errp); +} +static void riscv_check_if_cpu_available (RISCVCPU *cpu,Error **errp) {if (!riscv_cpu_accelerator_compatible (cpu)) {
Signature · 1 line
2.43.0
[PULL 06/20] target/riscv/cpu: constify cpu parameter for riscv_cpu_mxl
In reply to Pierrick Bouvier--- target/riscv/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.h +1 -1
@@ -755,7 +755,7 @@ FIELD(EXT_TB_FLAGS, BIG_ENDIAN, 33, 1)#ifdef TARGET_RISCV32 #define riscv_cpu_mxl (env) ((void)(env), MXL_RV32)#else -static inline RISCVMXL riscv_cpu_mxl (CPURISCVState *env) +static inline RISCVMXL riscv_cpu_mxl (const CPURISCVState *env) {return env->misa_mxl; }
Signature · 1 line
2.43.0
[PULL 12/20] meson.build: add hexagon-softmmu to multi-target
In reply to Pierrick BouvierNow that semihosting is solved, hexagon can join the list of target compatible with others.
--- meson.build | 1 + 1 file changed, 1 insertion(+)
meson.build +1 -0
@@ -4274,6 +4274,7 @@ multi_target_supported_targets = [ 'alpha-softmmu', 'arm-softmmu', 'avr-softmmu', + 'hexagon-softmmu', 'hppa-softmmu', 'm68k-softmmu', 'microblaze-softmmu',
Signature · 1 line
2.43.0
Richard Henderson
AppliedQuoted 12 lines · Pierrick Bouvier
The following changes since commit
7e8d3c7fc460fe7cd28a3e423d7466fa292bc269:Merge tag 'pull-aspeed-20261015' ofhttps://github.com/legoater/qemu into staging (2026-10-15 14:58:28 +0200)are available in the Git repository at:
https://gitlab.com/p-b-o/qemu tags/pbouvier/pr/multi_target-20261015for you to fetch changes up to
269cab810cd7ee2f6955be2048979b206a711817:qmp: reimplement
qmp_query_cpu_definitionsas a dispatcher function (2026-10-15 19:30:24 +0000)
Quoted 8 lines
----------------------------------------------------------------
Changes:
- [PATCH v3 00/12] multi-target: add hexagon (Pierrick Bouvier<[email protected]>)[email protected]
- [PATCH 0/8] multi-target: removeqmp_query_cpu_definitionsduplication (Pierrick Bouvier<[email protected]>)
Applied, thanks.
r~