* [PATCH v3 01/24] cpus: Restrict cpu_has_work() to system emulation
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 02/24] cpus: Un-inline cpu_has_work() Philippe Mathieu-Daudé
` (24 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
This method is not used on user emulation, because there
is always work to do there.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/core/cpu.h | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 2402706c7d9..e094d54949d 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -748,6 +748,20 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs);
*/
bool cpu_virtio_is_big_endian(CPUState *cpu);
+/**
+ * cpu_has_work:
+ * @cpu: The vCPU to check.
+ *
+ * Checks whether the CPU has work to do.
+ *
+ * Returns: %true if the CPU has work, %false otherwise.
+ */
+static inline bool cpu_has_work(CPUState *cpu)
+{
+ g_assert(cpu->cc->has_work);
+ return cpu->cc->has_work(cpu);
+}
+
#endif /* CONFIG_USER_ONLY */
/**
@@ -814,20 +828,6 @@ CPUState *cpu_create(const char *typename);
*/
const char *parse_cpu_option(const char *cpu_option);
-/**
- * cpu_has_work:
- * @cpu: The vCPU to check.
- *
- * Checks whether the CPU has work to do.
- *
- * Returns: %true if the CPU has work, %false otherwise.
- */
-static inline bool cpu_has_work(CPUState *cpu)
-{
- g_assert(cpu->cc->has_work);
- return cpu->cc->has_work(cpu);
-}
-
/**
* qemu_cpu_is_self:
* @cpu: The vCPU to check against.
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 02/24] cpus: Un-inline cpu_has_work()
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 01/24] cpus: Restrict cpu_has_work() " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 03/24] cpus: Introduce SysemuCPUOps::has_work() handler Philippe Mathieu-Daudé
` (23 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
In order to expand cpu_has_work(), un-inline it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/core/cpu.h | 6 +-----
hw/core/cpu-system.c | 6 ++++++
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e094d54949d..d64c823e768 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -756,11 +756,7 @@ bool cpu_virtio_is_big_endian(CPUState *cpu);
*
* Returns: %true if the CPU has work, %false otherwise.
*/
-static inline bool cpu_has_work(CPUState *cpu)
-{
- g_assert(cpu->cc->has_work);
- return cpu->cc->has_work(cpu);
-}
+bool cpu_has_work(CPUState *cpu);
#endif /* CONFIG_USER_ONLY */
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 37d54d04bf8..16d5efee12d 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -23,6 +23,12 @@
#include "exec/tswap.h"
#include "hw/core/sysemu-cpu-ops.h"
+bool cpu_has_work(CPUState *cpu)
+{
+ g_assert(cpu->cc->has_work);
+ return cpu->cc->has_work(cpu);
+}
+
bool cpu_paging_enabled(const CPUState *cpu)
{
if (cpu->cc->sysemu_ops->get_paging_enabled) {
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 03/24] cpus: Introduce SysemuCPUOps::has_work() handler
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 01/24] cpus: Restrict cpu_has_work() " Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 02/24] cpus: Un-inline cpu_has_work() Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 04/24] target/alpha: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
` (22 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
SysemuCPUOps::has_work() is similar to CPUClass::has_work(),
but only exposed on system emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/core/sysemu-cpu-ops.h | 4 ++++
include/hw/core/tcg-cpu-ops.h | 2 +-
hw/core/cpu-system.c | 4 ++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h
index 0df5b058f50..dee8a62ca98 100644
--- a/include/hw/core/sysemu-cpu-ops.h
+++ b/include/hw/core/sysemu-cpu-ops.h
@@ -16,6 +16,10 @@
* struct SysemuCPUOps: System operations specific to a CPU class
*/
typedef struct SysemuCPUOps {
+ /**
+ * @has_work: Callback for checking if there is work to do.
+ */
+ bool (*has_work)(CPUState *cpu);
/**
* @get_memory_mapping: Callback for obtaining the memory mappings.
*/
diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 2e3f1690f12..f60e5303f21 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -141,7 +141,7 @@ struct TCGCPUOps {
*
* 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
+ * SysemuCPUOps::has_work method can be used here, as they have the
* same function signature.
*/
bool (*cpu_exec_halt)(CPUState *cpu);
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 16d5efee12d..7b16bda2250 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -25,6 +25,10 @@
bool cpu_has_work(CPUState *cpu)
{
+ if (cpu->cc->sysemu_ops->has_work) {
+ return cpu->cc->sysemu_ops->has_work(cpu);
+ }
+
g_assert(cpu->cc->has_work);
return cpu->cc->has_work(cpu);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 04/24] target/alpha: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 03/24] cpus: Introduce SysemuCPUOps::has_work() handler Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 05/24] target/arm: " Philippe Mathieu-Daudé
` (21 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/alpha/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index e1b898e5755..83164a694d8 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -63,6 +63,7 @@ static void alpha_restore_state_to_opc(CPUState *cs,
}
}
+#ifndef CONFIG_USER_ONLY
static bool alpha_cpu_has_work(CPUState *cs)
{
/* Here we are checking to see if the CPU should wake up from HALT.
@@ -77,6 +78,7 @@ static bool alpha_cpu_has_work(CPUState *cs)
| CPU_INTERRUPT_SMP
| CPU_INTERRUPT_MCHK);
}
+#endif /* !CONFIG_USER_ONLY */
static int alpha_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -216,6 +218,7 @@ static void alpha_cpu_initfn(Object *obj)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps alpha_sysemu_ops = {
+ .has_work = alpha_cpu_has_work,
.get_phys_page_debug = alpha_cpu_get_phys_page_debug,
};
#endif
@@ -251,7 +254,6 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data)
&acc->parent_realize);
cc->class_by_name = alpha_cpu_class_by_name;
- cc->has_work = alpha_cpu_has_work;
cc->mmu_index = alpha_cpu_mmu_index;
cc->dump_state = alpha_cpu_dump_state;
cc->set_pc = alpha_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 05/24] target/arm: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 04/24] target/alpha: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 06/24] target/avr: " Philippe Mathieu-Daudé
` (20 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 048b825a006..322c95038d5 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -123,6 +123,7 @@ void arm_restore_state_to_opc(CPUState *cs,
}
#endif /* CONFIG_TCG */
+#ifndef CONFIG_USER_ONLY
/*
* With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with
* IRQ without Superpriority. Moreover, if the GIC is configured so that
@@ -141,6 +142,7 @@ static bool arm_cpu_has_work(CPUState *cs)
| CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR
| CPU_INTERRUPT_EXITTB);
}
+#endif /* !CONFIG_USER_ONLY */
static int arm_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -2671,6 +2673,7 @@ static const gchar *arm_gdb_arch_name(CPUState *cs)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps arm_sysemu_ops = {
+ .has_work = arm_cpu_has_work,
.get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug,
.asidx_from_attrs = arm_asidx_from_attrs,
.write_elf32_note = arm_cpu_write_elf32_note,
@@ -2721,7 +2724,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
&acc->parent_phases);
cc->class_by_name = arm_cpu_class_by_name;
- cc->has_work = arm_cpu_has_work;
cc->mmu_index = arm_cpu_mmu_index;
cc->dump_state = arm_cpu_dump_state;
cc->set_pc = arm_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 06/24] target/avr: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 05/24] target/arm: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 07/24] target/hexagon: Remove CPUClass:has_work() handler Philippe Mathieu-Daudé
` (19 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/avr/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index 8a126ff3222..8712813f3e2 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -200,6 +200,7 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps avr_sysemu_ops = {
+ .has_work = avr_cpu_has_work,
.get_phys_page_debug = avr_cpu_get_phys_page_debug,
};
@@ -232,7 +233,6 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data)
cc->class_by_name = avr_cpu_class_by_name;
- cc->has_work = avr_cpu_has_work;
cc->mmu_index = avr_cpu_mmu_index;
cc->dump_state = avr_cpu_dump_state;
cc->set_pc = avr_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 07/24] target/hexagon: Remove CPUClass:has_work() handler
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 06/24] target/avr: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 08/24] target/hppa: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
` (18 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Brian Cain
Remove as unreachable code.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
target/hexagon/cpu.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index 0b7fc98f6ce..f77e305d611 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -262,11 +262,6 @@ static void hexagon_cpu_synchronize_from_tb(CPUState *cs,
cpu_env(cs)->gpr[HEX_REG_PC] = tb->pc;
}
-static bool hexagon_cpu_has_work(CPUState *cs)
-{
- return true;
-}
-
static void hexagon_restore_state_to_opc(CPUState *cs,
const TranslationBlock *tb,
const uint64_t *data)
@@ -345,7 +340,6 @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data)
&mcc->parent_phases);
cc->class_by_name = hexagon_cpu_class_by_name;
- cc->has_work = hexagon_cpu_has_work;
cc->dump_state = hexagon_dump_state;
cc->set_pc = hexagon_cpu_set_pc;
cc->get_pc = hexagon_cpu_get_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 08/24] target/hppa: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 07/24] target/hexagon: Remove CPUClass:has_work() handler Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 09/24] target/i386: " Philippe Mathieu-Daudé
` (17 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index b0bc9d35e4c..d5a58a03cbb 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -125,10 +125,12 @@ static void hppa_restore_state_to_opc(CPUState *cs,
env->psw_n = 0;
}
+#ifndef CONFIG_USER_ONLY
static bool hppa_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
}
+#endif /* !CONFIG_USER_ONLY */
static int hppa_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -231,6 +233,7 @@ static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps hppa_sysemu_ops = {
+ .has_work = hppa_cpu_has_work,
.get_phys_page_debug = hppa_cpu_get_phys_page_debug,
};
#endif
@@ -267,7 +270,6 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
&acc->parent_phases);
cc->class_by_name = hppa_cpu_class_by_name;
- cc->has_work = hppa_cpu_has_work;
cc->mmu_index = hppa_cpu_mmu_index;
cc->dump_state = hppa_cpu_dump_state;
cc->set_pc = hppa_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 09/24] target/i386: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 08/24] target/hppa: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 10/24] target/loongarch: " Philippe Mathieu-Daudé
` (16 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Move has_work() from CPUClass to SysemuCPUOps,
restrict x86_cpu_pending_interrupt() to system.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/cpu.h | 4 ++--
target/i386/cpu.c | 8 +++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index b26e25ba15e..869b8598cd5 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2289,8 +2289,6 @@ struct X86CPUClass {
extern const VMStateDescription vmstate_x86_cpu;
#endif
-int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request);
-
int x86_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
int cpuid, DumpState *s);
int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
@@ -2313,6 +2311,8 @@ void x86_cpu_list(void);
int cpu_x86_support_mca_broadcast(CPUX86State *env);
#ifndef CONFIG_USER_ONLY
+int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request);
+
hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
MemTxAttrs *attrs);
int cpu_get_pic_interrupt(CPUX86State *s);
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 1b9c11022c4..51faba4e0b4 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -8256,16 +8256,15 @@ static vaddr x86_cpu_get_pc(CPUState *cs)
return cpu->env.eip + cpu->env.segs[R_CS].base;
}
+#if !defined(CONFIG_USER_ONLY)
int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request)
{
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
-#if !defined(CONFIG_USER_ONLY)
if (interrupt_request & CPU_INTERRUPT_POLL) {
return CPU_INTERRUPT_POLL;
}
-#endif
if (interrupt_request & CPU_INTERRUPT_SIPI) {
return CPU_INTERRUPT_SIPI;
}
@@ -8286,14 +8285,12 @@ int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request)
(env->eflags & IF_MASK &&
!(env->hflags & HF_INHIBIT_IRQ_MASK))))) {
return CPU_INTERRUPT_HARD;
-#if !defined(CONFIG_USER_ONLY)
} else if (env->hflags2 & HF2_VGIF_MASK) {
if((interrupt_request & CPU_INTERRUPT_VIRQ) &&
(env->eflags & IF_MASK) &&
!(env->hflags & HF_INHIBIT_IRQ_MASK)) {
return CPU_INTERRUPT_VIRQ;
}
-#endif
}
}
@@ -8304,6 +8301,7 @@ static bool x86_cpu_has_work(CPUState *cs)
{
return x86_cpu_pending_interrupt(cs, cs->interrupt_request) != 0;
}
+#endif /* !CONFIG_USER_ONLY */
int x86_mmu_index_pl(CPUX86State *env, unsigned pl)
{
@@ -8544,6 +8542,7 @@ static const Property x86_cpu_properties[] = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps i386_sysemu_ops = {
+ .has_work = x86_cpu_has_work,
.get_memory_mapping = x86_cpu_get_memory_mapping,
.get_paging_enabled = x86_cpu_get_paging_enabled,
.get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug,
@@ -8577,7 +8576,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
cc->class_by_name = x86_cpu_class_by_name;
cc->parse_features = x86_cpu_parse_featurestr;
- cc->has_work = x86_cpu_has_work;
cc->mmu_index = x86_cpu_mmu_index;
cc->dump_state = x86_cpu_dump_state;
cc->set_pc = x86_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 10/24] target/loongarch: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 09/24] target/i386: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 11/24] target/m68k: " Philippe Mathieu-Daudé
` (15 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/loongarch/cpu.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index d611a604704..20aba0e1fff 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -349,11 +349,9 @@ static void loongarch_restore_state_to_opc(CPUState *cs,
}
#endif /* CONFIG_TCG */
+#ifndef CONFIG_USER_ONLY
static bool loongarch_cpu_has_work(CPUState *cs)
{
-#ifdef CONFIG_USER_ONLY
- return true;
-#else
bool has_work = false;
if ((cs->interrupt_request & CPU_INTERRUPT_HARD) &&
@@ -362,8 +360,8 @@ static bool loongarch_cpu_has_work(CPUState *cs)
}
return has_work;
-#endif
}
+#endif /* !CONFIG_USER_ONLY */
static int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -835,6 +833,7 @@ static const TCGCPUOps loongarch_tcg_ops = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps loongarch_sysemu_ops = {
+ .has_work = loongarch_cpu_has_work,
.write_elf64_note = loongarch_cpu_write_elf64_note,
.get_phys_page_debug = loongarch_cpu_get_phys_page_debug,
};
@@ -860,7 +859,6 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)
&lacc->parent_phases);
cc->class_by_name = loongarch_cpu_class_by_name;
- cc->has_work = loongarch_cpu_has_work;
cc->mmu_index = loongarch_cpu_mmu_index;
cc->dump_state = loongarch_cpu_dump_state;
cc->set_pc = loongarch_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 11/24] target/m68k: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 10/24] target/loongarch: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 12/24] target/microblaze: " Philippe Mathieu-Daudé
` (14 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/m68k/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 41dfdf58045..eb7fb4f7e4c 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -51,10 +51,12 @@ static void m68k_restore_state_to_opc(CPUState *cs,
}
}
+#ifndef CONFIG_USER_ONLY
static bool m68k_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & CPU_INTERRUPT_HARD;
}
+#endif /* !CONFIG_USER_ONLY */
static int m68k_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -543,6 +545,7 @@ static const VMStateDescription vmstate_m68k_cpu = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps m68k_sysemu_ops = {
+ .has_work = m68k_cpu_has_work,
.get_phys_page_debug = m68k_cpu_get_phys_page_debug,
};
#endif /* !CONFIG_USER_ONLY */
@@ -576,7 +579,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
&mcc->parent_phases);
cc->class_by_name = m68k_cpu_class_by_name;
- cc->has_work = m68k_cpu_has_work;
cc->mmu_index = m68k_cpu_mmu_index;
cc->dump_state = m68k_cpu_dump_state;
cc->set_pc = m68k_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 12/24] target/microblaze: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 11/24] target/m68k: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 13/24] target/mips: " Philippe Mathieu-Daudé
` (13 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/microblaze/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index f114789abd8..7a90cb3016b 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -115,10 +115,12 @@ static void mb_restore_state_to_opc(CPUState *cs,
cpu->env.iflags = data[1];
}
+#ifndef CONFIG_USER_ONLY
static bool mb_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
}
+#endif /* !CONFIG_USER_ONLY */
static int mb_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -415,6 +417,7 @@ static ObjectClass *mb_cpu_class_by_name(const char *cpu_model)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps mb_sysemu_ops = {
+ .has_work = mb_cpu_has_work,
.get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug,
};
#endif
@@ -450,7 +453,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)
&mcc->parent_phases);
cc->class_by_name = mb_cpu_class_by_name;
- cc->has_work = mb_cpu_has_work;
cc->mmu_index = mb_cpu_mmu_index;
cc->dump_state = mb_cpu_dump_state;
cc->set_pc = mb_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 13/24] target/mips: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 12/24] target/microblaze: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 14/24] target/openrisc: " Philippe Mathieu-Daudé
` (12 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Move has_work() from CPUClass to SysemuCPUOps and
cpu_mips_hw_interrupts_enabled() to system.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/mips/internal.h | 4 ++--
target/mips/cpu.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/target/mips/internal.h b/target/mips/internal.h
index 91c786cff8a..28eb28936ba 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -162,8 +162,6 @@ void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val);
extern const VMStateDescription vmstate_mips_cpu;
-#endif /* !CONFIG_USER_ONLY */
-
static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env)
{
return (env->CP0_Status & (1 << CP0St_IE)) &&
@@ -206,6 +204,8 @@ static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env)
return r;
}
+#endif /* !CONFIG_USER_ONLY */
+
void msa_reset(CPUMIPSState *env);
/* cp0_timer.c */
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 47cd7cfdcef..0b3ac4e60a3 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -132,6 +132,7 @@ static vaddr mips_cpu_get_pc(CPUState *cs)
return cpu->env.active_tc.PC;
}
+#if !defined(CONFIG_USER_ONLY)
static bool mips_cpu_has_work(CPUState *cs)
{
CPUMIPSState *env = cpu_env(cs);
@@ -177,6 +178,7 @@ static bool mips_cpu_has_work(CPUState *cs)
}
return has_work;
}
+#endif /* !CONFIG_USER_ONLY */
static int mips_cpu_mmu_index(CPUState *cs, bool ifunc)
{
@@ -534,6 +536,7 @@ static ObjectClass *mips_cpu_class_by_name(const char *cpu_model)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps mips_sysemu_ops = {
+ .has_work = mips_cpu_has_work,
.get_phys_page_debug = mips_cpu_get_phys_page_debug,
.legacy_vmsd = &vmstate_mips_cpu,
};
@@ -577,7 +580,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)
&mcc->parent_phases);
cc->class_by_name = mips_cpu_class_by_name;
- cc->has_work = mips_cpu_has_work;
cc->mmu_index = mips_cpu_mmu_index;
cc->dump_state = mips_cpu_dump_state;
cc->set_pc = mips_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 14/24] target/openrisc: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 13/24] target/mips: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 15/24] target/ppc: " Philippe Mathieu-Daudé
` (11 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/openrisc/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
index b7bab0d7abf..5d80c4aa9ac 100644
--- a/target/openrisc/cpu.c
+++ b/target/openrisc/cpu.c
@@ -63,11 +63,13 @@ static void openrisc_restore_state_to_opc(CPUState *cs,
}
}
+#ifndef CONFIG_USER_ONLY
static bool openrisc_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & (CPU_INTERRUPT_HARD |
CPU_INTERRUPT_TIMER);
}
+#endif /* !CONFIG_USER_ONLY */
static int openrisc_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -228,6 +230,7 @@ static void openrisc_any_initfn(Object *obj)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps openrisc_sysemu_ops = {
+ .has_work = openrisc_cpu_has_work,
.get_phys_page_debug = openrisc_cpu_get_phys_page_debug,
};
#endif
@@ -261,7 +264,6 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data)
&occ->parent_phases);
cc->class_by_name = openrisc_cpu_class_by_name;
- cc->has_work = openrisc_cpu_has_work;
cc->mmu_index = openrisc_cpu_mmu_index;
cc->dump_state = openrisc_cpu_dump_state;
cc->set_pc = openrisc_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 15/24] target/ppc: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 14/24] target/openrisc: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 16/24] target/riscv: " Philippe Mathieu-Daudé
` (10 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/ppc/cpu_init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index c05c2dc42dc..081fb5bd343 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7177,10 +7177,12 @@ static void ppc_restore_state_to_opc(CPUState *cs,
}
#endif /* CONFIG_TCG */
+#ifndef CONFIG_USER_ONLY
static bool ppc_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & CPU_INTERRUPT_HARD;
}
+#endif /* !CONFIG_USER_ONLY */
static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -7418,6 +7420,7 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps ppc_sysemu_ops = {
+ .has_work = ppc_cpu_has_work,
.get_phys_page_debug = ppc_cpu_get_phys_page_debug,
.write_elf32_note = ppc32_cpu_write_elf32_note,
.write_elf64_note = ppc64_cpu_write_elf64_note,
@@ -7469,7 +7472,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
&pcc->parent_phases);
cc->class_by_name = ppc_cpu_class_by_name;
- cc->has_work = ppc_cpu_has_work;
cc->mmu_index = ppc_cpu_mmu_index;
cc->dump_state = ppc_cpu_dump_state;
cc->set_pc = ppc_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 16/24] target/riscv: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 15/24] target/ppc: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-26 12:29 ` Richard Henderson
2025-01-25 17:01 ` [PATCH v3 17/24] target/rx: " Philippe Mathieu-Daudé
` (9 subsequent siblings)
25 siblings, 1 reply; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, qemu-riscv
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Cc: qemu-riscv@nongnu.org
---
target/riscv/internals.h | 4 +++-
target/riscv/cpu.c | 8 +++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/target/riscv/internals.h b/target/riscv/internals.h
index 67291933f84..213aff31d85 100644
--- a/target/riscv/internals.h
+++ b/target/riscv/internals.h
@@ -142,8 +142,10 @@ static inline float16 check_nanbox_h(CPURISCVState *env, uint64_t f)
}
}
-/* Our implementation of CPUClass::has_work */
+#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,
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 3d4bd157d2c..4a7e02d9a99 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1010,9 +1010,9 @@ static vaddr riscv_cpu_get_pc(CPUState *cs)
return env->pc;
}
+#ifndef CONFIG_USER_ONLY
bool riscv_cpu_has_work(CPUState *cs)
{
-#ifndef CONFIG_USER_ONLY
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
/*
@@ -1022,10 +1022,8 @@ bool riscv_cpu_has_work(CPUState *cs)
return riscv_cpu_all_pending(env) != 0 ||
riscv_cpu_sirq_pending(env) != RISCV_EXCP_NONE ||
riscv_cpu_vsirq_pending(env) != RISCV_EXCP_NONE;
-#else
- return true;
-#endif
}
+#endif /* !CONFIG_USER_ONLY */
static int riscv_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -2912,6 +2910,7 @@ static int64_t riscv_get_arch_id(CPUState *cs)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps riscv_sysemu_ops = {
+ .has_work = riscv_cpu_has_work,
.get_phys_page_debug = riscv_cpu_get_phys_page_debug,
.write_elf64_note = riscv_cpu_write_elf64_note,
.write_elf32_note = riscv_cpu_write_elf32_note,
@@ -2933,7 +2932,6 @@ static void riscv_cpu_common_class_init(ObjectClass *c, void *data)
&mcc->parent_phases);
cc->class_by_name = riscv_cpu_class_by_name;
- cc->has_work = riscv_cpu_has_work;
cc->mmu_index = riscv_cpu_mmu_index;
cc->dump_state = riscv_cpu_dump_state;
cc->set_pc = riscv_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 17/24] target/rx: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 16/24] target/riscv: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 18/24] target/s390x: Restrict I/O handler installers to system emulation Philippe Mathieu-Daudé
` (8 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/rx/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index aa310bd6144..79b95090e7a 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -187,6 +187,7 @@ static void rx_cpu_init(Object *obj)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps rx_sysemu_ops = {
+ .has_work = rx_cpu_has_work,
.get_phys_page_debug = rx_cpu_get_phys_page_debug,
};
@@ -217,7 +218,6 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data)
&rcc->parent_phases);
cc->class_by_name = rx_cpu_class_by_name;
- cc->has_work = rx_cpu_has_work;
cc->mmu_index = riscv_cpu_mmu_index;
cc->dump_state = rx_cpu_dump_state;
cc->set_pc = rx_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 18/24] target/s390x: Restrict I/O handler installers to system emulation
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 17/24] target/rx: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 19/24] target/s390x: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
` (7 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/s390x/s390x-internal.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h
index a750e7a343a..6e2c98de97a 100644
--- a/target/s390x/s390x-internal.h
+++ b/target/s390x/s390x-internal.h
@@ -356,6 +356,7 @@ void cpu_inject_stop(S390CPU *cpu);
/* ioinst.c */
+#ifndef CONFIG_USER_ONLY
void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
@@ -373,6 +374,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2,
void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
+#endif /* CONFIG_USER_ONLY */
/* mem_helper.c */
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 19/24] target/s390x: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 18/24] target/s390x: Restrict I/O handler installers to system emulation Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 20/24] target/sh4: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Move has_work() from CPUClass to SysemuCPUOps, move
s390_cpu_has_work() to cpu-system.c so it is only build
for system emulation binaries, restrict functions not
used anymore on user emulation in interrupt.c.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/s390x/s390x-internal.h | 3 +++
target/s390x/cpu-system.c | 18 ++++++++++++++++++
target/s390x/cpu.c | 18 ------------------
target/s390x/interrupt.c | 8 ++------
4 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h
index 6e2c98de97a..a4ba6227ab4 100644
--- a/target/s390x/s390x-internal.h
+++ b/target/s390x/s390x-internal.h
@@ -245,6 +245,7 @@ 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);
#else
static inline unsigned int s390_cpu_halt(S390CPU *cpu)
@@ -341,6 +342,7 @@ void cpu_unmap_lowcore(LowCore *lowcore);
/* interrupt.c */
void trigger_pgm_exception(CPUS390XState *env, uint32_t code);
+#ifndef CONFIG_USER_ONLY
void cpu_inject_clock_comparator(S390CPU *cpu);
void cpu_inject_cpu_timer(S390CPU *cpu);
void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr);
@@ -353,6 +355,7 @@ bool s390_cpu_has_restart_int(S390CPU *cpu);
bool s390_cpu_has_stop_int(S390CPU *cpu);
void cpu_inject_restart(S390CPU *cpu);
void cpu_inject_stop(S390CPU *cpu);
+#endif /* CONFIG_USER_ONLY */
/* ioinst.c */
diff --git a/target/s390x/cpu-system.c b/target/s390x/cpu-system.c
index e9f8e7cc72f..9b380e343c2 100644
--- a/target/s390x/cpu-system.c
+++ b/target/s390x/cpu-system.c
@@ -39,6 +39,23 @@
#include "system/tcg.h"
#include "hw/core/sysemu-cpu-ops.h"
+bool s390_cpu_has_work(CPUState *cs)
+{
+ S390CPU *cpu = S390_CPU(cs);
+
+ /* STOPPED cpus can never wake up */
+ if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
+ s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
+ return false;
+ }
+
+ if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
+ return false;
+ }
+
+ return s390_cpu_has_int(cpu);
+}
+
/* S390CPUClass::load_normal() */
static void s390_cpu_load_normal(CPUState *s)
{
@@ -158,6 +175,7 @@ void s390_cpu_finalize(Object *obj)
}
static const struct SysemuCPUOps s390_sysemu_ops = {
+ .has_work = s390_cpu_has_work,
.get_phys_page_debug = s390_cpu_get_phys_page_debug,
.get_crash_info = s390_cpu_get_crash_info,
.write_elf64_note = s390_cpu_write_elf64_note,
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 97d41c23de7..eb2c6650989 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -126,23 +126,6 @@ static vaddr s390_cpu_get_pc(CPUState *cs)
return cpu->env.psw.addr;
}
-static bool s390_cpu_has_work(CPUState *cs)
-{
- S390CPU *cpu = S390_CPU(cs);
-
- /* STOPPED cpus can never wake up */
- if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
- s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
- return false;
- }
-
- if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
- return false;
- }
-
- return s390_cpu_has_int(cpu);
-}
-
static int s390x_cpu_mmu_index(CPUState *cs, bool ifetch)
{
return s390x_env_mmu_index(cpu_env(cs), ifetch);
@@ -394,7 +377,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
&scc->parent_phases);
cc->class_by_name = s390_cpu_class_by_name,
- cc->has_work = s390_cpu_has_work;
cc->mmu_index = s390x_cpu_mmu_index;
cc->dump_state = s390_cpu_dump_state;
cc->query_cpu_fast = s390_query_cpu_fast;
diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c
index d68d8955b1a..4ae6e2ddeaa 100644
--- a/target/s390x/interrupt.c
+++ b/target/s390x/interrupt.c
@@ -30,6 +30,7 @@ void trigger_pgm_exception(CPUS390XState *env, uint32_t code)
/* env->int_pgm_ilen is already set, or will be set during unwinding */
}
+#if !defined(CONFIG_USER_ONLY)
void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra)
{
if (kvm_enabled()) {
@@ -41,7 +42,6 @@ void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra)
}
}
-#if !defined(CONFIG_USER_ONLY)
void cpu_inject_clock_comparator(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
@@ -225,11 +225,9 @@ bool s390_cpu_has_stop_int(S390CPU *cpu)
return env->pending_int & INTERRUPT_STOP;
}
-#endif
bool s390_cpu_has_int(S390CPU *cpu)
{
-#ifndef CONFIG_USER_ONLY
if (!tcg_enabled()) {
return false;
}
@@ -238,7 +236,5 @@ bool s390_cpu_has_int(S390CPU *cpu)
s390_cpu_has_io_int(cpu) ||
s390_cpu_has_restart_int(cpu) ||
s390_cpu_has_stop_int(cpu);
-#else
- return false;
-#endif
}
+#endif /* !CONFIG_USER_ONLY */
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 20/24] target/sh4: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 19/24] target/s390x: Move has_work() from CPUClass to SysemuCPUOps Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 21/24] target/sparc: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sh4/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 24a22724c61..80a66e1f1d6 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -82,12 +82,12 @@ static bool superh_io_recompile_replay_branch(CPUState *cs,
}
return false;
}
-#endif
static bool superh_cpu_has_work(CPUState *cs)
{
return cs->interrupt_request & CPU_INTERRUPT_HARD;
}
+#endif /* !CONFIG_USER_ONLY */
static int sh4_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -243,6 +243,7 @@ static const VMStateDescription vmstate_sh_cpu = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps sh4_sysemu_ops = {
+ .has_work = superh_cpu_has_work,
.get_phys_page_debug = superh_cpu_get_phys_page_debug,
};
#endif
@@ -279,7 +280,6 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)
&scc->parent_phases);
cc->class_by_name = superh_cpu_class_by_name;
- cc->has_work = superh_cpu_has_work;
cc->mmu_index = sh4_cpu_mmu_index;
cc->dump_state = superh_cpu_dump_state;
cc->set_pc = superh_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 21/24] target/sparc: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 20/24] target/sh4: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 22/24] target/tricore: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index fbd38ec334a..94e807f9f84 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -776,11 +776,13 @@ static void sparc_restore_state_to_opc(CPUState *cs,
}
}
+#ifndef CONFIG_USER_ONLY
static bool sparc_cpu_has_work(CPUState *cs)
{
return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_interrupts_enabled(cpu_env(cs));
}
+#endif /* !CONFIG_USER_ONLY */
static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -986,6 +988,7 @@ static const Property sparc_cpu_properties[] = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps sparc_sysemu_ops = {
+ .has_work = sparc_cpu_has_work,
.get_phys_page_debug = sparc_cpu_get_phys_page_debug,
.legacy_vmsd = &vmstate_sparc_cpu,
};
@@ -1027,7 +1030,6 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)
cc->class_by_name = sparc_cpu_class_by_name;
cc->parse_features = sparc_cpu_parse_features;
- cc->has_work = sparc_cpu_has_work;
cc->mmu_index = sparc_cpu_mmu_index;
cc->dump_state = sparc_cpu_dump_state;
#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 22/24] target/tricore: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 21/24] target/sparc: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 23/24] target/xtensa: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/tricore/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index 95202fadbfd..e4f95876efd 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -165,6 +165,7 @@ static bool tricore_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps tricore_sysemu_ops = {
+ .has_work = tricore_cpu_has_work,
.get_phys_page_debug = tricore_cpu_get_phys_page_debug,
};
@@ -193,7 +194,6 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
resettable_class_set_parent_phases(rc, NULL, tricore_cpu_reset_hold, NULL,
&mcc->parent_phases);
cc->class_by_name = tricore_cpu_class_by_name;
- cc->has_work = tricore_cpu_has_work;
cc->mmu_index = tricore_cpu_mmu_index;
cc->gdb_read_register = tricore_cpu_gdb_read_register;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 23/24] target/xtensa: Move has_work() from CPUClass to SysemuCPUOps
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 22/24] target/tricore: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-25 17:01 ` [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler Philippe Mathieu-Daudé
` (2 subsequent siblings)
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
Move has_work() from CPUClass to SysemuCPUOps, simplifying
xtensa_cpu_has_work() by directly using CPU env.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/xtensa/cpu.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 4eb699d1f45..c5d7682f4bf 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -63,16 +63,14 @@ static void xtensa_restore_state_to_opc(CPUState *cs,
cpu->env.pc = data[0];
}
+#ifndef CONFIG_USER_ONLY
static bool xtensa_cpu_has_work(CPUState *cs)
{
-#ifndef CONFIG_USER_ONLY
- XtensaCPU *cpu = XTENSA_CPU(cs);
+ CPUXtensaState *env = cpu_env(cs);
- return !cpu->env.runstall && cpu->env.pending_irq_level;
-#else
- return true;
-#endif
+ return !env->runstall && env->pending_irq_level;
}
+#endif /* !CONFIG_USER_ONLY */
static int xtensa_cpu_mmu_index(CPUState *cs, bool ifetch)
{
@@ -224,6 +222,7 @@ static const VMStateDescription vmstate_xtensa_cpu = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps xtensa_sysemu_ops = {
+ .has_work = xtensa_cpu_has_work,
.get_phys_page_debug = xtensa_cpu_get_phys_page_debug,
};
#endif
@@ -261,7 +260,6 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
&xcc->parent_phases);
cc->class_by_name = xtensa_cpu_class_by_name;
- cc->has_work = xtensa_cpu_has_work;
cc->mmu_index = xtensa_cpu_mmu_index;
cc->dump_state = xtensa_cpu_dump_state;
cc->set_pc = xtensa_cpu_set_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 23/24] target/xtensa: " Philippe Mathieu-Daudé
@ 2025-01-25 17:01 ` Philippe Mathieu-Daudé
2025-01-26 12:31 ` Richard Henderson
2025-02-10 21:57 ` [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
2025-03-09 13:38 ` Philippe Mathieu-Daudé
25 siblings, 1 reply; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-25 17:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé
All handlers have been converted to SysemuCPUOps::has_work().
Remove CPUClass::has_work along with cpu_common_has_work()
and simplify cpu_has_work(), making SysemuCPUOps::has_work
handler mandatory.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/cpu.h | 3 +--
include/hw/core/sysemu-cpu-ops.h | 2 +-
cpu-target.c | 8 ++++++++
hw/core/cpu-common.c | 12 ++++++------
hw/core/cpu-system.c | 7 +------
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index d64c823e768..42795f12290 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -104,7 +104,6 @@ struct SysemuCPUOps;
* instantiatable CPU type.
* @parse_features: Callback to parse command line arguments.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
- * @has_work: Callback for checking if there is work to do.
* @mmu_index: Callback for choosing softmmu mmu index;
* may be used internally by memory_rw_debug without TCG.
* @memory_rw_debug: Callback for GDB memory access.
@@ -151,7 +150,6 @@ struct CPUClass {
ObjectClass *(*class_by_name)(const char *cpu_model);
void (*parse_features)(const char *typename, char *str, Error **errp);
- bool (*has_work)(CPUState *cpu);
int (*mmu_index)(CPUState *cpu, bool ifetch);
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
uint8_t *buf, int len, bool is_write);
@@ -1154,6 +1152,7 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
/* $(top_srcdir)/cpu.c */
void cpu_class_init_props(DeviceClass *dc);
+void cpu_exec_class_post_init(CPUClass *cc, void *data);
void cpu_exec_initfn(CPUState *cpu);
bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h
index dee8a62ca98..877892373f9 100644
--- a/include/hw/core/sysemu-cpu-ops.h
+++ b/include/hw/core/sysemu-cpu-ops.h
@@ -19,7 +19,7 @@ typedef struct SysemuCPUOps {
/**
* @has_work: Callback for checking if there is work to do.
*/
- bool (*has_work)(CPUState *cpu);
+ bool (*has_work)(CPUState *cpu); /* MANDATORY NON-NULL */
/**
* @get_memory_mapping: Callback for obtaining the memory mappings.
*/
diff --git a/cpu-target.c b/cpu-target.c
index 98e9e7cc4a1..778f622b07a 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -230,6 +230,14 @@ void cpu_class_init_props(DeviceClass *dc)
device_class_set_props(dc, cpu_common_props);
}
+void cpu_exec_class_post_init(CPUClass *cc, void *data)
+{
+#ifndef CONFIG_USER_ONLY
+ /* Check mandatory SysemuCPUOps handlers */
+ g_assert(cc->sysemu_ops->has_work);
+#endif
+}
+
void cpu_exec_initfn(CPUState *cpu)
{
cpu->as = NULL;
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 886aa793c04..eae621f942f 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -134,11 +134,6 @@ static void cpu_common_reset_hold(Object *obj, ResetType type)
cpu_exec_reset_hold(cpu);
}
-static bool cpu_common_has_work(CPUState *cs)
-{
- return false;
-}
-
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
{
ObjectClass *oc;
@@ -304,7 +299,6 @@ static void cpu_common_class_init(ObjectClass *klass, void *data)
k->parse_features = cpu_common_parse_features;
k->get_arch_id = cpu_common_get_arch_id;
- k->has_work = cpu_common_has_work;
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
@@ -319,6 +313,11 @@ static void cpu_common_class_init(ObjectClass *klass, void *data)
dc->user_creatable = false;
}
+static void cpu_common_post_class_init(ObjectClass *klass, void *data)
+{
+ cpu_exec_class_post_init(CPU_CLASS(klass), data);
+}
+
static const TypeInfo cpu_type_info = {
.name = TYPE_CPU,
.parent = TYPE_DEVICE,
@@ -328,6 +327,7 @@ static const TypeInfo cpu_type_info = {
.abstract = true,
.class_size = sizeof(CPUClass),
.class_init = cpu_common_class_init,
+ .class_post_init = cpu_common_post_class_init,
};
static void cpu_register_types(void)
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 7b16bda2250..32d09757169 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -25,12 +25,7 @@
bool cpu_has_work(CPUState *cpu)
{
- if (cpu->cc->sysemu_ops->has_work) {
- return cpu->cc->sysemu_ops->has_work(cpu);
- }
-
- g_assert(cpu->cc->has_work);
- return cpu->cc->has_work(cpu);
+ return cpu->cc->sysemu_ops->has_work(cpu);
}
bool cpu_paging_enabled(const CPUState *cpu)
--
2.47.1
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler
2025-01-25 17:01 ` [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler Philippe Mathieu-Daudé
@ 2025-01-26 12:31 ` Richard Henderson
2025-01-27 7:50 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 32+ messages in thread
From: Richard Henderson @ 2025-01-26 12:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 1/25/25 09:01, Philippe Mathieu-Daudé wrote:
> diff --git a/cpu-target.c b/cpu-target.c
> index 98e9e7cc4a1..778f622b07a 100644
> --- a/cpu-target.c
> +++ b/cpu-target.c
> @@ -230,6 +230,14 @@ void cpu_class_init_props(DeviceClass *dc)
> device_class_set_props(dc, cpu_common_props);
> }
>
> +void cpu_exec_class_post_init(CPUClass *cc, void *data)
> +{
> +#ifndef CONFIG_USER_ONLY
> + /* Check mandatory SysemuCPUOps handlers */
> + g_assert(cc->sysemu_ops->has_work);
> +#endif
> +}
> +
Does this really need to be split from...
> @@ -319,6 +313,11 @@ static void cpu_common_class_init(ObjectClass *klass, void *data)
> dc->user_creatable = false;
> }
>
> +static void cpu_common_post_class_init(ObjectClass *klass, void *data)
> +{
> + cpu_exec_class_post_init(CPU_CLASS(klass), data);
> +}
... here?
r~
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler
2025-01-26 12:31 ` Richard Henderson
@ 2025-01-27 7:50 ` Philippe Mathieu-Daudé
2025-02-10 21:36 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 7:50 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 26/1/25 13:31, Richard Henderson wrote:
> On 1/25/25 09:01, Philippe Mathieu-Daudé wrote:
>> diff --git a/cpu-target.c b/cpu-target.c
>> index 98e9e7cc4a1..778f622b07a 100644
>> --- a/cpu-target.c
>> +++ b/cpu-target.c
>> @@ -230,6 +230,14 @@ void cpu_class_init_props(DeviceClass *dc)
>> device_class_set_props(dc, cpu_common_props);
>> }
>> +void cpu_exec_class_post_init(CPUClass *cc, void *data)
>> +{
>> +#ifndef CONFIG_USER_ONLY
>> + /* Check mandatory SysemuCPUOps handlers */
>> + g_assert(cc->sysemu_ops->has_work);
>> +#endif
>> +}
>> +
>
> Does this really need to be split from...
>
> diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
>
>> @@ -319,6 +313,11 @@ static void cpu_common_class_init(ObjectClass
>> *klass, void *data)
>> dc->user_creatable = false;
>> }
>> +static void cpu_common_post_class_init(ObjectClass *klass, void *data)
>> +{
>> + cpu_exec_class_post_init(CPU_CLASS(klass), data);
>> +}
>
> ... here?
cpu-target.c is in specific_ss[], cpu-common.c in common_ss[]
where CONFIG_USER_ONLY is not available thus defined.
We could define cpu_common_post_class_init() in cpu-target.c,
which is odd because not common; or name it differently
(cpu_exec_post_class_init?) and have it registered as common
post_init handler but again it seems a dirty API mismatch, so
I went this way, hoping that eventually cpu-common.c ends
better abstracted and cpu-target.c disappearing...
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler
2025-01-27 7:50 ` Philippe Mathieu-Daudé
@ 2025-02-10 21:36 ` Philippe Mathieu-Daudé
2025-02-10 21:38 ` Richard Henderson
0 siblings, 1 reply; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-10 21:36 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 27/1/25 08:50, Philippe Mathieu-Daudé wrote:
> On 26/1/25 13:31, Richard Henderson wrote:
>> On 1/25/25 09:01, Philippe Mathieu-Daudé wrote:
>>> diff --git a/cpu-target.c b/cpu-target.c
>>> index 98e9e7cc4a1..778f622b07a 100644
>>> --- a/cpu-target.c
>>> +++ b/cpu-target.c
>>> @@ -230,6 +230,14 @@ void cpu_class_init_props(DeviceClass *dc)
>>> device_class_set_props(dc, cpu_common_props);
>>> }
>>> +void cpu_exec_class_post_init(CPUClass *cc, void *data)
>>> +{
>>> +#ifndef CONFIG_USER_ONLY
>>> + /* Check mandatory SysemuCPUOps handlers */
>>> + g_assert(cc->sysemu_ops->has_work);
>>> +#endif
>>> +}
>>> +
>>
>> Does this really need to be split from...
>>
>
> > diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
> >
>>> @@ -319,6 +313,11 @@ static void cpu_common_class_init(ObjectClass
>>> *klass, void *data)
>>> dc->user_creatable = false;
>>> }
>>> +static void cpu_common_post_class_init(ObjectClass *klass, void *data)
>>> +{
>>> + cpu_exec_class_post_init(CPU_CLASS(klass), data);
>>> +}
>>
>> ... here?
>
> cpu-target.c is in specific_ss[], cpu-common.c in common_ss[]
> where CONFIG_USER_ONLY is not available thus defined.
>
> We could define cpu_common_post_class_init() in cpu-target.c,
> which is odd because not common; or name it differently
> (cpu_exec_post_class_init?) and have it registered as common
> post_init handler but again it seems a dirty API mismatch, so
> I went this way, hoping that eventually cpu-common.c ends
> better abstracted and cpu-target.c disappearing...
I'll amend to the description:
---
Note, since cpu-common.c is in meson's common_ss[] source set, we
must define cpu_exec_class_post_init() in cpu-target.c (which is
in the specific_ss[] source set) to have CONFIG_USER_ONLY defined.
---
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2025-01-25 17:01 ` [PATCH v3 24/24] cpus: Remove CPUClass::has_work() handler Philippe Mathieu-Daudé
@ 2025-02-10 21:57 ` Philippe Mathieu-Daudé
2025-03-09 13:38 ` Philippe Mathieu-Daudé
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-10 21:57 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
On 25/1/25 18:01, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (24):
> cpus: Restrict cpu_has_work() to system emulation
> cpus: Un-inline cpu_has_work()
> cpus: Introduce SysemuCPUOps::has_work() handler
> target/alpha: Move has_work() from CPUClass to SysemuCPUOps
> target/arm: Move has_work() from CPUClass to SysemuCPUOps
> target/avr: Move has_work() from CPUClass to SysemuCPUOps
> target/hexagon: Remove CPUClass:has_work() handler
> target/hppa: Move has_work() from CPUClass to SysemuCPUOps
> target/i386: Move has_work() from CPUClass to SysemuCPUOps
> target/loongarch: Move has_work() from CPUClass to SysemuCPUOps
> target/m68k: Move has_work() from CPUClass to SysemuCPUOps
> target/microblaze: Move has_work() from CPUClass to SysemuCPUOps
> target/mips: Move has_work() from CPUClass to SysemuCPUOps
> target/openrisc: Move has_work() from CPUClass to SysemuCPUOps
> target/ppc: Move has_work() from CPUClass to SysemuCPUOps
> target/riscv: Move has_work() from CPUClass to SysemuCPUOps
> target/rx: Move has_work() from CPUClass to SysemuCPUOps
> target/s390x: Restrict I/O handler installers to system emulation
> target/s390x: Move has_work() from CPUClass to SysemuCPUOps
> target/sh4: Move has_work() from CPUClass to SysemuCPUOps
> target/sparc: Move has_work() from CPUClass to SysemuCPUOps
> target/tricore: Move has_work() from CPUClass to SysemuCPUOps
> target/xtensa: Move has_work() from CPUClass to SysemuCPUOps
> cpus: Remove CPUClass::has_work() handler
Series queued with patch #24 description expanded, thanks.
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation
2025-01-25 17:01 [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2025-02-10 21:57 ` [PATCH v3 00/24] cpus: Restrict CPU has_work() handlers to system emulation Philippe Mathieu-Daudé
@ 2025-03-09 13:38 ` Philippe Mathieu-Daudé
25 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-09 13:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
On 25/1/25 18:01, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (24):
> cpus: Restrict cpu_has_work() to system emulation
> cpus: Un-inline cpu_has_work()
> cpus: Introduce SysemuCPUOps::has_work() handler
> target/alpha: Move has_work() from CPUClass to SysemuCPUOps
> target/arm: Move has_work() from CPUClass to SysemuCPUOps
> target/avr: Move has_work() from CPUClass to SysemuCPUOps
> target/hexagon: Remove CPUClass:has_work() handler
> target/hppa: Move has_work() from CPUClass to SysemuCPUOps
> target/i386: Move has_work() from CPUClass to SysemuCPUOps
> target/loongarch: Move has_work() from CPUClass to SysemuCPUOps
> target/m68k: Move has_work() from CPUClass to SysemuCPUOps
> target/microblaze: Move has_work() from CPUClass to SysemuCPUOps
> target/mips: Move has_work() from CPUClass to SysemuCPUOps
> target/openrisc: Move has_work() from CPUClass to SysemuCPUOps
> target/ppc: Move has_work() from CPUClass to SysemuCPUOps
> target/riscv: Move has_work() from CPUClass to SysemuCPUOps
> target/rx: Move has_work() from CPUClass to SysemuCPUOps
> target/s390x: Restrict I/O handler installers to system emulation
> target/s390x: Move has_work() from CPUClass to SysemuCPUOps
> target/sh4: Move has_work() from CPUClass to SysemuCPUOps
> target/sparc: Move has_work() from CPUClass to SysemuCPUOps
> target/tricore: Move has_work() from CPUClass to SysemuCPUOps
> target/xtensa: Move has_work() from CPUClass to SysemuCPUOps
> cpus: Remove CPUClass::has_work() handler
Series queued, thanks.
^ permalink raw reply [flat|nested] 32+ messages in thread