All remaining users of cpu_exec_halt simply alias cpu_has_work(). Call cpu_has_work() directly from the generic halt flow and remove the redundant hook registrations and interface definition.
Make affected cpu_has_work() helpers private where possible. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> --- include/accel/tcg/cpu-ops.h | 18 ------------------ target/loongarch/internals.h | 1 - target/riscv/internals.h | 5 ----- target/s390x/s390x-internal.h | 1 - accel/tcg/cpu-exec.c | 23 ++++++++--------------- target/alpha/cpu.c | 1 - target/avr/cpu.c | 1 - target/hexagon/cpu.c | 1 - target/hppa/cpu.c | 1 - target/loongarch/cpu.c | 2 +- target/loongarch/tcg/tcg_cpu.c | 1 - target/m68k/cpu.c | 1 - target/microblaze/cpu.c | 1 - target/mips/cpu.c | 1 - target/or1k/cpu.c | 1 - target/ppc/cpu_init.c | 1 - target/riscv/cpu.c | 2 +- target/riscv/tcg/tcg-cpu.c | 1 - target/rx/cpu.c | 1 - target/s390x/cpu-system.c | 2 +- target/s390x/cpu.c | 1 - target/sh4/cpu.c | 1 - target/sparc/cpu.c | 1 - target/tricore/cpu.c | 1 - target/xtensa/cpu.c | 1 - 25 files changed, 11 insertions(+), 60 deletions(-) diff --git a/include/accel/tcg/cpu-ops.h b/include/accel/tcg/cpu-ops.h index 1ee5d3d8bdb..4195a29e1e4 100644 --- a/include/accel/tcg/cpu-ops.h +++ b/include/accel/tcg/cpu-ops.h @@ -187,7 +187,6 @@ struct TCGCPUOps { * resume execution from the halted state. This callback performs any * necessary target-specific state transitions or synchronization before * instruction execution resumes. The caller does not hold the BQL. - * Either this callback or @cpu_exec_halt must be provided (but not both). */ void (*leaving_halt)(CPUState *cpu); /** @do_interrupt: Callback for interrupt handling. */ @@ -196,23 +195,6 @@ struct TCGCPUOps { bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); /** @cpu_exec_reset: Callback for reset in cpu_exec. */ void (*cpu_exec_reset)(CPUState *cpu); - /** - * @cpu_exec_halt: Callback for handling halt in cpu_exec. - * - * The target CPU should do any special processing here that it needs - * to do when the CPU is in the halted state. - * - * Return true to indicate that the CPU should now leave halt, false - * if it should remain in the halted state. (This should generally - * be the same value that cpu_has_work() would return.) - * - * Either @leaving_halt or this method must be provided, but not both. - * If the target does not need to - * do anything special for halt, the same function used for its - * SysemuCPUOps::has_work method can be used here, as they have the - * same function signature. - */ - bool (*cpu_exec_halt)(CPUState *cpu); /** * @tlb_fill_align: Handle a softmmu tlb miss * @cpu: cpu context diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index f9a0680fe0f..2e31442453e 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -38,7 +38,6 @@ void cpu_loongarch_timer_cb(void *opaque); uint64_t cpu_loongarch_get_timer_counter(CPUTimerState *timer); uint64_t cpu_loongarch_get_timer_ticks(CPUTimerState *timer); void cpu_loongarch_set_timer_config(CPUTimerState *timer, uint64_t value); -bool loongarch_cpu_has_work(CPUState *cs); bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env); #endif /* !CONFIG_USER_ONLY */ diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 5d84e4de960..fb2d8b3e17a 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -201,11 +201,6 @@ static inline target_ulong get_xepc_mask(CPURISCVState *env) } } -#ifndef CONFIG_USER_ONLY -/* Our implementation of SysemuCPUOps::has_work */ -bool riscv_cpu_has_work(CPUState *cs); -#endif - /* Zjpm addr masking routine */ static inline target_ulong adjust_addr_body(CPURISCVState *env, target_ulong addr, diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index da60b2b1fd4..df1297b5c67 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -248,7 +248,6 @@ bool s390_cpu_system_realize(DeviceState *dev, Error **errp); void s390_cpu_finalize(Object *obj); void s390_cpu_system_class_init(CPUClass *cc); void s390_cpu_machine_reset_cb(void *opaque); -bool s390_cpu_has_work(CPUState *cs); #endif /* CONFIG_USER_ONLY */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index edb719b0d10..30a9a8aed42 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -48,7 +48,6 @@ #include "internal-common.h" #if !defined(CONFIG_USER_ONLY) #include "accel/tcg/iommu.h" -#include "hw/core/sysemu-cpu-ops.h" #endif /* -icount align implementation. */ @@ -659,21 +658,16 @@ static bool cpu_poll_while_halted(CPUState *cpu) { const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + if (tcg_ops->poll_during_halt) { + tcg_ops->poll_during_halt(cpu); + } + + if (!cpu_has_work(cpu)) { + return false; + } + if (tcg_ops->leaving_halt) { - assert(!tcg_ops->cpu_exec_halt); - if (tcg_ops->poll_during_halt) { - tcg_ops->poll_during_halt(cpu); - } - if (!cpu_has_work(cpu)) { - return false; - } tcg_ops->leaving_halt(cpu); - } else { - assert(!tcg_ops->poll_during_halt); - assert(cpu->cc->sysemu_ops->has_work == tcg_ops->cpu_exec_halt); - if (!tcg_ops->cpu_exec_halt(cpu)) { - return false; - } } cpu->halted = 0; /* allow execution */ @@ -1072,7 +1066,6 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp) /* Check mandatory TCGCPUOps handlers */ const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; #ifndef CONFIG_USER_ONLY - assert(tcg_ops->cpu_exec_halt || tcg_ops->leaving_halt); assert(tcg_ops->cpu_exec_interrupt); assert(tcg_ops->cpu_exec_reset); assert(tcg_ops->pointer_wrap); diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 12e86021663..7d1d036e1d3 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -265,7 +265,6 @@ static const TCGCPUOps alpha_tcg_ops = { .tlb_fill = alpha_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_notreached, .cpu_exec_interrupt = alpha_cpu_exec_interrupt, - .cpu_exec_halt = alpha_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = alpha_cpu_do_interrupt, .do_transaction_failed = alpha_cpu_do_transaction_failed, diff --git a/target/avr/cpu.c b/target/avr/cpu.c index f8409f32ab9..a01e6fa4751 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -246,7 +246,6 @@ static const TCGCPUOps avr_tcg_ops = { .restore_state_to_opc = avr_restore_state_to_opc, .mmu_index = avr_cpu_mmu_index, .cpu_exec_interrupt = avr_cpu_exec_interrupt, - .cpu_exec_halt = avr_cpu_has_work, .cpu_exec_reset = cpu_reset, .tlb_fill = avr_cpu_tlb_fill, .do_interrupt = avr_cpu_do_interrupt, diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index fad526ccfb5..e7defcca8a7 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -783,7 +783,6 @@ static const TCGCPUOps hexagon_tcg_ops = { .cpu_exec_reset = cpu_reset, .tlb_fill = hexagon_tlb_fill, .do_unaligned_access = hexagon_cpu_do_unaligned_access, - .cpu_exec_halt = hexagon_cpu_has_work, .do_interrupt = hexagon_cpu_do_interrupt, #endif /* !CONFIG_USER_ONLY */ }; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 07b49e51326..7b1309a7c38 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -270,7 +270,6 @@ static const TCGCPUOps hppa_tcg_ops = { .tlb_fill_align = hppa_cpu_tlb_fill_align, .pointer_wrap = cpu_pointer_wrap_notreached, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, - .cpu_exec_halt = hppa_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = hppa_cpu_do_interrupt, .do_unaligned_access = hppa_cpu_do_unaligned_access, diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index f22f64efb80..6b765797393 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -123,7 +123,7 @@ bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) #endif #ifndef CONFIG_USER_ONLY -bool loongarch_cpu_has_work(CPUState *cs) +static bool loongarch_cpu_has_work(CPUState *cs) { bool has_work = false; diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c index 4b1d44a1644..7ea2a1eb933 100644 --- a/target/loongarch/tcg/tcg_cpu.c +++ b/target/loongarch/tcg/tcg_cpu.c @@ -327,7 +327,6 @@ const TCGCPUOps loongarch_tcg_ops = { .tlb_fill = loongarch_cpu_tlb_fill, .pointer_wrap = loongarch_pointer_wrap, .cpu_exec_interrupt = loongarch_cpu_exec_interrupt, - .cpu_exec_halt = loongarch_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = loongarch_cpu_do_interrupt, .do_transaction_failed = loongarch_cpu_do_transaction_failed, diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 9b52ad5fc23..c7771cbf643 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -710,7 +710,6 @@ static const TCGCPUOps m68k_tcg_ops = { .tlb_fill = m68k_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = m68k_cpu_exec_interrupt, - .cpu_exec_halt = m68k_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = m68k_cpu_do_interrupt, .do_transaction_failed = m68k_cpu_transaction_failed, diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 389a5124b12..6013a8def8e 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -448,7 +448,6 @@ static const TCGCPUOps mb_tcg_ops = { .tlb_fill = mb_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = mb_cpu_exec_interrupt, - .cpu_exec_halt = mb_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = mb_cpu_do_interrupt, .do_transaction_failed = mb_cpu_transaction_failed, diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 0fead20d651..c069aa1c0b7 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -716,7 +716,6 @@ static const TCGCPUOps mips_tcg_ops = { .tlb_fill = mips_cpu_tlb_fill, .pointer_wrap = mips_pointer_wrap, .cpu_exec_interrupt = mips_cpu_exec_interrupt, - .cpu_exec_halt = mips_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = mips_cpu_do_interrupt, .do_transaction_failed = mips_cpu_do_transaction_failed, diff --git a/target/or1k/cpu.c b/target/or1k/cpu.c index 66c00c0930c..42d9351b6d7 100644 --- a/target/or1k/cpu.c +++ b/target/or1k/cpu.c @@ -266,7 +266,6 @@ static const TCGCPUOps openrisc_tcg_ops = { .tlb_fill = openrisc_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = openrisc_cpu_exec_interrupt, - .cpu_exec_halt = openrisc_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = openrisc_cpu_do_interrupt, #endif /* !CONFIG_USER_ONLY */ diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 6c626843c93..ef59c56f416 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7496,7 +7496,6 @@ static const TCGCPUOps ppc_tcg_ops = { .tlb_fill = ppc_cpu_tlb_fill, .pointer_wrap = ppc_pointer_wrap, .cpu_exec_interrupt = ppc_cpu_exec_interrupt, - .cpu_exec_halt = ppc_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = ppc_cpu_do_interrupt, .cpu_exec_enter = ppc_cpu_exec_enter, diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index da4c1a090b9..c6b44e8f9c6 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -953,7 +953,7 @@ int riscv_cpu_vsirq_pending(CPURISCVState *env) (irqs | irqs_f_vs), env->hviprio); } -bool riscv_cpu_has_work(CPUState *cs) +static bool riscv_cpu_has_work(CPUState *cs) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index b68160af830..260ac6d89e7 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -286,7 +286,6 @@ const TCGCPUOps riscv_tcg_ops = { .tlb_fill = riscv_cpu_tlb_fill, .pointer_wrap = riscv_pointer_wrap, .cpu_exec_interrupt = riscv_cpu_exec_interrupt, - .cpu_exec_halt = riscv_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = riscv_cpu_do_interrupt, .do_transaction_failed = riscv_cpu_do_transaction_failed, diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 9b8473d71cf..69946928995 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -227,7 +227,6 @@ static const TCGCPUOps rx_tcg_ops = { .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = rx_cpu_exec_interrupt, - .cpu_exec_halt = rx_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = rx_cpu_do_interrupt, }; diff --git a/target/s390x/cpu-system.c b/target/s390x/cpu-system.c index d38de4fea2b..82c89080a17 100644 --- a/target/s390x/cpu-system.c +++ b/target/s390x/cpu-system.c @@ -39,7 +39,7 @@ #include "system/tcg.h" #include "hw/core/sysemu-cpu-ops.h" -bool s390_cpu_has_work(CPUState *cs) +static bool s390_cpu_has_work(CPUState *cs) { S390CPU *cpu = S390_CPU(cs); diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 85afc5dec9a..e7f81fabff6 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -384,7 +384,6 @@ static const TCGCPUOps s390_tcg_ops = { .tlb_fill = s390_cpu_tlb_fill, .pointer_wrap = s390_pointer_wrap, .cpu_exec_interrupt = s390_cpu_exec_interrupt, - .cpu_exec_halt = s390_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = s390_cpu_do_interrupt, .debug_excp_handler = s390x_cpu_debug_excp_handler, diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 3bbdee301d5..55c73a1da35 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -312,7 +312,6 @@ static const TCGCPUOps superh_tcg_ops = { .tlb_fill = superh_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_notreached, .cpu_exec_interrupt = superh_cpu_exec_interrupt, - .cpu_exec_halt = superh_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = superh_cpu_do_interrupt, .do_unaligned_access = superh_cpu_do_unaligned_access, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index ae9bdca9df8..1529f9570da 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -1074,7 +1074,6 @@ static const TCGCPUOps sparc_tcg_ops = { .tlb_fill = sparc_cpu_tlb_fill, .pointer_wrap = sparc_pointer_wrap, .cpu_exec_interrupt = sparc_cpu_exec_interrupt, - .cpu_exec_halt = sparc_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = sparc_cpu_do_interrupt, .do_transaction_failed = sparc_cpu_do_transaction_failed, diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 84a05e3d363..82b56c3cd56 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -223,7 +223,6 @@ static const TCGCPUOps tricore_tcg_ops = { .tlb_fill = tricore_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = tricore_cpu_exec_interrupt, - .cpu_exec_halt = tricore_cpu_has_work, .cpu_exec_reset = cpu_reset, }; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 7c25b9ab707..99c8bd4b5fb 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -325,7 +325,6 @@ static const TCGCPUOps xtensa_tcg_ops = { .tlb_fill = xtensa_cpu_tlb_fill, .pointer_wrap = cpu_pointer_wrap_uint32, .cpu_exec_interrupt = xtensa_cpu_exec_interrupt, - .cpu_exec_halt = xtensa_cpu_has_work, .cpu_exec_reset = cpu_reset, .do_interrupt = xtensa_cpu_do_interrupt, .do_transaction_failed = xtensa_cpu_do_transaction_failed, -- 2.53.0
