[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 56/76] accel/tcg: Make TCGCPUOps::cpu_exec_halt mandatory
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 56/76] accel/tcg: Make TCGCPUOps::cpu_exec_halt mandatory |
Date: |
Tue, 18 Jun 2024 18:00:18 +0200 |
From: Peter Maydell <peter.maydell@linaro.org>
Now that all targets set TCGCPUOps::cpu_exec_halt, we can make it
mandatory and remove the fallback handling that calls cpu_has_work.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240603160933.1141717-4-peter.maydell@linaro.org>
[PMD: Add assert(cpu_exec_halt) call in tcg_exec_realizefn]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/tcg-cpu-ops.h | 9 ++++++---
accel/tcg/cpu-exec.c | 12 ++++++------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 099de3375e..34318cf0e6 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -122,10 +122,13 @@ struct TCGCPUOps {
* 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.
+ * if it should remain in the halted state. (This should generally
+ * be the same value that cpu_has_work() would return.)
*
- * If this method is not provided, the default is to do nothing, and
- * to leave halt if cpu_has_work() returns true.
+ * This method must be provided. If the target does not need to
+ * do anything special for halt, the same function used for its
+ * CPUClass::has_work method can be used here, as they have the
+ * same function signature.
*/
bool (*cpu_exec_halt)(CPUState *cpu);
/**
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 6711b58e0b..f7f8683a1b 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -682,13 +682,8 @@ static inline bool cpu_handle_halt(CPUState *cpu)
#ifndef CONFIG_USER_ONLY
if (cpu->halted) {
const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
- bool leave_halt;
+ bool leave_halt = tcg_ops->cpu_exec_halt(cpu);
- if (tcg_ops->cpu_exec_halt) {
- leave_halt = tcg_ops->cpu_exec_halt(cpu);
- } else {
- leave_halt = cpu_has_work(cpu);
- }
if (!leave_halt) {
return true;
}
@@ -1082,6 +1077,11 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
static bool tcg_target_initialized;
if (!tcg_target_initialized) {
+ /* Check mandatory TCGCPUOps handlers */
+#ifndef CONFIG_USER_ONLY
+ assert(cpu->cc->tcg_ops->cpu_exec_halt);
+#endif /* !CONFIG_USER_ONLY */
+
cpu->cc->tcg_ops->initialize();
tcg_target_initialized = true;
}
--
2.41.0
- [PULL 45/76] hw/ppc: Avoid using Monitor in xive2_nvp_pic_print_info(), (continued)
- [PULL 45/76] hw/ppc: Avoid using Monitor in xive2_nvp_pic_print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 46/76] hw/ppc: Avoid using Monitor in pnv_xive2_pic_print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 47/76] hw/ppc: Avoid using Monitor in SpaprInterruptControllerClass::print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 48/76] hw/ppc: Avoid using Monitor in spapr_irq_print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 49/76] hw/ppc: Avoid using Monitor in pnv_chip_power9_pic_print_info_child(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 50/76] hw/ppc: Avoid using Monitor in pic_print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 51/76] hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 52/76] hw/intc: Introduce x-query-interrupt-controllers QMP command, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 53/76] ppc/pnv: Introduce pnv_chip_foreach_cpu(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 54/76] target/arm: Set arm_v7m_tcg_ops cpu_exec_halt to arm_cpu_exec_halt(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 56/76] accel/tcg: Make TCGCPUOps::cpu_exec_halt mandatory,
Philippe Mathieu-Daudé <=
- [PULL 55/76] target: Set TCGCPUOps::cpu_exec_halt to target's has_work implementation, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 57/76] memory: Constify IOMMUTLBEvent in memory_region_notify_iommu_one(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 58/76] memory: Constify IOMMUTLBEvent in memory_region_notify_iommu(), Philippe Mathieu-Daudé, 2024/06/18
- [PULL 59/76] hw/i386/iommu: Constify IOMMUTLBEvent in vtd_page_walk_hook prototype, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 60/76] hw/usb: Remove unused 'host.h' header, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 63/76] hw/intc/loongson_ipi: Provide per core MMIO address spaces, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 62/76] hw/intc: Remove loongarch_ipi.c, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 61/76] hw/usb/dev-mtp: Correctly report free space, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 64/76] hw/intc/loongson_ipi: Replace ipi_getcpu with cpu_by_arch_id, Philippe Mathieu-Daudé, 2024/06/18
- [PULL 66/76] hw/s390x: Introduce s390_skeys_get|set() helpers, Philippe Mathieu-Daudé, 2024/06/18