All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass
@ 2021-09-25 14:50 Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 01/40] accel: Simplify qemu_init_vcpu() Philippe Mathieu-Daudé
                   ` (40 more replies)
  0 siblings, 41 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé

Hi,

CPU has_work() is a per-accelerator handler. This series is organized
in 2 parts:
- Patches 1-15: Move has_work() from CPUClass to AccelOpsClass
- Patches 16-40: Move remainging has_work() to TCGCPUOps

I prefer to send as a single big series to be sure it is merged
at once, since the 2nd part logic (TCGCPUOps) is related to the
end of the first part (we proved remaining CPUClass::has_work
handlers are TCG specific, thus can be moved to TCGCPUOps).

Missing review:
0001-accel-Simplify-qemu_init_vcpu.patch
0004-hw-core-Move-cpu_common_has_work-to-cpu_has_work.patch
0005-accel-Introduce-AccelOpsClass-has_work.patch
0008-accel-hvf-Implement-AccelOpsClass-has_work.patch
0009-accel-xen-Implement-AccelOpsClass-has_work.patch
0010-accel-hax-Implement-AccelOpsClass-has_work.patch
0011-accel-nvmm-Implement-AccelOpsClass-has_work.patch
0012-accel-qtest-Implement-AccelOpsClass-has_work.patch
0013-accel-tcg-Implement-AccelOpsClass-has_work.patch
0014-accel-Simplify-cpu_has_work.patch
0015-accel-tcg-Introduce-TCGCPUOps-has_work.patch
0016-target-arm-Explicit-v7M-cores-use-arm_cpu_has_work-a.patch
0017-target-arm-Restrict-has_work-handler-to-sysemu-and-T.patch
0018-target-alpha-Restrict-has_work-handler-to-sysemu.patch
0039-accel-tcg-Remove-CPUClass-has_work.patch
0040-accel-tcg-Simplify-tcg_cpu_has_work.patch

Since v6:
- Added missing target/alpha/ patch
- Updated comment in qemu_s390_flic_has_service()

Since v5:
- Rework ARM v7M case (pm215)
- Reorder patch logic (rth)

Since v4:
- Implement arm_v7m_cpu_has_work() (new patch)
- Assert has_work() handlers are set, don't use default value
- Fix ARM v7M and cris CPUs
- Reset R-b tags on modified patches

Since v3:
- Remove pointless CONFIG_TCG uses (rth)
- Rework PPC patches, still using indirection

Since v2:
- Full rewrite, no more RFC.

Supersedes: <20210920214447.2998623-1-f4bug@amsat.org>

Philippe Mathieu-Daudé (40):
  accel: Simplify qemu_init_vcpu()
  hw/core: Restrict cpu_has_work() to sysemu
  hw/core: Un-inline cpu_has_work()
  hw/core: Move cpu_common_has_work() to cpu_has_work()
  accel: Introduce AccelOpsClass::has_work()
  accel/kvm: Implement AccelOpsClass::has_work()
  accel/whpx: Implement AccelOpsClass::has_work()
  accel/hvf: Implement AccelOpsClass::has_work()
  accel/xen: Implement AccelOpsClass::has_work()
  accel/hax: Implement AccelOpsClass::has_work()
  accel/nvmm: Implement AccelOpsClass::has_work()
  accel/qtest: Implement AccelOpsClass::has_work()
  accel/tcg: Implement AccelOpsClass::has_work()
  accel: Simplify cpu_has_work()
  accel/tcg: Introduce TCGCPUOps::has_work()
  target/arm: Explicit v7M cores use arm_cpu_has_work as
    CPUClass:has_work
  target/arm: Restrict has_work() handler to sysemu and TCG
  target/alpha: Restrict has_work() handler to sysemu
  target/avr: Restrict has_work() handler to sysemu
  target/cris: Restrict has_work() handler to sysemu
  target/hexagon: Remove unused has_work() handler
  target/hppa: Restrict has_work() handler to sysemu
  target/i386: Restrict has_work() handler to sysemu and TCG
  target/m68k: Restrict has_work() handler to sysemu
  target/microblaze: Restrict has_work() handler to sysemu
  target/mips: Restrict has_work() handler to sysemu and TCG
  target/nios2: Restrict has_work() handler to sysemu
  target/openrisc: Restrict has_work() handler to sysemu
  target/ppc: Introduce PowerPCCPUClass::has_work()
  target/ppc: Restrict has_work() handlers to sysemu and TCG
  target/riscv: Restrict has_work() handler to sysemu and TCG
  target/rx: Restrict has_work() handler to sysemu
  target/s390x: Restrict has_work() handler to sysemu and TCG
  target/sh4: Restrict has_work() handler to sysemu
  target/sparc: Remove pointless use of CONFIG_TCG definition
  target/sparc: Restrict has_work() handler to sysemu
  target/tricore: Restrict has_work() handler to sysemu
  target/xtensa: Restrict has_work() handler to sysemu
  accel/tcg: Remove CPUClass::has_work()
  accel/tcg: Simplify tcg_cpu_has_work()

 include/hw/core/cpu.h             | 28 +++++++++--------------
 include/hw/core/tcg-cpu-ops.h     |  4 ++++
 include/sysemu/accel-ops.h        |  5 +++++
 target/arm/internals.h            |  4 ++++
 target/ppc/cpu-qom.h              |  3 +++
 accel/hvf/hvf-accel-ops.c         |  6 +++++
 accel/kvm/kvm-accel-ops.c         |  6 +++++
 accel/qtest/qtest.c               |  6 +++++
 accel/tcg/cpu-exec.c              |  6 +++++
 accel/tcg/tcg-accel-ops.c         |  9 ++++++++
 accel/xen/xen-all.c               |  6 +++++
 hw/core/cpu-common.c              |  6 -----
 hw/intc/s390_flic.c               | 15 ++++++++++---
 softmmu/cpus.c                    | 17 +++++++++-----
 target/alpha/cpu.c                |  4 +++-
 target/arm/cpu.c                  |  9 +++++---
 target/arm/cpu_tcg.c              |  1 +
 target/avr/cpu.c                  |  2 +-
 target/cris/cpu.c                 |  5 ++++-
 target/hexagon/cpu.c              |  6 -----
 target/hppa/cpu.c                 |  4 +++-
 target/i386/cpu.c                 |  6 -----
 target/i386/hax/hax-accel-ops.c   |  6 +++++
 target/i386/nvmm/nvmm-accel-ops.c |  6 +++++
 target/i386/tcg/tcg-cpu.c         |  8 ++++++-
 target/i386/whpx/whpx-accel-ops.c |  6 +++++
 target/m68k/cpu.c                 |  4 +++-
 target/microblaze/cpu.c           |  8 +++----
 target/mips/cpu.c                 |  4 +++-
 target/nios2/cpu.c                |  4 +++-
 target/openrisc/cpu.c             |  4 +++-
 target/ppc/cpu_init.c             | 37 ++++++++++++++++++++++---------
 target/riscv/cpu.c                |  8 +++----
 target/rx/cpu.c                   |  4 +++-
 target/s390x/cpu.c                |  4 +++-
 target/sh4/cpu.c                  |  5 +++--
 target/sparc/cpu.c                |  6 ++---
 target/tricore/cpu.c              |  6 ++++-
 target/xtensa/cpu.c               | 14 ++++++------
 39 files changed, 202 insertions(+), 90 deletions(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 51+ messages in thread

* [PATCH v7 01/40] accel: Simplify qemu_init_vcpu()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 15:25   ` Richard Henderson
  2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
                   ` (39 subsequent siblings)
  40 siblings, 1 reply; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

cpus_register_accel() already checks for ops->create_vcpu_thread
being non-NULL, so it is pointless to re-check for it in
qemu_init_vcpu().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 softmmu/cpus.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 071085f840b..646326b24fd 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -604,7 +604,10 @@ void cpu_remove_sync(CPUState *cpu)
 void cpus_register_accel(const AccelOpsClass *ops)
 {
     assert(ops != NULL);
-    assert(ops->create_vcpu_thread != NULL); /* mandatory */
+
+    /* Mandatory non-NULL handlers */
+    assert(ops->create_vcpu_thread != NULL);
+
     cpus_accel = ops;
 }
 
@@ -626,7 +629,7 @@ void qemu_init_vcpu(CPUState *cpu)
     }
 
     /* accelerators all implement the AccelOpsClass */
-    g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL);
+    g_assert(cpus_accel != NULL);
     cpus_accel->create_vcpu_thread(cpu);
 
     while (!cpu->created) {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 01/40] accel: Simplify qemu_init_vcpu() Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 03/40] hw/core: Un-inline cpu_has_work() Philippe Mathieu-Daudé
                   ` (38 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Philippe Mathieu-Daudé, Eduardo Habkost

cpu_has_work() is only called from system emulation code.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index bc864564cee..2bd563e221f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -538,6 +538,22 @@ enum CPUDumpFlags {
 void cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 
 #ifndef CONFIG_USER_ONLY
+/**
+ * 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)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    g_assert(cc->has_work);
+    return cc->has_work(cpu);
+}
+
 /**
  * cpu_get_phys_page_attrs_debug:
  * @cpu: The CPU to obtain the physical page address for.
@@ -636,22 +652,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)
-{
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    g_assert(cc->has_work);
-    return cc->has_work(cpu);
-}
-
 /**
  * qemu_cpu_is_self:
  * @cpu: The vCPU to check against.
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 03/40] hw/core: Un-inline cpu_has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 01/40] accel: Simplify qemu_init_vcpu() Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 04/40] hw/core: Move cpu_common_has_work() to cpu_has_work() Philippe Mathieu-Daudé
                   ` (37 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé,
	Eduardo Habkost

We want to make cpu_has_work() per-accelerator. Only declare its
prototype and move its definition to softmmu/cpus.c.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h | 8 +-------
 softmmu/cpus.c        | 8 ++++++++
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 2bd563e221f..e2dd171a13f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -546,13 +546,7 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags);
  *
  * Returns: %true if the CPU has work, %false otherwise.
  */
-static inline bool cpu_has_work(CPUState *cpu)
-{
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    g_assert(cc->has_work);
-    return cc->has_work(cpu);
-}
+bool cpu_has_work(CPUState *cpu);
 
 /**
  * cpu_get_phys_page_attrs_debug:
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 646326b24fd..6a05860f7fe 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -251,6 +251,14 @@ void cpu_interrupt(CPUState *cpu, int mask)
     }
 }
 
+bool cpu_has_work(CPUState *cpu)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    g_assert(cc->has_work);
+    return cc->has_work(cpu);
+}
+
 static int do_vm_stop(RunState state, bool send_stop)
 {
     int ret = 0;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 04/40] hw/core: Move cpu_common_has_work() to cpu_has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 03/40] hw/core: Un-inline cpu_has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 05/40] accel: Introduce AccelOpsClass::has_work() Philippe Mathieu-Daudé
                   ` (36 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

cpu_class_init() always register cpu_common_has_work() as
CPUClass::has_work() handler, so the assertion check in
cpu_has_work() is pointless.
Since cpu_common_has_work() simply returns 'false', we can
inline it in cpu_has_work(), improving the function readability.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/core/cpu-common.c | 6 ------
 softmmu/cpus.c       | 6 ++++--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index e2f5a646046..5ed1ccdfdd5 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -143,11 +143,6 @@ static void cpu_common_reset(DeviceState *dev)
     }
 }
 
-static bool cpu_common_has_work(CPUState *cs)
-{
-    return false;
-}
-
 ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
 {
     CPUClass *cc = CPU_CLASS(object_class_by_name(typename));
@@ -279,7 +274,6 @@ static void cpu_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);
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 6a05860f7fe..accb20f0589 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -255,8 +255,10 @@ bool cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
-    g_assert(cc->has_work);
-    return cc->has_work(cpu);
+    if (cc->has_work && cc->has_work(cpu)) {
+        return true;
+    }
+    return false;
 }
 
 static int do_vm_stop(RunState state, bool send_stop)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 05/40] accel: Introduce AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 04/40] hw/core: Move cpu_common_has_work() to cpu_has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50   ` Philippe Mathieu-Daudé
                   ` (35 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

Introduce an accelerator-specific has_work() handler.
Eventually call it from cpu_has_work().

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/accel-ops.h | 5 +++++
 softmmu/cpus.c             | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 032f6979d76..de83f095f20 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -31,6 +31,11 @@ struct AccelOpsClass {
     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
     void (*kick_vcpu_thread)(CPUState *cpu);
 
+    /**
+     * @has_work: Callback for checking if there is work to do.
+     */
+    bool (*has_work)(CPUState *cpu);
+
     void (*synchronize_post_reset)(CPUState *cpu);
     void (*synchronize_post_init)(CPUState *cpu);
     void (*synchronize_state)(CPUState *cpu);
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index accb20f0589..85b06d3e685 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -258,6 +258,9 @@ bool cpu_has_work(CPUState *cpu)
     if (cc->has_work && cc->has_work(cpu)) {
         return true;
     }
+    if (cpus_accel->has_work && cpus_accel->has_work(cpu)) {
+        return true;
+    }
     return false;
 }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 06/40] accel/kvm: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
@ 2021-09-25 14:50   ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Philippe Mathieu-Daudé,
	Paolo Bonzini, open list:Overall KVM CPUs

Implement KVM has_work() handler in AccelOpsClass and
remove it from cpu_thread_is_idle() since cpu_has_work()
is already called.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/kvm/kvm-accel-ops.c | 6 ++++++
 softmmu/cpus.c            | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 7516c67a3f5..6f4d5df3a0d 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -74,6 +74,11 @@ static void kvm_start_vcpu_thread(CPUState *cpu)
                        cpu, QEMU_THREAD_JOINABLE);
 }
 
+static bool kvm_cpu_has_work(CPUState *cpu)
+{
+    return kvm_halt_in_kernel();
+}
+
 static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -83,6 +88,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
     ops->synchronize_state = kvm_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
+    ops->has_work = kvm_cpu_has_work;
 }
 
 static const TypeInfo kvm_accel_ops_type = {
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 85b06d3e685..c9f54a09989 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -90,7 +90,7 @@ bool cpu_thread_is_idle(CPUState *cpu)
         return true;
     }
     if (!cpu->halted || cpu_has_work(cpu) ||
-        kvm_halt_in_kernel() || whpx_apic_in_platform()) {
+        whpx_apic_in_platform()) {
         return false;
     }
     return true;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 06/40] accel/kvm: Implement AccelOpsClass::has_work()
@ 2021-09-25 14:50   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé,
	open list:Overall KVM CPUs

Implement KVM has_work() handler in AccelOpsClass and
remove it from cpu_thread_is_idle() since cpu_has_work()
is already called.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/kvm/kvm-accel-ops.c | 6 ++++++
 softmmu/cpus.c            | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 7516c67a3f5..6f4d5df3a0d 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -74,6 +74,11 @@ static void kvm_start_vcpu_thread(CPUState *cpu)
                        cpu, QEMU_THREAD_JOINABLE);
 }
 
+static bool kvm_cpu_has_work(CPUState *cpu)
+{
+    return kvm_halt_in_kernel();
+}
+
 static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -83,6 +88,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
     ops->synchronize_state = kvm_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
+    ops->has_work = kvm_cpu_has_work;
 }
 
 static const TypeInfo kvm_accel_ops_type = {
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 85b06d3e685..c9f54a09989 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -90,7 +90,7 @@ bool cpu_thread_is_idle(CPUState *cpu)
         return true;
     }
     if (!cpu->halted || cpu_has_work(cpu) ||
-        kvm_halt_in_kernel() || whpx_apic_in_platform()) {
+        whpx_apic_in_platform()) {
         return false;
     }
     return true;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 07/40] accel/whpx: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2021-09-25 14:50   ` Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 08/40] accel/hvf: " Philippe Mathieu-Daudé
                   ` (33 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Sunil Muthuswamy, Richard Henderson,
	Philippe Mathieu-Daudé

Implement WHPX has_work() handler in AccelOpsClass and
remove it from cpu_thread_is_idle() since cpu_has_work()
is already called.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 softmmu/cpus.c                    | 4 +---
 target/i386/whpx/whpx-accel-ops.c | 6 ++++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index c9f54a09989..5ffa02f9cef 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -41,7 +41,6 @@
 #include "sysemu/replay.h"
 #include "sysemu/runstate.h"
 #include "sysemu/cpu-timers.h"
-#include "sysemu/whpx.h"
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "trace.h"
@@ -89,8 +88,7 @@ bool cpu_thread_is_idle(CPUState *cpu)
     if (cpu_is_stopped(cpu)) {
         return true;
     }
-    if (!cpu->halted || cpu_has_work(cpu) ||
-        whpx_apic_in_platform()) {
+    if (!cpu->halted || cpu_has_work(cpu)) {
         return false;
     }
     return true;
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 6bc47c53098..1f9c6d52c27 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -83,6 +83,11 @@ static void whpx_kick_vcpu_thread(CPUState *cpu)
     }
 }
 
+static bool whpx_cpu_has_work(CPUState *cpu)
+{
+    return whpx_apic_in_platform();
+}
+
 static void whpx_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -94,6 +99,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
     ops->synchronize_state = whpx_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
+    ops->has_work = whpx_cpu_has_work;
 }
 
 static const TypeInfo whpx_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 08/40] accel/hvf: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 07/40] accel/whpx: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50   ` Philippe Mathieu-Daudé
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bolshakov, Richard Henderson, Philippe Mathieu-Daudé,
	Cameron Esfahani

Since there is no specific HVF handling for cpu_has_work() in
cpu_thread_is_idle(), implement HVF has_work() handler as a
simple 'return false' code.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/hvf/hvf-accel-ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 93976f4ecea..ba7d4f20a35 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -454,6 +454,11 @@ static void hvf_start_vcpu_thread(CPUState *cpu)
                        cpu, QEMU_THREAD_JOINABLE);
 }
 
+static bool hvf_cpu_has_work(CPUState *cpu)
+{
+    return false;
+}
+
 static void hvf_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -465,6 +470,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = hvf_cpu_synchronize_post_init;
     ops->synchronize_state = hvf_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = hvf_cpu_synchronize_pre_loadvm;
+    ops->has_work = hvf_cpu_has_work;
 };
 static const TypeInfo hvf_accel_ops_type = {
     .name = ACCEL_OPS_NAME("hvf"),
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 09/40] accel/xen: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
@ 2021-09-25 14:50   ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Philippe Mathieu-Daudé,
	Paul Durrant, Stefano Stabellini, Anthony Perard,
	open list:X86 Xen CPUs

Since there is no specific Xen handling for cpu_has_work() in
cpu_thread_is_idle(), implement Xen has_work() handler as a
simple 'return false' code.

Acked-by: Paul Durrant <paul@xen.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/xen/xen-all.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 69aa7d018b2..fe5a37fa2e6 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -215,11 +215,17 @@ static const TypeInfo xen_accel_type = {
     .class_init = xen_accel_class_init,
 };
 
+static bool xen_cpu_has_work(CPUState *cpu)
+{
+    return false;
+}
+
 static void xen_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
 
     ops->create_vcpu_thread = dummy_start_vcpu_thread;
+    ops->has_work = xen_cpu_has_work;
 }
 
 static const TypeInfo xen_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 09/40] accel/xen: Implement AccelOpsClass::has_work()
@ 2021-09-25 14:50   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefano Stabellini, Paul Durrant, Richard Henderson,
	Philippe Mathieu-Daudé,
	Anthony Perard, open list:X86 Xen CPUs

Since there is no specific Xen handling for cpu_has_work() in
cpu_thread_is_idle(), implement Xen has_work() handler as a
simple 'return false' code.

Acked-by: Paul Durrant <paul@xen.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/xen/xen-all.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 69aa7d018b2..fe5a37fa2e6 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -215,11 +215,17 @@ static const TypeInfo xen_accel_type = {
     .class_init = xen_accel_class_init,
 };
 
+static bool xen_cpu_has_work(CPUState *cpu)
+{
+    return false;
+}
+
 static void xen_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
 
     ops->create_vcpu_thread = dummy_start_vcpu_thread;
+    ops->has_work = xen_cpu_has_work;
 }
 
 static const TypeInfo xen_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 10/40] accel/hax: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2021-09-25 14:50   ` Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 11/40] accel/nvmm: " Philippe Mathieu-Daudé
                   ` (30 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: open list:X86 HAXM CPUs, Richard Henderson,
	Philippe Mathieu-Daudé,
	Colin Xu, Wenchao Wang

Since there is no specific HAX handling for cpu_has_work() in
cpu_thread_is_idle(), implement HAX has_work() handler as a
simple 'return false' code.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/hax/hax-accel-ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c
index 136630e9b23..5407ba17eaf 100644
--- a/target/i386/hax/hax-accel-ops.c
+++ b/target/i386/hax/hax-accel-ops.c
@@ -74,6 +74,11 @@ static void hax_start_vcpu_thread(CPUState *cpu)
 #endif
 }
 
+static bool hax_cpu_has_work(CPUState *cpu)
+{
+    return false;
+}
+
 static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -85,6 +90,7 @@ static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = hax_cpu_synchronize_post_init;
     ops->synchronize_state = hax_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm;
+    ops->has_work = hax_cpu_has_work;
 }
 
 static const TypeInfo hax_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 11/40] accel/nvmm: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 10/40] accel/hax: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 12/40] accel/qtest: " Philippe Mathieu-Daudé
                   ` (29 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Reinoud Zandijk, Kamil Rytarowski, Richard Henderson,
	Philippe Mathieu-Daudé

Since there is no specific NVMM handling for cpu_has_work() in
cpu_thread_is_idle(), implement NVMM has_work() handler as a
simple 'return false' code.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/nvmm/nvmm-accel-ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index f788f75289f..36296f79ff8 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -83,6 +83,11 @@ static void nvmm_kick_vcpu_thread(CPUState *cpu)
     cpus_kick_thread(cpu);
 }
 
+static bool nvmm_cpu_has_work(CPUState *cpu)
+{
+    return false;
+}
+
 static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -94,6 +99,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data)
     ops->synchronize_post_init = nvmm_cpu_synchronize_post_init;
     ops->synchronize_state = nvmm_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm;
+    ops->has_work = nvmm_cpu_has_work;
 }
 
 static const TypeInfo nvmm_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 12/40] accel/qtest: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 11/40] accel/nvmm: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 15:27   ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 13/40] accel/tcg: " Philippe Mathieu-Daudé
                   ` (28 subsequent siblings)
  40 siblings, 1 reply; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Richard Henderson,
	Philippe Mathieu-Daudé

Implement QTest has_work() handler in AccelOpsClass.
Since no CPU are available under QTest accelerator,
this function is not reachable.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/qtest/qtest.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d52..903c39ec1bf 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -47,12 +47,18 @@ static const TypeInfo qtest_accel_type = {
 };
 module_obj(TYPE_QTEST_ACCEL);
 
+static bool qtest_cpu_has_work(CPUState *cpu)
+{
+    g_assert_not_reached();
+}
+
 static void qtest_accel_ops_class_init(ObjectClass *oc, void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
 
     ops->create_vcpu_thread = dummy_start_vcpu_thread;
     ops->get_virtual_clock = qtest_get_virtual_clock;
+    ops->has_work = qtest_cpu_has_work;
 };
 
 static const TypeInfo qtest_accel_ops_type = {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 13/40] accel/tcg: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 12/40] accel/qtest: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 14/40] accel: Simplify cpu_has_work() Philippe Mathieu-Daudé
                   ` (27 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé,
	Eduardo Habkost

All accelerators but TCG implement their AccelOpsClass::has_work()
handler, meaning all the remaining CPUClass::has_work() ones are
only reachable from TCG accelerator; and these has_work() handlers
belong to TCGCPUOps.

We will gradually move each target CPUClass::has_work() to
TCGCPUOps in the following commits.
For now, move the CPUClass::has_work() call to tcg_cpu_has_work(),
the TCG AccelOpsClass::has_work() implementation.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h     |  2 +-
 accel/tcg/tcg-accel-ops.c | 11 +++++++++++
 softmmu/cpus.c            |  5 -----
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e2dd171a13f..114eb3b9b2c 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -89,7 +89,7 @@ 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.
+ * @has_work: Callback for checking if there is work to do. Only used by TCG.
  * @memory_rw_debug: Callback for GDB memory access.
  * @dump_state: Callback for dumping state.
  * @get_arch_id: Callback for getting architecture-dependent CPU ID.
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 1a8e8390bd6..ebaacff1842 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -73,6 +73,16 @@ int tcg_cpus_exec(CPUState *cpu)
     return ret;
 }
 
+static bool tcg_cpu_has_work(CPUState *cpu)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    if (cc->has_work) {
+        return cc->has_work(cpu);
+    }
+    return false;
+}
+
 /* mask must never be zero, except for A20 change call */
 void tcg_handle_interrupt(CPUState *cpu, int mask)
 {
@@ -108,6 +118,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops)
         ops->kick_vcpu_thread = rr_kick_vcpu_thread;
         ops->handle_interrupt = tcg_handle_interrupt;
     }
+    ops->has_work = tcg_cpu_has_work;
 }
 
 static void tcg_accel_ops_class_init(ObjectClass *oc, void *data)
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 5ffa02f9cef..bb16a25bcef 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -251,11 +251,6 @@ void cpu_interrupt(CPUState *cpu, int mask)
 
 bool cpu_has_work(CPUState *cpu)
 {
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    if (cc->has_work && cc->has_work(cpu)) {
-        return true;
-    }
     if (cpus_accel->has_work && cpus_accel->has_work(cpu)) {
         return true;
     }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 14/40] accel: Simplify cpu_has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 13/40] accel/tcg: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 15/40] accel/tcg: Introduce TCGCPUOps::has_work() Philippe Mathieu-Daudé
                   ` (26 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

Now that all accelerators implement a has_work() handler, we can
simplify cpu_has_work() by removing the non-NULL handler check.

Add an assertion in cpus_register_accel() for future accelerators.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 softmmu/cpus.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index bb16a25bcef..bbb83d5982a 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -251,10 +251,7 @@ void cpu_interrupt(CPUState *cpu, int mask)
 
 bool cpu_has_work(CPUState *cpu)
 {
-    if (cpus_accel->has_work && cpus_accel->has_work(cpu)) {
-        return true;
-    }
-    return false;
+    return cpus_accel->has_work(cpu);
 }
 
 static int do_vm_stop(RunState state, bool send_stop)
@@ -613,6 +610,7 @@ void cpus_register_accel(const AccelOpsClass *ops)
 
     /* Mandatory non-NULL handlers */
     assert(ops->create_vcpu_thread != NULL);
+    assert(ops->has_work != NULL);
 
     cpus_accel = ops;
 }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 15/40] accel/tcg: Introduce TCGCPUOps::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 14/40] accel: Simplify cpu_has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 16/40] target/arm: Explicit v7M cores use arm_cpu_has_work as CPUClass:has_work Philippe Mathieu-Daudé
                   ` (25 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

Introduce a target-specific has_work() handler for TCG.
Eventually call it from tcg_cpu_has_work(), our
AccelOpsClass::has_work() handler.

Inspired-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/tcg-cpu-ops.h | 4 ++++
 accel/tcg/tcg-accel-ops.c     | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 6cbe17f2e6d..c19c507b23c 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -66,6 +66,10 @@ struct TCGCPUOps {
     void (*do_interrupt)(CPUState *cpu);
 #endif /* !CONFIG_USER_ONLY || !TARGET_I386 */
 #ifdef CONFIG_SOFTMMU
+    /**
+     * @has_work: Callback for checking if there is work to do.
+     */
+    bool (*has_work)(CPUState *cpu);
     /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */
     bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);
     /**
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index ebaacff1842..cd44bb6d0d8 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -32,6 +32,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
+#include "hw/core/tcg-cpu-ops.h"
 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-mttcg.h"
@@ -80,6 +81,9 @@ static bool tcg_cpu_has_work(CPUState *cpu)
     if (cc->has_work) {
         return cc->has_work(cpu);
     }
+    if (cc->tcg_ops->has_work) {
+        return cc->tcg_ops->has_work(cpu);
+    }
     return false;
 }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 16/40] target/arm: Explicit v7M cores use arm_cpu_has_work as CPUClass:has_work
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 15/40] accel/tcg: Introduce TCGCPUOps::has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 17/40] target/arm: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
                   ` (24 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, open list:ARM TCG CPUs, Richard Henderson,
	Philippe Mathieu-Daudé

ARM v7M cores inherit TYPE_ARM_CPU, so TYPE_ARM_CPU's class_init runs
first and sets up most of the class fields, setting in particular the
has_work handler to the generic arm_cpu_has_work(). Thus M-profile
and A-profile share the same arm_cpu_has_work() function. Some of the
checks the code there does are perhaps unnecessary for M-profile, but
they're harmless.

Since we want to move the has_work handler from CPUClass to TCGCPUOps,
the next commit will be more explicit if we already register this
handler in arm_v7m_class_init(). Since arm_cpu_has_work() is static to
target/arm/cpu.c, we have to declare it in "internals.h" to be able to
use it in target/arm/cpu_tcg.c.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/arm/internals.h | 2 ++
 target/arm/cpu.c       | 2 +-
 target/arm/cpu_tcg.c   | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/arm/internals.h b/target/arm/internals.h
index 9fbb3649682..f20aeb97fa0 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -177,6 +177,8 @@ void arm_translate_init(void);
 void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
 #endif /* CONFIG_TCG */
 
+bool arm_cpu_has_work(CPUState *cs);
+
 /**
  * aarch64_sve_zcr_get_valid_len:
  * @cpu: cpu context
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 641a8c2d3d3..4b08f717f64 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -76,7 +76,7 @@ void arm_cpu_synchronize_from_tb(CPUState *cs,
 }
 #endif /* CONFIG_TCG */
 
-static bool arm_cpu_has_work(CPUState *cs)
+bool arm_cpu_has_work(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
 
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
index 0d5adccf1a7..9a0927ad5d0 100644
--- a/target/arm/cpu_tcg.c
+++ b/target/arm/cpu_tcg.c
@@ -920,6 +920,7 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
 
     acc->info = data;
 #ifdef CONFIG_TCG
+    cc->has_work = arm_cpu_has_work;
     cc->tcg_ops = &arm_v7m_tcg_ops;
 #endif /* CONFIG_TCG */
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 17/40] target/arm: Restrict has_work() handler to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 16/40] target/arm: Explicit v7M cores use arm_cpu_has_work as CPUClass:has_work Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 18/40] target/alpha: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (23 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, open list:ARM TCG CPUs, Richard Henderson,
	Philippe Mathieu-Daudé

Restrict arm_cpu_has_work() and has_work() handler to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/arm/internals.h | 4 +++-
 target/arm/cpu.c       | 7 +++++--
 target/arm/cpu_tcg.c   | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/target/arm/internals.h b/target/arm/internals.h
index f20aeb97fa0..18b3c2bf1ea 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -175,9 +175,11 @@ void arm_translate_init(void);
 
 #ifdef CONFIG_TCG
 void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
-#endif /* CONFIG_TCG */
 
+#if !defined(CONFIG_USER_ONLY)
 bool arm_cpu_has_work(CPUState *cs);
+#endif /* !CONFIG_USER_ONLY */
+#endif /* CONFIG_TCG */
 
 /**
  * aarch64_sve_zcr_get_valid_len:
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 4b08f717f64..53c478171ac 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -74,8 +74,8 @@ void arm_cpu_synchronize_from_tb(CPUState *cs,
         env->regs[15] = tb->pc;
     }
 }
-#endif /* CONFIG_TCG */
 
+#ifndef CONFIG_USER_ONLY
 bool arm_cpu_has_work(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
@@ -86,6 +86,9 @@ bool arm_cpu_has_work(CPUState *cs)
          | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ
          | CPU_INTERRUPT_EXITTB);
 }
+#endif /* !CONFIG_USER_ONLY */
+
+#endif /* CONFIG_TCG */
 
 void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
                                  void *opaque)
@@ -2035,6 +2038,7 @@ static const struct TCGCPUOps arm_tcg_ops = {
     .debug_excp_handler = arm_debug_excp_handler,
 
 #if !defined(CONFIG_USER_ONLY)
+    .has_work = arm_cpu_has_work,
     .cpu_exec_interrupt = arm_cpu_exec_interrupt,
     .do_interrupt = arm_cpu_do_interrupt,
     .do_transaction_failed = arm_cpu_do_transaction_failed,
@@ -2059,7 +2063,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, arm_cpu_reset, &acc->parent_reset);
 
     cc->class_by_name = arm_cpu_class_by_name;
-    cc->has_work = arm_cpu_has_work;
     cc->dump_state = arm_cpu_dump_state;
     cc->set_pc = arm_cpu_set_pc;
     cc->gdb_read_register = arm_cpu_gdb_read_register;
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
index 9a0927ad5d0..7d0d9fcbc79 100644
--- a/target/arm/cpu_tcg.c
+++ b/target/arm/cpu_tcg.c
@@ -902,6 +902,7 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = {
     .debug_excp_handler = arm_debug_excp_handler,
 
 #if !defined(CONFIG_USER_ONLY)
+    .has_work = arm_cpu_has_work,
     .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt,
     .do_interrupt = arm_v7m_cpu_do_interrupt,
     .do_transaction_failed = arm_cpu_do_transaction_failed,
@@ -920,7 +921,6 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
 
     acc->info = data;
 #ifdef CONFIG_TCG
-    cc->has_work = arm_cpu_has_work;
     cc->tcg_ops = &arm_v7m_tcg_ops;
 #endif /* CONFIG_TCG */
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 18/40] target/alpha: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 17/40] target/arm: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 19/40] target/avr: " Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 93e16a2ffb4..1ca601cac5b 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -33,6 +33,7 @@ static void alpha_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc = value;
 }
 
+#if !defined(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.
@@ -47,6 +48,7 @@ static bool alpha_cpu_has_work(CPUState *cs)
                                     | CPU_INTERRUPT_SMP
                                     | CPU_INTERRUPT_MCHK);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void alpha_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 {
@@ -221,6 +223,7 @@ static const struct TCGCPUOps alpha_tcg_ops = {
     .tlb_fill = alpha_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = alpha_cpu_has_work,
     .cpu_exec_interrupt = alpha_cpu_exec_interrupt,
     .do_interrupt = alpha_cpu_do_interrupt,
     .do_transaction_failed = alpha_cpu_do_transaction_failed,
@@ -238,7 +241,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->dump_state = alpha_cpu_dump_state;
     cc->set_pc = alpha_cpu_set_pc;
     cc->gdb_read_register = alpha_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 19/40] target/avr: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 18/40] target/alpha: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 20/40] target/cris: " Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Rolnik, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 5d70e34dd54..6d51f91ca2c 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -195,6 +195,7 @@ static const struct SysemuCPUOps avr_sysemu_ops = {
 static const struct TCGCPUOps avr_tcg_ops = {
     .initialize = avr_cpu_tcg_init,
     .synchronize_from_tb = avr_cpu_synchronize_from_tb,
+    .has_work = avr_cpu_has_work,
     .cpu_exec_interrupt = avr_cpu_exec_interrupt,
     .tlb_fill = avr_cpu_tlb_fill,
     .do_interrupt = avr_cpu_do_interrupt,
@@ -211,7 +212,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->dump_state = avr_cpu_dump_state;
     cc->set_pc = avr_cpu_set_pc;
     cc->memory_rw_debug = avr_cpu_memory_rw_debug;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 20/40] target/cris: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 19/40] target/avr: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 21/40] target/hexagon: Remove unused has_work() handler Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E. Iglesias, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/cris/cpu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/cris/cpu.c b/target/cris/cpu.c
index c2e7483f5bd..b2761f8b110 100644
--- a/target/cris/cpu.c
+++ b/target/cris/cpu.c
@@ -35,10 +35,12 @@ static void cris_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc = value;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool cris_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void cris_cpu_reset(DeviceState *dev)
 {
@@ -208,6 +210,7 @@ static const struct TCGCPUOps crisv10_tcg_ops = {
     .tlb_fill = cris_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = cris_cpu_has_work,
     .cpu_exec_interrupt = cris_cpu_exec_interrupt,
     .do_interrupt = crisv10_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -218,6 +221,7 @@ static const struct TCGCPUOps crisv32_tcg_ops = {
     .tlb_fill = cris_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = cris_cpu_has_work,
     .cpu_exec_interrupt = cris_cpu_exec_interrupt,
     .do_interrupt = cris_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -294,7 +298,6 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, cris_cpu_reset, &ccc->parent_reset);
 
     cc->class_by_name = cris_cpu_class_by_name;
-    cc->has_work = cris_cpu_has_work;
     cc->dump_state = cris_cpu_dump_state;
     cc->set_pc = cris_cpu_set_pc;
     cc->gdb_read_register = cris_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 21/40] target/hexagon: Remove unused has_work() handler
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 20/40] target/cris: " Philippe Mathieu-Daudé
@ 2021-09-25 14:50 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 22/40] target/hppa: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Taylor Simpson, Richard Henderson, Philippe Mathieu-Daudé

has_work() is sysemu specific, and Hexagon target only provides
a linux-user implementation. Remove the unused hexagon_cpu_has_work().

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/hexagon/cpu.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index 3338365c16e..aa01974807c 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -189,11 +189,6 @@ static void hexagon_cpu_synchronize_from_tb(CPUState *cs,
     env->gpr[HEX_REG_PC] = tb->pc;
 }
 
-static bool hexagon_cpu_has_work(CPUState *cs)
-{
-    return true;
-}
-
 void restore_state_to_opc(CPUHexagonState *env, TranslationBlock *tb,
                           target_ulong *data)
 {
@@ -287,7 +282,6 @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_parent_reset(dc, hexagon_cpu_reset, &mcc->parent_reset);
 
     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->gdb_read_register = hexagon_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 22/40] target/hppa: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2021-09-25 14:50 ` [PATCH v7 21/40] target/hexagon: Remove unused has_work() handler Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 23/40] target/i386: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 89cba9d7a2c..000c2e7793a 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -60,10 +60,12 @@ static void hppa_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.psw_n = (tb->flags & PSW_N) != 0;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool hppa_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
 {
@@ -148,6 +150,7 @@ static const struct TCGCPUOps hppa_tcg_ops = {
     .tlb_fill = hppa_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = hppa_cpu_has_work,
     .cpu_exec_interrupt = hppa_cpu_exec_interrupt,
     .do_interrupt = hppa_cpu_do_interrupt,
     .do_unaligned_access = hppa_cpu_do_unaligned_access,
@@ -164,7 +167,6 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)
                                     &acc->parent_realize);
 
     cc->class_by_name = hppa_cpu_class_by_name;
-    cc->has_work = hppa_cpu_has_work;
     cc->dump_state = hppa_cpu_dump_state;
     cc->set_pc = hppa_cpu_set_pc;
     cc->gdb_read_register = hppa_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 23/40] target/i386: Restrict has_work() handler to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 22/40] target/hppa: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 24/40] target/m68k: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé,
	Eduardo Habkost

Restrict has_work() to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/i386/cpu.c         | 6 ------
 target/i386/tcg/tcg-cpu.c | 8 +++++++-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 6b029f1bdf1..36a1c5f3fd2 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6554,11 +6554,6 @@ int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request)
     return 0;
 }
 
-static bool x86_cpu_has_work(CPUState *cs)
-{
-    return x86_cpu_pending_interrupt(cs, cs->interrupt_request) != 0;
-}
-
 static void x86_disas_set_info(CPUState *cs, disassemble_info *info)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -6763,7 +6758,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->dump_state = x86_cpu_dump_state;
     cc->set_pc = x86_cpu_set_pc;
     cc->gdb_read_register = x86_cpu_gdb_read_register;
diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c
index 3ecfae34cb5..aef050d0898 100644
--- a/target/i386/tcg/tcg-cpu.c
+++ b/target/i386/tcg/tcg-cpu.c
@@ -55,6 +55,11 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs,
 }
 
 #ifndef CONFIG_USER_ONLY
+static bool x86_cpu_has_work(CPUState *cs)
+{
+    return x86_cpu_pending_interrupt(cs, cs->interrupt_request) != 0;
+}
+
 static bool x86_debug_check_breakpoint(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -63,7 +68,7 @@ static bool x86_debug_check_breakpoint(CPUState *cs)
     /* RF disables all architectural breakpoints. */
     return !(env->eflags & RF_MASK);
 }
-#endif
+#endif /* CONFIG_USER_ONLY */
 
 #include "hw/core/tcg-cpu-ops.h"
 
@@ -76,6 +81,7 @@ static const struct TCGCPUOps x86_tcg_ops = {
 #ifdef CONFIG_USER_ONLY
     .fake_user_interrupt = x86_cpu_do_interrupt,
 #else
+    .has_work = x86_cpu_has_work,
     .do_interrupt = x86_cpu_do_interrupt,
     .cpu_exec_interrupt = x86_cpu_exec_interrupt,
     .debug_excp_handler = breakpoint_handler,
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 24/40] target/m68k: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 23/40] target/i386: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 25/40] target/microblaze: " Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Laurent Vivier

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 66d22d11895..ad5d26b5c9e 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -31,10 +31,12 @@ static void m68k_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc = value;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool m68k_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void m68k_set_feature(CPUM68KState *env, int feature)
 {
@@ -518,6 +520,7 @@ static const struct TCGCPUOps m68k_tcg_ops = {
     .tlb_fill = m68k_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = m68k_cpu_has_work,
     .cpu_exec_interrupt = m68k_cpu_exec_interrupt,
     .do_interrupt = m68k_cpu_do_interrupt,
     .do_transaction_failed = m68k_cpu_transaction_failed,
@@ -535,7 +538,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_parent_reset(dc, m68k_cpu_reset, &mcc->parent_reset);
 
     cc->class_by_name = m68k_cpu_class_by_name;
-    cc->has_work = m68k_cpu_has_work;
     cc->dump_state = m68k_cpu_dump_state;
     cc->set_pc = m68k_cpu_set_pc;
     cc->gdb_read_register = m68k_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 25/40] target/microblaze: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (23 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 24/40] target/m68k: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 26/40] target/mips: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E. Iglesias, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/microblaze/cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index 15db277925f..36e6e540483 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -92,12 +92,13 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
 }
 
+#ifndef CONFIG_USER_ONLY
+
 static bool mb_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
 
-#ifndef CONFIG_USER_ONLY
 static void mb_cpu_ns_axi_dp(void *opaque, int irq, int level)
 {
     MicroBlazeCPU *cpu = opaque;
@@ -142,7 +143,7 @@ static void microblaze_cpu_set_irq(void *opaque, int irq, int level)
         cpu_reset_interrupt(cs, type);
     }
 }
-#endif
+#endif /* !CONFIG_USER_ONLY */
 
 static void mb_cpu_reset(DeviceState *dev)
 {
@@ -368,6 +369,7 @@ static const struct TCGCPUOps mb_tcg_ops = {
     .tlb_fill = mb_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = mb_cpu_has_work,
     .cpu_exec_interrupt = mb_cpu_exec_interrupt,
     .do_interrupt = mb_cpu_do_interrupt,
     .do_transaction_failed = mb_cpu_transaction_failed,
@@ -386,8 +388,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, mb_cpu_reset, &mcc->parent_reset);
 
     cc->class_by_name = mb_cpu_class_by_name;
-    cc->has_work = mb_cpu_has_work;
-
     cc->dump_state = mb_cpu_dump_state;
     cc->set_pc = mb_cpu_set_pc;
     cc->gdb_read_register = mb_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 26/40] target/mips: Restrict has_work() handler to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (24 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 25/40] target/microblaze: " Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 27/40] target/nios2: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Philippe Mathieu-Daudé,
	Aurelien Jarno, Aleksandar Rikalo

Restrict has_work() to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/mips/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 00e0c55d0e4..3639c03f8ea 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -128,6 +128,7 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value)
     mips_env_set_pc(&cpu->env, value);
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool mips_cpu_has_work(CPUState *cs)
 {
     MIPSCPU *cpu = MIPS_CPU(cs);
@@ -172,6 +173,7 @@ static bool mips_cpu_has_work(CPUState *cs)
     }
     return has_work;
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 #include "cpu-defs.c.inc"
 
@@ -542,6 +544,7 @@ static const struct TCGCPUOps mips_tcg_ops = {
     .tlb_fill = mips_cpu_tlb_fill,
 
 #if !defined(CONFIG_USER_ONLY)
+    .has_work = mips_cpu_has_work,
     .cpu_exec_interrupt = mips_cpu_exec_interrupt,
     .do_interrupt = mips_cpu_do_interrupt,
     .do_transaction_failed = mips_cpu_do_transaction_failed,
@@ -563,7 +566,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_props(dc, mips_cpu_properties);
 
     cc->class_by_name = mips_cpu_class_by_name;
-    cc->has_work = mips_cpu_has_work;
     cc->dump_state = mips_cpu_dump_state;
     cc->set_pc = mips_cpu_set_pc;
     cc->gdb_read_register = mips_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 27/40] target/nios2: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (25 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 26/40] target/mips: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 28/40] target/openrisc: " Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marek Vasut, Chris Wulff, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/nios2/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c
index 947bb09bc1e..9938d7c2919 100644
--- a/target/nios2/cpu.c
+++ b/target/nios2/cpu.c
@@ -34,10 +34,12 @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value)
     env->regs[R_PC] = value;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool nios2_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void nios2_cpu_reset(DeviceState *dev)
 {
@@ -223,6 +225,7 @@ static const struct TCGCPUOps nios2_tcg_ops = {
     .tlb_fill = nios2_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = nios2_cpu_has_work,
     .cpu_exec_interrupt = nios2_cpu_exec_interrupt,
     .do_interrupt = nios2_cpu_do_interrupt,
     .do_unaligned_access = nios2_cpu_do_unaligned_access,
@@ -241,7 +244,6 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, nios2_cpu_reset, &ncc->parent_reset);
 
     cc->class_by_name = nios2_cpu_class_by_name;
-    cc->has_work = nios2_cpu_has_work;
     cc->dump_state = nios2_cpu_dump_state;
     cc->set_pc = nios2_cpu_set_pc;
     cc->disas_set_info = nios2_cpu_disas_set_info;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 28/40] target/openrisc: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (26 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 27/40] target/nios2: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 29/40] target/ppc: Introduce PowerPCCPUClass::has_work() Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stafford Horne, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 27cb04152f9..3c368a1bde7 100644
--- a/target/openrisc/cpu.c
+++ b/target/openrisc/cpu.c
@@ -30,11 +30,13 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.dflag = 0;
 }
 
+#if !defined(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 void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info)
 {
@@ -189,6 +191,7 @@ static const struct TCGCPUOps openrisc_tcg_ops = {
     .tlb_fill = openrisc_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = openrisc_cpu_has_work,
     .cpu_exec_interrupt = openrisc_cpu_exec_interrupt,
     .do_interrupt = openrisc_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -205,7 +208,6 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, openrisc_cpu_reset, &occ->parent_reset);
 
     cc->class_by_name = openrisc_cpu_class_by_name;
-    cc->has_work = openrisc_cpu_has_work;
     cc->dump_state = openrisc_cpu_dump_state;
     cc->set_pc = openrisc_cpu_set_pc;
     cc->gdb_read_register = openrisc_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 29/40] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (27 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 28/40] target/openrisc: " Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 30/40] target/ppc: Restrict has_work() handlers to sysemu and TCG Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: open list:PowerPC TCG CPUs, Greg Kurz, Richard Henderson,
	Philippe Mathieu-Daudé,
	David Gibson

We're moving the hook from CPUState to TCGCPUOps. TCGCPUOps is
a const structure, so to avoid creating multiple versions of
the same structure, simply changing the has_work() handler,
introduce yet another indirection with a has_work() handler in
PowerPCCPUClass, and ppc_cpu_has_work() method which dispatch
to it.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu-qom.h  |  1 +
 target/ppc/cpu_init.c | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 5800fa324e8..36110112506 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -188,6 +188,7 @@ struct PowerPCCPUClass {
     uint32_t flags;
     int bfd_mach;
     uint32_t l1_dcache_size, l1_icache_size;
+    bool (*has_work)(CPUState *cpu);
 #ifndef CONFIG_USER_ONLY
     unsigned int gdb_num_sprs;
     const char *gdb_spr_xml;
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 6aad01d1d3a..2f7d262b176 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7621,7 +7621,6 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
-    CPUClass *cc = CPU_CLASS(oc);
 
     dc->fw_name = "PowerPC,POWER7";
     dc->desc = "POWER7";
@@ -7630,7 +7629,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
     pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER7;
     pcc->check_pow = check_pow_nocheck;
-    cc->has_work = cpu_has_work_POWER7;
+    pcc->has_work = cpu_has_work_POWER7;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -7789,7 +7788,6 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
-    CPUClass *cc = CPU_CLASS(oc);
 
     dc->fw_name = "PowerPC,POWER8";
     dc->desc = "POWER8";
@@ -7798,7 +7796,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
     pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER8;
     pcc->check_pow = check_pow_nocheck;
-    cc->has_work = cpu_has_work_POWER8;
+    pcc->has_work = cpu_has_work_POWER8;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -8003,7 +8001,6 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
-    CPUClass *cc = CPU_CLASS(oc);
 
     dc->fw_name = "PowerPC,POWER9";
     dc->desc = "POWER9";
@@ -8013,7 +8010,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
                          PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER9;
     pcc->check_pow = check_pow_nocheck;
-    cc->has_work = cpu_has_work_POWER9;
+    pcc->has_work = cpu_has_work_POWER9;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -8212,7 +8209,6 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
-    CPUClass *cc = CPU_CLASS(oc);
 
     dc->fw_name = "PowerPC,POWER10";
     dc->desc = "POWER10";
@@ -8223,7 +8219,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
                          PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER10;
     pcc->check_pow = check_pow_nocheck;
-    cc->has_work = cpu_has_work_POWER10;
+    pcc->has_work = cpu_has_work_POWER10;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -8790,7 +8786,7 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.nip = value;
 }
 
-static bool ppc_cpu_has_work(CPUState *cs)
+static bool cpu_has_work_default(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
@@ -8798,6 +8794,14 @@ static bool ppc_cpu_has_work(CPUState *cs)
     return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
 }
 
+static bool ppc_cpu_has_work(CPUState *cs)
+{
+    PowerPCCPU *cpu = POWERPC_CPU(cs);
+    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+    return pcc->has_work(cs);
+}
+
 static void ppc_cpu_reset(DeviceState *dev)
 {
     CPUState *s = CPU(dev);
@@ -9037,6 +9041,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_unrealize(dc, ppc_cpu_unrealize,
                                       &pcc->parent_unrealize);
     pcc->pvr_match = ppc_pvr_match_default;
+    pcc->has_work = cpu_has_work_default;
     device_class_set_props(dc, ppc_cpu_properties);
 
     device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 30/40] target/ppc: Restrict has_work() handlers to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (28 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 29/40] target/ppc: Introduce PowerPCCPUClass::has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51   ` Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: open list:PowerPC TCG CPUs, Greg Kurz, Richard Henderson,
	Philippe Mathieu-Daudé,
	David Gibson

Restrict PowerPCCPUClass::has_work() and ppc_cpu_has_work()
- SysemuCPUOps::has_work() implementation - to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu-qom.h  |  4 +++-
 target/ppc/cpu_init.c | 24 ++++++++++++++++++------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 36110112506..ff2bafcde6f 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -188,8 +188,10 @@ struct PowerPCCPUClass {
     uint32_t flags;
     int bfd_mach;
     uint32_t l1_dcache_size, l1_icache_size;
-    bool (*has_work)(CPUState *cpu);
 #ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_TCG
+    bool (*has_work)(CPUState *cpu);
+#endif /* CONFIG_TCG */
     unsigned int gdb_num_sprs;
     const char *gdb_spr_xml;
 #endif
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 2f7d262b176..5c134adeea9 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7583,6 +7583,7 @@ static bool ppc_pvr_match_power7(PowerPCCPUClass *pcc, uint32_t pvr)
     return false;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cpu_has_work_POWER7(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -7616,6 +7617,7 @@ static bool cpu_has_work_POWER7(CPUState *cs)
         return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 {
@@ -7629,7 +7631,6 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
     pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER7;
     pcc->check_pow = check_pow_nocheck;
-    pcc->has_work = cpu_has_work_POWER7;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -7672,6 +7673,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
     pcc->lpcr_pm = LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2;
     pcc->mmu_model = POWERPC_MMU_2_06;
 #if defined(CONFIG_SOFTMMU)
+    pcc->has_work = cpu_has_work_POWER7;
     pcc->hash64_opts = &ppc_hash64_opts_POWER7;
     pcc->lrg_decr_bits = 32;
 #endif
@@ -7742,6 +7744,7 @@ static bool ppc_pvr_match_power8(PowerPCCPUClass *pcc, uint32_t pvr)
     return false;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cpu_has_work_POWER8(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -7783,6 +7786,7 @@ static bool cpu_has_work_POWER8(CPUState *cs)
         return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
 {
@@ -7796,7 +7800,6 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
     pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER8;
     pcc->check_pow = check_pow_nocheck;
-    pcc->has_work = cpu_has_work_POWER8;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -7846,6 +7849,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
                    LPCR_P8_PECE3 | LPCR_P8_PECE4;
     pcc->mmu_model = POWERPC_MMU_2_07;
 #if defined(CONFIG_SOFTMMU)
+    pcc->has_work = cpu_has_work_POWER8;
     pcc->hash64_opts = &ppc_hash64_opts_POWER7;
     pcc->lrg_decr_bits = 32;
     pcc->n_host_threads = 8;
@@ -7939,6 +7943,7 @@ static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr)
     return false;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cpu_has_work_POWER9(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -7996,6 +8001,7 @@ static bool cpu_has_work_POWER9(CPUState *cs)
         return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
 {
@@ -8010,7 +8016,6 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
                          PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER9;
     pcc->check_pow = check_pow_nocheck;
-    pcc->has_work = cpu_has_work_POWER9;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -8059,6 +8064,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
     pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE;
     pcc->mmu_model = POWERPC_MMU_3_00;
 #if defined(CONFIG_SOFTMMU)
+    pcc->has_work = cpu_has_work_POWER9;
     /* segment page size remain the same */
     pcc->hash64_opts = &ppc_hash64_opts_POWER7;
     pcc->radix_page_info = &POWER9_radix_page_info;
@@ -8147,6 +8153,7 @@ static bool ppc_pvr_match_power10(PowerPCCPUClass *pcc, uint32_t pvr)
     return false;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cpu_has_work_POWER10(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -8204,6 +8211,7 @@ static bool cpu_has_work_POWER10(CPUState *cs)
         return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
 {
@@ -8219,7 +8227,6 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
                          PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->init_proc = init_proc_POWER10;
     pcc->check_pow = check_pow_nocheck;
-    pcc->has_work = cpu_has_work_POWER10;
     pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
                        PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
                        PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
@@ -8271,6 +8278,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
     pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE;
     pcc->mmu_model = POWERPC_MMU_3_00;
 #if defined(CONFIG_SOFTMMU)
+    pcc->has_work = cpu_has_work_POWER10;
     /* segment page size remain the same */
     pcc->hash64_opts = &ppc_hash64_opts_POWER7;
     pcc->radix_page_info = &POWER10_radix_page_info;
@@ -8786,6 +8794,7 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.nip = value;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cpu_has_work_default(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -8801,6 +8810,7 @@ static bool ppc_cpu_has_work(CPUState *cs)
 
     return pcc->has_work(cs);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void ppc_cpu_reset(DeviceState *dev)
 {
@@ -9021,6 +9031,7 @@ static const struct TCGCPUOps ppc_tcg_ops = {
   .tlb_fill = ppc_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+  .has_work = ppc_cpu_has_work,
   .cpu_exec_interrupt = ppc_cpu_exec_interrupt,
   .do_interrupt = ppc_cpu_do_interrupt,
   .cpu_exec_enter = ppc_cpu_exec_enter,
@@ -9041,13 +9052,11 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_unrealize(dc, ppc_cpu_unrealize,
                                       &pcc->parent_unrealize);
     pcc->pvr_match = ppc_pvr_match_default;
-    pcc->has_work = cpu_has_work_default;
     device_class_set_props(dc, ppc_cpu_properties);
 
     device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset);
 
     cc->class_by_name = ppc_cpu_class_by_name;
-    cc->has_work = ppc_cpu_has_work;
     cc->dump_state = ppc_cpu_dump_state;
     cc->set_pc = ppc_cpu_set_pc;
     cc->gdb_read_register = ppc_cpu_gdb_read_register;
@@ -9078,6 +9087,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
 
 #ifdef CONFIG_TCG
     cc->tcg_ops = &ppc_tcg_ops;
+#ifndef CONFIG_USER_ONLY
+    pcc->has_work = cpu_has_work_default;
+#endif
 #endif /* CONFIG_TCG */
 }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 31/40] target/riscv: Restrict has_work() handler to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
@ 2021-09-25 14:51   ` Philippe Mathieu-Daudé
  2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: open list:RISC-V TCG CPUs, Bin Meng, Richard Henderson,
	Philippe Mathieu-Daudé,
	Alistair Francis, Palmer Dabbelt

Restrict has_work() to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/riscv/cpu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 7c626d89cd7..ca76bc34d9b 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -335,9 +335,9 @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs,
     env->pc = tb->pc;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool riscv_cpu_has_work(CPUState *cs)
 {
-#ifndef CONFIG_USER_ONLY
     RISCVCPU *cpu = RISCV_CPU(cs);
     CPURISCVState *env = &cpu->env;
     /*
@@ -345,10 +345,8 @@ static bool riscv_cpu_has_work(CPUState *cs)
      * mode and delegation registers, but respect individual enables
      */
     return (env->mip & env->mie) != 0;
-#else
-    return true;
-#endif
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 void restore_state_to_opc(CPURISCVState *env, TranslationBlock *tb,
                           target_ulong *data)
@@ -678,6 +676,7 @@ static const struct TCGCPUOps riscv_tcg_ops = {
     .tlb_fill = riscv_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = riscv_cpu_has_work,
     .cpu_exec_interrupt = riscv_cpu_exec_interrupt,
     .do_interrupt = riscv_cpu_do_interrupt,
     .do_transaction_failed = riscv_cpu_do_transaction_failed,
@@ -697,7 +696,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_parent_reset(dc, riscv_cpu_reset, &mcc->parent_reset);
 
     cc->class_by_name = riscv_cpu_class_by_name;
-    cc->has_work = riscv_cpu_has_work;
     cc->dump_state = riscv_cpu_dump_state;
     cc->set_pc = riscv_cpu_set_pc;
     cc->gdb_read_register = riscv_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 31/40] target/riscv: Restrict has_work() handler to sysemu and TCG
@ 2021-09-25 14:51   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Philippe Mathieu-Daudé,
	Alistair Francis, Palmer Dabbelt, Bin Meng,
	open list:RISC-V TCG CPUs

Restrict has_work() to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/riscv/cpu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 7c626d89cd7..ca76bc34d9b 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -335,9 +335,9 @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs,
     env->pc = tb->pc;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool riscv_cpu_has_work(CPUState *cs)
 {
-#ifndef CONFIG_USER_ONLY
     RISCVCPU *cpu = RISCV_CPU(cs);
     CPURISCVState *env = &cpu->env;
     /*
@@ -345,10 +345,8 @@ static bool riscv_cpu_has_work(CPUState *cs)
      * mode and delegation registers, but respect individual enables
      */
     return (env->mip & env->mie) != 0;
-#else
-    return true;
-#endif
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 void restore_state_to_opc(CPURISCVState *env, TranslationBlock *tb,
                           target_ulong *data)
@@ -678,6 +676,7 @@ static const struct TCGCPUOps riscv_tcg_ops = {
     .tlb_fill = riscv_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = riscv_cpu_has_work,
     .cpu_exec_interrupt = riscv_cpu_exec_interrupt,
     .do_interrupt = riscv_cpu_do_interrupt,
     .do_transaction_failed = riscv_cpu_do_transaction_failed,
@@ -697,7 +696,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_parent_reset(dc, riscv_cpu_reset, &mcc->parent_reset);
 
     cc->class_by_name = riscv_cpu_class_by_name;
-    cc->has_work = riscv_cpu_has_work;
     cc->dump_state = riscv_cpu_dump_state;
     cc->set_pc = riscv_cpu_set_pc;
     cc->gdb_read_register = riscv_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 32/40] target/rx: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (30 preceding siblings ...)
  2021-09-25 14:51   ` Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 33/40] target/s390x: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Yoshinori Sato

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/rx/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index 25a4aa2976d..ac6b40b2716 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -41,11 +41,13 @@ static void rx_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.pc = tb->pc;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool rx_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request &
         (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void rx_cpu_reset(DeviceState *dev)
 {
@@ -189,6 +191,7 @@ static const struct TCGCPUOps rx_tcg_ops = {
     .tlb_fill = rx_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = rx_cpu_has_work,
     .cpu_exec_interrupt = rx_cpu_exec_interrupt,
     .do_interrupt = rx_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -206,7 +209,6 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data)
                                   &rcc->parent_reset);
 
     cc->class_by_name = rx_cpu_class_by_name;
-    cc->has_work = rx_cpu_has_work;
     cc->dump_state = rx_cpu_dump_state;
     cc->set_pc = rx_cpu_set_pc;
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 33/40] target/s390x: Restrict has_work() handler to sysemu and TCG
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (31 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 32/40] target/rx: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 34/40] target/sh4: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Philippe Mathieu-Daudé,
	Halil Pasic, Christian Borntraeger,
	open list:S390 general arch...

Restrict has_work() to TCG sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/intc/s390_flic.c | 15 ++++++++++++---
 target/s390x/cpu.c  |  4 +++-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
index 74e02858d43..22bc38e9b4e 100644
--- a/hw/intc/s390_flic.c
+++ b/hw/intc/s390_flic.c
@@ -312,19 +312,28 @@ static void qemu_s390_inject_crw_mchk(S390FLICState *fs)
 
 bool qemu_s390_flic_has_service(QEMUS390FLICState *flic)
 {
-    /* called without lock via cc->has_work, will be validated under lock */
+    /*
+     * Called without lock via TCGCPUOps::has_work,
+     * will be validated under lock.
+     */
     return !!(flic->pending & FLIC_PENDING_SERVICE);
 }
 
 bool qemu_s390_flic_has_io(QEMUS390FLICState *flic, uint64_t cr6)
 {
-    /* called without lock via cc->has_work, will be validated under lock */
+    /*
+     * Called without lock via TCGCPUOps::has_work,
+     * will be validated under lock.
+     */
     return !!(flic->pending & CR6_TO_PENDING_IO(cr6));
 }
 
 bool qemu_s390_flic_has_crw_mchk(QEMUS390FLICState *flic)
 {
-    /* called without lock via cc->has_work, will be validated under lock */
+    /*
+     * Called without lock via TCGCPUOps::has_work,
+     * will be validated under lock.
+     */
     return !!(flic->pending & FLIC_PENDING_MCHK_CR);
 }
 
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 7b7b05f1d3a..df8ade9021d 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -88,6 +88,7 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.psw.addr = value;
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool s390_cpu_has_work(CPUState *cs)
 {
     S390CPU *cpu = S390_CPU(cs);
@@ -104,6 +105,7 @@ static bool s390_cpu_has_work(CPUState *cs)
 
     return s390_cpu_has_int(cpu);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 /* S390CPUClass::reset() */
 static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
@@ -269,6 +271,7 @@ static const struct TCGCPUOps s390_tcg_ops = {
     .tlb_fill = s390_cpu_tlb_fill,
 
 #if !defined(CONFIG_USER_ONLY)
+    .has_work = s390_cpu_has_work,
     .cpu_exec_interrupt = s390_cpu_exec_interrupt,
     .do_interrupt = s390_cpu_do_interrupt,
     .debug_excp_handler = s390x_cpu_debug_excp_handler,
@@ -292,7 +295,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
 
     scc->reset = s390_cpu_reset;
     cc->class_by_name = s390_cpu_class_by_name,
-    cc->has_work = s390_cpu_has_work;
     cc->dump_state = s390_cpu_dump_state;
     cc->set_pc = s390_cpu_set_pc;
     cc->gdb_read_register = s390_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 34/40] target/sh4: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (32 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 33/40] target/s390x: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 35/40] target/sparc: Remove pointless use of CONFIG_TCG definition Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Yoshinori Sato

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/sh4/cpu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 2047742d03c..fb2116dc52e 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -58,13 +58,14 @@ 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 void superh_cpu_reset(DeviceState *dev)
 {
     CPUState *s = CPU(dev);
@@ -239,6 +240,7 @@ static const struct TCGCPUOps superh_tcg_ops = {
     .tlb_fill = superh_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = superh_cpu_has_work,
     .cpu_exec_interrupt = superh_cpu_exec_interrupt,
     .do_interrupt = superh_cpu_do_interrupt,
     .do_unaligned_access = superh_cpu_do_unaligned_access,
@@ -258,7 +260,6 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, superh_cpu_reset, &scc->parent_reset);
 
     cc->class_by_name = superh_cpu_class_by_name;
-    cc->has_work = superh_cpu_has_work;
     cc->dump_state = superh_cpu_dump_state;
     cc->set_pc = superh_cpu_set_pc;
     cc->gdb_read_register = superh_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 35/40] target/sparc: Remove pointless use of CONFIG_TCG definition
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (33 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 34/40] target/sh4: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 36/40] target/sparc: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Richard Henderson, Philippe Mathieu-Daudé,
	Artyom Tarasenko

The SPARC target only support TCG acceleration. Remove the CONFIG_TCG
definition introduced by mistake in commit 78271684719 ("cpu: tcg_ops:
move to tcg-cpu-ops.h, keep a pointer in CPUClass").

Reported-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/sparc/cpu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 21dd27796d0..0d252cb5bdc 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -859,7 +859,6 @@ static const struct SysemuCPUOps sparc_sysemu_ops = {
 };
 #endif
 
-#ifdef CONFIG_TCG
 #include "hw/core/tcg-cpu-ops.h"
 
 static const struct TCGCPUOps sparc_tcg_ops = {
@@ -874,7 +873,6 @@ static const struct TCGCPUOps sparc_tcg_ops = {
     .do_unaligned_access = sparc_cpu_do_unaligned_access,
 #endif /* !CONFIG_USER_ONLY */
 };
-#endif /* CONFIG_TCG */
 
 static void sparc_cpu_class_init(ObjectClass *oc, void *data)
 {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 36/40] target/sparc: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (34 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 35/40] target/sparc: Remove pointless use of CONFIG_TCG definition Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 37/40] target/tricore: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Richard Henderson, Philippe Mathieu-Daudé,
	Artyom Tarasenko

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.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 0d252cb5bdc..8d61bf15f6c 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -702,6 +702,7 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.npc = tb->cs_base;
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool sparc_cpu_has_work(CPUState *cs)
 {
     SPARCCPU *cpu = SPARC_CPU(cs);
@@ -710,6 +711,7 @@ static bool sparc_cpu_has_work(CPUState *cs)
     return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
            cpu_interrupts_enabled(env);
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static char *sparc_cpu_type_name(const char *cpu_model)
 {
@@ -867,6 +869,7 @@ static const struct TCGCPUOps sparc_tcg_ops = {
     .tlb_fill = sparc_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = sparc_cpu_has_work,
     .cpu_exec_interrupt = sparc_cpu_exec_interrupt,
     .do_interrupt = sparc_cpu_do_interrupt,
     .do_transaction_failed = sparc_cpu_do_transaction_failed,
@@ -888,7 +891,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->dump_state = sparc_cpu_dump_state;
 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
     cc->memory_rw_debug = sparc_cpu_memory_rw_debug;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 37/40] target/tricore: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (35 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 36/40] target/sparc: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 38/40] target/xtensa: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bastian Koppelmann, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/tricore/cpu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index b95682b7f04..419fa624bd5 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -62,10 +62,12 @@ static void tricore_cpu_reset(DeviceState *dev)
     cpu_state_reset(env);
 }
 
+#if !defined(CONFIG_USER_ONLY)
 static bool tricore_cpu_has_work(CPUState *cs)
 {
     return true;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)
 {
@@ -154,6 +156,9 @@ static const struct TCGCPUOps tricore_tcg_ops = {
     .initialize = tricore_tcg_init,
     .synchronize_from_tb = tricore_cpu_synchronize_from_tb,
     .tlb_fill = tricore_cpu_tlb_fill,
+#if !defined(CONFIG_USER_ONLY)
+    .has_work = tricore_cpu_has_work,
+#endif
 };
 
 static void tricore_cpu_class_init(ObjectClass *c, void *data)
@@ -167,7 +172,6 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
 
     device_class_set_parent_reset(dc, tricore_cpu_reset, &mcc->parent_reset);
     cc->class_by_name = tricore_cpu_class_by_name;
-    cc->has_work = tricore_cpu_has_work;
 
     cc->gdb_read_register = tricore_cpu_gdb_read_register;
     cc->gdb_write_register = tricore_cpu_gdb_write_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 38/40] target/xtensa: Restrict has_work() handler to sysemu
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (36 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 37/40] target/tricore: " Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 39/40] accel/tcg: Remove CPUClass::has_work() Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to sysemu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/xtensa/cpu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index c1cbd03595e..5cb19a88819 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -43,18 +43,17 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc = value;
 }
 
+#ifndef CONFIG_USER_ONLY
+
 static bool xtensa_cpu_has_work(CPUState *cs)
 {
-#ifndef CONFIG_USER_ONLY
     XtensaCPU *cpu = XTENSA_CPU(cs);
 
     return !cpu->env.runstall && cpu->env.pending_irq_level;
-#else
-    return true;
-#endif
 }
 
-#ifdef CONFIG_USER_ONLY
+#else /* CONFIG_USER_ONLY*/
+
 static bool abi_call0;
 
 void xtensa_set_abi_call0(void)
@@ -66,7 +65,8 @@ bool xtensa_abi_call0(void)
 {
     return abi_call0;
 }
-#endif
+
+#endif /* CONFIG_USER_ONLY */
 
 static void xtensa_cpu_reset(DeviceState *dev)
 {
@@ -196,6 +196,7 @@ static const struct TCGCPUOps xtensa_tcg_ops = {
     .debug_excp_handler = xtensa_breakpoint_handler,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = xtensa_cpu_has_work,
     .cpu_exec_interrupt = xtensa_cpu_exec_interrupt,
     .do_interrupt = xtensa_cpu_do_interrupt,
     .do_transaction_failed = xtensa_cpu_do_transaction_failed,
@@ -215,7 +216,6 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
     device_class_set_parent_reset(dc, xtensa_cpu_reset, &xcc->parent_reset);
 
     cc->class_by_name = xtensa_cpu_class_by_name;
-    cc->has_work = xtensa_cpu_has_work;
     cc->dump_state = xtensa_cpu_dump_state;
     cc->set_pc = xtensa_cpu_set_pc;
     cc->gdb_read_register = xtensa_cpu_gdb_read_register;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 39/40] accel/tcg: Remove CPUClass::has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (37 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 38/40] target/xtensa: " Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 14:51 ` [PATCH v7 40/40] accel/tcg: Simplify tcg_cpu_has_work() Philippe Mathieu-Daudé
  2021-09-25 15:28 ` [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Richard Henderson
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé,
	Eduardo Habkost

Now that all TCG targets converted their CPUClass::has_work()
handler to a TCGCPUOps::has_work() one, we can remove has_work
from CPUClass.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h     | 2 --
 accel/tcg/tcg-accel-ops.c | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 114eb3b9b2c..c64709b898c 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -89,7 +89,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. Only used by TCG.
  * @memory_rw_debug: Callback for GDB memory access.
  * @dump_state: Callback for dumping state.
  * @get_arch_id: Callback for getting architecture-dependent CPU ID.
@@ -132,7 +131,6 @@ struct CPUClass {
     void (*parse_features)(const char *typename, char *str, Error **errp);
 
     int reset_dump_flags;
-    bool (*has_work)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
     void (*dump_state)(CPUState *cpu, FILE *, int flags);
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index cd44bb6d0d8..3c75ed2cccc 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -78,9 +78,6 @@ static bool tcg_cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
-    if (cc->has_work) {
-        return cc->has_work(cpu);
-    }
     if (cc->tcg_ops->has_work) {
         return cc->tcg_ops->has_work(cpu);
     }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH v7 40/40] accel/tcg: Simplify tcg_cpu_has_work()
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (38 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 39/40] accel/tcg: Remove CPUClass::has_work() Philippe Mathieu-Daudé
@ 2021-09-25 14:51 ` Philippe Mathieu-Daudé
  2021-09-25 15:28 ` [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Richard Henderson
  40 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 14:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Philippe Mathieu-Daudé

All TCG targets implement the TCGCPUOps::has_work() handler.
We can remove the non-NULL handler check in tcg_cpu_has_work().

Add an assertion in tcg_exec_realizefn() for future TCG targets.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/tcg/cpu-exec.c      | 6 ++++++
 accel/tcg/tcg-accel-ops.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 5fd1ed34222..d577a65237c 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -993,6 +993,12 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp)
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
     if (!tcg_target_initialized) {
+        /* Mandatory non-NULL handlers */
+        g_assert(cc->tcg_ops->initialize);
+#ifndef CONFIG_USER_ONLY
+        g_assert(cc->tcg_ops->has_work);
+#endif /* !CONFIG_USER_ONLY */
+
         cc->tcg_ops->initialize();
         tcg_target_initialized = true;
     }
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 3c75ed2cccc..6cd32f04cb9 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -78,10 +78,7 @@ static bool tcg_cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
-    if (cc->tcg_ops->has_work) {
-        return cc->tcg_ops->has_work(cpu);
-    }
-    return false;
+    return cc->tcg_ops->has_work(cpu);
 }
 
 /* mask must never be zero, except for A20 change call */
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 01/40] accel: Simplify qemu_init_vcpu()
  2021-09-25 14:50 ` [PATCH v7 01/40] accel: Simplify qemu_init_vcpu() Philippe Mathieu-Daudé
@ 2021-09-25 15:25   ` Richard Henderson
  0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2021-09-25 15:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini

On 9/25/21 10:50 AM, Philippe Mathieu-Daudé wrote:
> cpus_register_accel() already checks for ops->create_vcpu_thread
> being non-NULL, so it is pointless to re-check for it in
> qemu_init_vcpu().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   softmmu/cpus.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 12/40] accel/qtest: Implement AccelOpsClass::has_work()
  2021-09-25 14:50 ` [PATCH v7 12/40] accel/qtest: " Philippe Mathieu-Daudé
@ 2021-09-25 15:27   ` Philippe Mathieu-Daudé
  2021-09-25 15:32     ` Richard Henderson
  0 siblings, 1 reply; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 15:27 UTC (permalink / raw)
  To: qemu-devel, Thomas Huth
  Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson, Igor Mammedov

+Igor

On 9/25/21 16:50, Philippe Mathieu-Daudé wrote:
> Implement QTest has_work() handler in AccelOpsClass.
> Since no CPU are available under QTest accelerator,
> this function is not reachable.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   accel/qtest/qtest.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
> index 7e6b8110d52..903c39ec1bf 100644
> --- a/accel/qtest/qtest.c
> +++ b/accel/qtest/qtest.c
> @@ -47,12 +47,18 @@ static const TypeInfo qtest_accel_type = {
>   };
>   module_obj(TYPE_QTEST_ACCEL);
>   
> +static bool qtest_cpu_has_work(CPUState *cpu)
> +{
> +    g_assert_not_reached();
> +}

Sigh, this triggers:

Running test qtest-i386/cpu-plug-test
**
ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be 
reached
ERROR qtest-i386/cpu-plug-test - Bail out! 
ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be 
reached
Broken pipe

I understand we want to test CPU hotplug, however I'm not sure what
part of the accelerator can be tested, QTest is almost empty stubs.

I suppose it is in my interest to 'return false' here and call it
a day...

>   static void qtest_accel_ops_class_init(ObjectClass *oc, void *data)
>   {
>       AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
>   
>       ops->create_vcpu_thread = dummy_start_vcpu_thread;
>       ops->get_virtual_clock = qtest_get_virtual_clock;
> +    ops->has_work = qtest_cpu_has_work;
>   };
>   
>   static const TypeInfo qtest_accel_ops_type = {
> 


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass
  2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
                   ` (39 preceding siblings ...)
  2021-09-25 14:51 ` [PATCH v7 40/40] accel/tcg: Simplify tcg_cpu_has_work() Philippe Mathieu-Daudé
@ 2021-09-25 15:28 ` Richard Henderson
  2021-09-25 15:36   ` Philippe Mathieu-Daudé
  40 siblings, 1 reply; 51+ messages in thread
From: Richard Henderson @ 2021-09-25 15:28 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 9/25/21 10:50 AM, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (40):
>    accel: Simplify qemu_init_vcpu()
>    hw/core: Restrict cpu_has_work() to sysemu
>    hw/core: Un-inline cpu_has_work()
>    hw/core: Move cpu_common_has_work() to cpu_has_work()
>    accel: Introduce AccelOpsClass::has_work()
>    accel/kvm: Implement AccelOpsClass::has_work()
>    accel/whpx: Implement AccelOpsClass::has_work()
>    accel/hvf: Implement AccelOpsClass::has_work()
>    accel/xen: Implement AccelOpsClass::has_work()
>    accel/hax: Implement AccelOpsClass::has_work()
>    accel/nvmm: Implement AccelOpsClass::has_work()
>    accel/qtest: Implement AccelOpsClass::has_work()
>    accel/tcg: Implement AccelOpsClass::has_work()
>    accel: Simplify cpu_has_work()
>    accel/tcg: Introduce TCGCPUOps::has_work()
>    target/arm: Explicit v7M cores use arm_cpu_has_work as
>      CPUClass:has_work
>    target/arm: Restrict has_work() handler to sysemu and TCG
>    target/alpha: Restrict has_work() handler to sysemu
>    target/avr: Restrict has_work() handler to sysemu
>    target/cris: Restrict has_work() handler to sysemu
>    target/hexagon: Remove unused has_work() handler
>    target/hppa: Restrict has_work() handler to sysemu
>    target/i386: Restrict has_work() handler to sysemu and TCG
>    target/m68k: Restrict has_work() handler to sysemu
>    target/microblaze: Restrict has_work() handler to sysemu
>    target/mips: Restrict has_work() handler to sysemu and TCG
>    target/nios2: Restrict has_work() handler to sysemu
>    target/openrisc: Restrict has_work() handler to sysemu
>    target/ppc: Introduce PowerPCCPUClass::has_work()
>    target/ppc: Restrict has_work() handlers to sysemu and TCG
>    target/riscv: Restrict has_work() handler to sysemu and TCG
>    target/rx: Restrict has_work() handler to sysemu
>    target/s390x: Restrict has_work() handler to sysemu and TCG
>    target/sh4: Restrict has_work() handler to sysemu
>    target/sparc: Remove pointless use of CONFIG_TCG definition
>    target/sparc: Restrict has_work() handler to sysemu
>    target/tricore: Restrict has_work() handler to sysemu
>    target/xtensa: Restrict has_work() handler to sysemu
>    accel/tcg: Remove CPUClass::has_work()
>    accel/tcg: Simplify tcg_cpu_has_work()

$ make check
   GIT     ui/keycodemapdb meson tests/fp/berkeley-testfloat-3 
tests/fp/berkeley-softfloat-3 dtc capstone slirp
[1/143] Generating qemu-version.h with a meson_exe.py custom command
Running test qtest-aarch64/qom-test
**
ERROR:../git-alt/accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
ERROR qtest-aarch64/qom-test - Bail out! 
ERROR:../git-alt/accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
Broken pipe



r~


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 12/40] accel/qtest: Implement AccelOpsClass::has_work()
  2021-09-25 15:27   ` Philippe Mathieu-Daudé
@ 2021-09-25 15:32     ` Richard Henderson
  2021-09-25 16:01       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 51+ messages in thread
From: Richard Henderson @ 2021-09-25 15:32 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Thomas Huth
  Cc: Laurent Vivier, Paolo Bonzini, Igor Mammedov

On 9/25/21 11:27 AM, Philippe Mathieu-Daudé wrote:
>> +static bool qtest_cpu_has_work(CPUState *cpu)
>> +{
>> +    g_assert_not_reached();
>> +}
> 
> Sigh, this triggers:
> 
> Running test qtest-i386/cpu-plug-test
> **
> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
> ERROR qtest-i386/cpu-plug-test - Bail out! 
> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
> Broken pipe

Ha ha, yes.  You beat me to the reply within minutes.

> I suppose it is in my interest to 'return false' here and call it
> a day...

I *think* that's the right thing, but I could see maybe "true" also makes sense.  I'll try 
and have a closer look.


r~


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass
  2021-09-25 15:28 ` [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Richard Henderson
@ 2021-09-25 15:36   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 15:36 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 9/25/21 17:28, Richard Henderson wrote:
> On 9/25/21 10:50 AM, Philippe Mathieu-Daudé wrote:
>> Philippe Mathieu-Daudé (40):
>>    accel: Simplify qemu_init_vcpu()
>>    hw/core: Restrict cpu_has_work() to sysemu
>>    hw/core: Un-inline cpu_has_work()
>>    hw/core: Move cpu_common_has_work() to cpu_has_work()
>>    accel: Introduce AccelOpsClass::has_work()
>>    accel/kvm: Implement AccelOpsClass::has_work()
>>    accel/whpx: Implement AccelOpsClass::has_work()
>>    accel/hvf: Implement AccelOpsClass::has_work()
>>    accel/xen: Implement AccelOpsClass::has_work()
>>    accel/hax: Implement AccelOpsClass::has_work()
>>    accel/nvmm: Implement AccelOpsClass::has_work()
>>    accel/qtest: Implement AccelOpsClass::has_work()
>>    accel/tcg: Implement AccelOpsClass::has_work()
>>    accel: Simplify cpu_has_work()
>>    accel/tcg: Introduce TCGCPUOps::has_work()
>>    target/arm: Explicit v7M cores use arm_cpu_has_work as
>>      CPUClass:has_work
>>    target/arm: Restrict has_work() handler to sysemu and TCG
>>    target/alpha: Restrict has_work() handler to sysemu
>>    target/avr: Restrict has_work() handler to sysemu
>>    target/cris: Restrict has_work() handler to sysemu
>>    target/hexagon: Remove unused has_work() handler
>>    target/hppa: Restrict has_work() handler to sysemu
>>    target/i386: Restrict has_work() handler to sysemu and TCG
>>    target/m68k: Restrict has_work() handler to sysemu
>>    target/microblaze: Restrict has_work() handler to sysemu
>>    target/mips: Restrict has_work() handler to sysemu and TCG
>>    target/nios2: Restrict has_work() handler to sysemu
>>    target/openrisc: Restrict has_work() handler to sysemu
>>    target/ppc: Introduce PowerPCCPUClass::has_work()
>>    target/ppc: Restrict has_work() handlers to sysemu and TCG
>>    target/riscv: Restrict has_work() handler to sysemu and TCG
>>    target/rx: Restrict has_work() handler to sysemu
>>    target/s390x: Restrict has_work() handler to sysemu and TCG
>>    target/sh4: Restrict has_work() handler to sysemu
>>    target/sparc: Remove pointless use of CONFIG_TCG definition
>>    target/sparc: Restrict has_work() handler to sysemu
>>    target/tricore: Restrict has_work() handler to sysemu
>>    target/xtensa: Restrict has_work() handler to sysemu
>>    accel/tcg: Remove CPUClass::has_work()
>>    accel/tcg: Simplify tcg_cpu_has_work()
> 
> $ make check
>    GIT     ui/keycodemapdb meson tests/fp/berkeley-testfloat-3 
> tests/fp/berkeley-softfloat-3 dtc capstone slirp
> [1/143] Generating qemu-version.h with a meson_exe.py custom command
> Running test qtest-aarch64/qom-test
> **
> ERROR:../git-alt/accel/qtest/qtest.c:52:qtest_cpu_has_work: code should 
> not be reached
> ERROR qtest-aarch64/qom-test - Bail out! 
> ERROR:../git-alt/accel/qtest/qtest.c:52:qtest_cpu_has_work: code should 
> not be reached
> Broken pipe

Yeah sorry I just realized 🤦‍♂️

Quick fix if you want to keep testing while allowing other to review:

-- >8 --
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 903c39ec1bf..eb5a17cef18 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -51,3 +51,3 @@ static bool qtest_cpu_has_work(CPUState *cpu)
  {
-    g_assert_not_reached();
+    return false;
  }
---


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 12/40] accel/qtest: Implement AccelOpsClass::has_work()
  2021-09-25 15:32     ` Richard Henderson
@ 2021-09-25 16:01       ` Philippe Mathieu-Daudé
  2021-09-27  6:12         ` Laurent Vivier
  0 siblings, 1 reply; 51+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 16:01 UTC (permalink / raw)
  To: Richard Henderson, Paolo Bonzini, Thomas Huth
  Cc: Laurent Vivier, Igor Mammedov, qemu-devel

On 9/25/21 17:32, Richard Henderson wrote:
> On 9/25/21 11:27 AM, Philippe Mathieu-Daudé wrote:
>>> +static bool qtest_cpu_has_work(CPUState *cpu)
>>> +{
>>> +    g_assert_not_reached();
>>> +}
>>
>> Sigh, this triggers:
>>
>> Running test qtest-i386/cpu-plug-test
>> **
>> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be 
>> reached
>> ERROR qtest-i386/cpu-plug-test - Bail out! 
>> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be 
>> reached
>> Broken pipe
> 
> Ha ha, yes.  You beat me to the reply within minutes.
> 
>> I suppose it is in my interest to 'return false' here and call it
>> a day...
> 
> I *think* that's the right thing, but I could see maybe "true" also 
> makes sense.  I'll try and have a closer look.

So first I tested using "-machine pc,accel=qtest" -> no crash.

Looking closely at how check-qtest calls QEMU, it does:
"-machine pc -accel qtest". Isn't the sugar property supposed
to work that way?

Then the backtrace is:

Thread 5 "qemu-system-i38" hit Breakpoint 1, qtest_cpu_has_work 
(cpu=0x555556a08400) at accel/qtest/qtest.c:52
52          g_assert_not_reached();
(gdb) bt
#0  qtest_cpu_has_work (cpu=0x555556a08400) at accel/qtest/qtest.c:52
#1  0x0000555555c330ba in cpu_has_work (cpu=0x555556a08400) at 
softmmu/cpus.c:254
#2  0x0000555555c32ac8 in cpu_thread_is_idle (cpu=0x555556a08400) at 
softmmu/cpus.c:91
#3  0x0000555555c33584 in qemu_wait_io_event (cpu=0x555556a08400) at 
softmmu/cpus.c:417
#4  0x0000555555d8a7f4 in dummy_cpu_thread_fn (arg=0x555556a08400) at 
accel/dummy-cpus.c:53
#5  0x0000555555f469f6 in qemu_thread_start (args=0x5555574edae0) at 
util/qemu-thread-posix.c:557
#6  0x00007ffff4ff3299 in start_thread () at /lib64/libpthread.so.0
#7  0x00007ffff4f1b353 in clone () at /lib64/libc.so.6

dummy_cpu_thread_fn() content didn't change since its introduction
in commit c7f0f3b1c82 ("qtest: add test framework"):

    "The idea behind qtest is pretty simple.  Instead of executing
     a CPU via TCG or KVM, rely on an external process to send events
     to the device model that the CPU would normally generate."

Based on that description, qtest should provide a command to notify
whether the CPU has work to do or not.

Meanwhile, no qtest command = no work = 'return false'.


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH v7 12/40] accel/qtest: Implement AccelOpsClass::has_work()
  2021-09-25 16:01       ` Philippe Mathieu-Daudé
@ 2021-09-27  6:12         ` Laurent Vivier
  0 siblings, 0 replies; 51+ messages in thread
From: Laurent Vivier @ 2021-09-27  6:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Richard Henderson, Paolo Bonzini, Thomas Huth
  Cc: Igor Mammedov, qemu-devel

On 25/09/2021 18:01, Philippe Mathieu-Daudé wrote:
> On 9/25/21 17:32, Richard Henderson wrote:
>> On 9/25/21 11:27 AM, Philippe Mathieu-Daudé wrote:
>>>> +static bool qtest_cpu_has_work(CPUState *cpu)
>>>> +{
>>>> +    g_assert_not_reached();
>>>> +}
>>>
>>> Sigh, this triggers:
>>>
>>> Running test qtest-i386/cpu-plug-test
>>> **
>>> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
>>> ERROR qtest-i386/cpu-plug-test - Bail out! 
>>> ERROR:../accel/qtest/qtest.c:52:qtest_cpu_has_work: code should not be reached
>>> Broken pipe
>>
>> Ha ha, yes.  You beat me to the reply within minutes.
>>
>>> I suppose it is in my interest to 'return false' here and call it
>>> a day...
>>
>> I *think* that's the right thing, but I could see maybe "true" also makes sense.  I'll 
>> try and have a closer look.
> 
> So first I tested using "-machine pc,accel=qtest" -> no crash.
> 
> Looking closely at how check-qtest calls QEMU, it does:
> "-machine pc -accel qtest". Isn't the sugar property supposed
> to work that way?
> 
> Then the backtrace is:
> 
> Thread 5 "qemu-system-i38" hit Breakpoint 1, qtest_cpu_has_work (cpu=0x555556a08400) at 
> accel/qtest/qtest.c:52
> 52          g_assert_not_reached();
> (gdb) bt
> #0  qtest_cpu_has_work (cpu=0x555556a08400) at accel/qtest/qtest.c:52
> #1  0x0000555555c330ba in cpu_has_work (cpu=0x555556a08400) at softmmu/cpus.c:254
> #2  0x0000555555c32ac8 in cpu_thread_is_idle (cpu=0x555556a08400) at softmmu/cpus.c:91
> #3  0x0000555555c33584 in qemu_wait_io_event (cpu=0x555556a08400) at softmmu/cpus.c:417
> #4  0x0000555555d8a7f4 in dummy_cpu_thread_fn (arg=0x555556a08400) at accel/dummy-cpus.c:53
> #5  0x0000555555f469f6 in qemu_thread_start (args=0x5555574edae0) at 
> util/qemu-thread-posix.c:557
> #6  0x00007ffff4ff3299 in start_thread () at /lib64/libpthread.so.0
> #7  0x00007ffff4f1b353 in clone () at /lib64/libc.so.6
> 
> dummy_cpu_thread_fn() content didn't change since its introduction
> in commit c7f0f3b1c82 ("qtest: add test framework"):
> 
>     "The idea behind qtest is pretty simple.  Instead of executing
>      a CPU via TCG or KVM, rely on an external process to send events
>      to the device model that the CPU would normally generate."
> 
> Based on that description, qtest should provide a command to notify
> whether the CPU has work to do or not.
> 
> Meanwhile, no qtest command = no work = 'return false'.
> 

In fact, with the migration test we have CPU running (it's the purpose of the test), qtest 
allows to have several accelerators, "-accel qtest" adds the qtest control in QEMU and we 
have then a KVM or TCG accel to be able to run some qtest commands with a CPU running.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2021-09-27  6:13 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25 14:50 [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 01/40] accel: Simplify qemu_init_vcpu() Philippe Mathieu-Daudé
2021-09-25 15:25   ` Richard Henderson
2021-09-25 14:50 ` [PATCH v7 02/40] hw/core: Restrict cpu_has_work() to sysemu Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 03/40] hw/core: Un-inline cpu_has_work() Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 04/40] hw/core: Move cpu_common_has_work() to cpu_has_work() Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 05/40] accel: Introduce AccelOpsClass::has_work() Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 06/40] accel/kvm: Implement AccelOpsClass::has_work() Philippe Mathieu-Daudé
2021-09-25 14:50   ` Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 07/40] accel/whpx: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 08/40] accel/hvf: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 09/40] accel/xen: " Philippe Mathieu-Daudé
2021-09-25 14:50   ` Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 10/40] accel/hax: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 11/40] accel/nvmm: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 12/40] accel/qtest: " Philippe Mathieu-Daudé
2021-09-25 15:27   ` Philippe Mathieu-Daudé
2021-09-25 15:32     ` Richard Henderson
2021-09-25 16:01       ` Philippe Mathieu-Daudé
2021-09-27  6:12         ` Laurent Vivier
2021-09-25 14:50 ` [PATCH v7 13/40] accel/tcg: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 14/40] accel: Simplify cpu_has_work() Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 15/40] accel/tcg: Introduce TCGCPUOps::has_work() Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 16/40] target/arm: Explicit v7M cores use arm_cpu_has_work as CPUClass:has_work Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 17/40] target/arm: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 18/40] target/alpha: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 19/40] target/avr: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 20/40] target/cris: " Philippe Mathieu-Daudé
2021-09-25 14:50 ` [PATCH v7 21/40] target/hexagon: Remove unused has_work() handler Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 22/40] target/hppa: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 23/40] target/i386: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 24/40] target/m68k: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 25/40] target/microblaze: " Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 26/40] target/mips: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 27/40] target/nios2: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 28/40] target/openrisc: " Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 29/40] target/ppc: Introduce PowerPCCPUClass::has_work() Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 30/40] target/ppc: Restrict has_work() handlers to sysemu and TCG Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 31/40] target/riscv: Restrict has_work() handler " Philippe Mathieu-Daudé
2021-09-25 14:51   ` Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 32/40] target/rx: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 33/40] target/s390x: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 34/40] target/sh4: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 35/40] target/sparc: Remove pointless use of CONFIG_TCG definition Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 36/40] target/sparc: Restrict has_work() handler to sysemu Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 37/40] target/tricore: " Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 38/40] target/xtensa: " Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 39/40] accel/tcg: Remove CPUClass::has_work() Philippe Mathieu-Daudé
2021-09-25 14:51 ` [PATCH v7 40/40] accel/tcg: Simplify tcg_cpu_has_work() Philippe Mathieu-Daudé
2021-09-25 15:28 ` [PATCH v7 00/40] accel: Move has_work() from CPUClass to AccelOpsClass Richard Henderson
2021-09-25 15:36   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.