All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/30] accel: Move has_work() from SysemuCPUOps to AccelOpsClass
@ 2021-09-02 16:15 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Hi,

CPU has_work() is a per-accelerator handler. This series
- explicit the KVM / WHPX implementations
- moves TCG implementations in AccelOpsClass
- explicit missing implementations (returning 'false').

Since v2:
- Full rewrite, no more RFC.

Supersedes: <20210304222323.1954755-1-f4bug@amsat.org>
"cpu: Move CPUClass::has_work() to TCGCPUOps"

Philippe Mathieu-Daudé (30):
  accel/tcg: Restrict cpu_handle_halt() to sysemu
  hw/core: Restrict cpu_has_work() to sysemu
  hw/core: Un-inline cpu_has_work()
  sysemu: Introduce AccelOpsClass::has_work()
  accel/kvm: Implement AccelOpsClass::has_work()
  accel/whpx: Implement AccelOpsClass::has_work()
  accel/tcg: Implement AccelOpsClass::has_work() as stub
  target/alpha: Restrict has_work() handler to sysemu and TCG
  target/arm: Restrict has_work() handler to sysemu and TCG
  target/avr: Restrict has_work() handler to sysemu and TCG
  target/cris: Restrict has_work() handler to sysemu and TCG
  target/hexagon: Remove unused has_work() handler
  target/hppa: Restrict has_work() handler to sysemu and TCG
  target/i386: Restrict has_work() handler to sysemu and TCG
  target/m68k: Restrict has_work() handler to sysemu and TCG
  target/microblaze: Restrict has_work() handler to sysemu and TCG
  target/mips: Restrict has_work() handler to sysemu and TCG
  target/nios2: Restrict has_work() handler to sysemu and TCG
  target/openrisc: Restrict has_work() handler to sysemu and TCG
  target/ppc: Restrict has_work() handler to sysemu and TCG
  target/ppc: Introduce PowerPCCPUClass::has_work()
  target/ppc: Simplify has_work() handlers
  target/riscv: Restrict has_work() handler to sysemu and TCG
  target/rx: Restrict has_work() handler to sysemu and TCG
  target/s390x: Restrict has_work() handler to sysemu and TCG
  target/sh4: Restrict has_work() handler to sysemu and TCG
  target/sparc: Restrict has_work() handler to sysemu and TCG
  target/tricore: Restrict has_work() handler to sysemu and TCG
  target/xtensa: Restrict has_work() handler to sysemu and TCG
  accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one

 include/hw/core/cpu.h             |  28 +--
 include/hw/core/tcg-cpu-ops.h     |   4 +
 include/sysemu/accel-ops.h        |   5 +
 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              |   8 +-
 accel/tcg/tcg-accel-ops.c         |  12 ++
 accel/xen/xen-all.c               |   6 +
 hw/core/cpu-common.c              |   6 -
 softmmu/cpus.c                    |  10 +-
 target/alpha/cpu.c                |   4 +-
 target/arm/cpu.c                  |   7 +-
 target/avr/cpu.c                  |   4 +-
 target/cris/cpu.c                 |   4 +-
 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           |  10 +-
 target/mips/cpu.c                 |   4 +-
 target/nios2/cpu.c                |   4 +-
 target/openrisc/cpu.c             |   4 +-
 target/ppc/cpu_init.c             | 324 +++++++++++++++---------------
 target/riscv/cpu.c                |   8 +-
 target/rx/cpu.c                   |   4 +-
 target/s390x/cpu.c                |   4 +-
 target/sh4/cpu.c                  |   7 +-
 target/sparc/cpu.c                |   4 +-
 target/tricore/cpu.c              |   6 +-
 target/xtensa/cpu.c               |  16 +-
 36 files changed, 321 insertions(+), 239 deletions(-)

-- 
2.31.1



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

* [PATCH v3 00/30] accel: Move has_work() from SysemuCPUOps to AccelOpsClass
@ 2021-09-02 16:15 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Hi,

CPU has_work() is a per-accelerator handler. This series
- explicit the KVM / WHPX implementations
- moves TCG implementations in AccelOpsClass
- explicit missing implementations (returning 'false').

Since v2:
- Full rewrite, no more RFC.

Supersedes: <20210304222323.1954755-1-f4bug@amsat.org>
"cpu: Move CPUClass::has_work() to TCGCPUOps"

Philippe Mathieu-Daudé (30):
  accel/tcg: Restrict cpu_handle_halt() to sysemu
  hw/core: Restrict cpu_has_work() to sysemu
  hw/core: Un-inline cpu_has_work()
  sysemu: Introduce AccelOpsClass::has_work()
  accel/kvm: Implement AccelOpsClass::has_work()
  accel/whpx: Implement AccelOpsClass::has_work()
  accel/tcg: Implement AccelOpsClass::has_work() as stub
  target/alpha: Restrict has_work() handler to sysemu and TCG
  target/arm: Restrict has_work() handler to sysemu and TCG
  target/avr: Restrict has_work() handler to sysemu and TCG
  target/cris: Restrict has_work() handler to sysemu and TCG
  target/hexagon: Remove unused has_work() handler
  target/hppa: Restrict has_work() handler to sysemu and TCG
  target/i386: Restrict has_work() handler to sysemu and TCG
  target/m68k: Restrict has_work() handler to sysemu and TCG
  target/microblaze: Restrict has_work() handler to sysemu and TCG
  target/mips: Restrict has_work() handler to sysemu and TCG
  target/nios2: Restrict has_work() handler to sysemu and TCG
  target/openrisc: Restrict has_work() handler to sysemu and TCG
  target/ppc: Restrict has_work() handler to sysemu and TCG
  target/ppc: Introduce PowerPCCPUClass::has_work()
  target/ppc: Simplify has_work() handlers
  target/riscv: Restrict has_work() handler to sysemu and TCG
  target/rx: Restrict has_work() handler to sysemu and TCG
  target/s390x: Restrict has_work() handler to sysemu and TCG
  target/sh4: Restrict has_work() handler to sysemu and TCG
  target/sparc: Restrict has_work() handler to sysemu and TCG
  target/tricore: Restrict has_work() handler to sysemu and TCG
  target/xtensa: Restrict has_work() handler to sysemu and TCG
  accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one

 include/hw/core/cpu.h             |  28 +--
 include/hw/core/tcg-cpu-ops.h     |   4 +
 include/sysemu/accel-ops.h        |   5 +
 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              |   8 +-
 accel/tcg/tcg-accel-ops.c         |  12 ++
 accel/xen/xen-all.c               |   6 +
 hw/core/cpu-common.c              |   6 -
 softmmu/cpus.c                    |  10 +-
 target/alpha/cpu.c                |   4 +-
 target/arm/cpu.c                  |   7 +-
 target/avr/cpu.c                  |   4 +-
 target/cris/cpu.c                 |   4 +-
 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           |  10 +-
 target/mips/cpu.c                 |   4 +-
 target/nios2/cpu.c                |   4 +-
 target/openrisc/cpu.c             |   4 +-
 target/ppc/cpu_init.c             | 324 +++++++++++++++---------------
 target/riscv/cpu.c                |   8 +-
 target/rx/cpu.c                   |   4 +-
 target/s390x/cpu.c                |   4 +-
 target/sh4/cpu.c                  |   7 +-
 target/sparc/cpu.c                |   4 +-
 target/tricore/cpu.c              |   6 +-
 target/xtensa/cpu.c               |  16 +-
 36 files changed, 321 insertions(+), 239 deletions(-)

-- 
2.31.1


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

* [PATCH v3 01/30] accel/tcg: Restrict cpu_handle_halt() to sysemu
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Commit 372579427a5 ("tcg: enable thread-per-vCPU") added the following
comment describing EXCP_HALTED in qemu_tcg_cpu_thread_fn():

    case EXCP_HALTED:
         /* during start-up the vCPU is reset and the thread is
          * kicked several times. If we don't ensure we go back
          * to sleep in the halted state we won't cleanly
          * start-up when the vCPU is enabled.
          *
          * cpu->halted should ensure we sleep in wait_io_event
          */
         g_assert(cpu->halted);
         break;

qemu_wait_io_event() is sysemu-specific, so we can restrict the
cpu_handle_halt() call in cpu_exec() to system emulation.

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

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 7a6dd9049f0..6b61262b151 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -586,10 +586,11 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
     return;
 }
 
+#ifndef CONFIG_USER_ONLY
 static inline bool cpu_handle_halt(CPUState *cpu)
 {
     if (cpu->halted) {
-#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY)
+#if defined(TARGET_I386)
         if (cpu->interrupt_request & CPU_INTERRUPT_POLL) {
             X86CPU *x86_cpu = X86_CPU(cpu);
             qemu_mutex_lock_iothread();
@@ -597,7 +598,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
             cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL);
             qemu_mutex_unlock_iothread();
         }
-#endif
+#endif /* TARGET_I386 */
         if (!cpu_has_work(cpu)) {
             return true;
         }
@@ -607,6 +608,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
 
     return false;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static inline void cpu_handle_debug_exception(CPUState *cpu)
 {
@@ -865,9 +867,11 @@ int cpu_exec(CPUState *cpu)
     /* replay_interrupt may need current_cpu */
     current_cpu = cpu;
 
+#ifndef CONFIG_USER_ONLY
     if (cpu_handle_halt(cpu)) {
         return EXCP_HALTED;
     }
+#endif
 
     rcu_read_lock();
 
-- 
2.31.1


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

* [PATCH v3 01/30] accel/tcg: Restrict cpu_handle_halt() to sysemu
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Commit 372579427a5 ("tcg: enable thread-per-vCPU") added the following
comment describing EXCP_HALTED in qemu_tcg_cpu_thread_fn():

    case EXCP_HALTED:
         /* during start-up the vCPU is reset and the thread is
          * kicked several times. If we don't ensure we go back
          * to sleep in the halted state we won't cleanly
          * start-up when the vCPU is enabled.
          *
          * cpu->halted should ensure we sleep in wait_io_event
          */
         g_assert(cpu->halted);
         break;

qemu_wait_io_event() is sysemu-specific, so we can restrict the
cpu_handle_halt() call in cpu_exec() to system emulation.

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

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 7a6dd9049f0..6b61262b151 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -586,10 +586,11 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
     return;
 }
 
+#ifndef CONFIG_USER_ONLY
 static inline bool cpu_handle_halt(CPUState *cpu)
 {
     if (cpu->halted) {
-#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY)
+#if defined(TARGET_I386)
         if (cpu->interrupt_request & CPU_INTERRUPT_POLL) {
             X86CPU *x86_cpu = X86_CPU(cpu);
             qemu_mutex_lock_iothread();
@@ -597,7 +598,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
             cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL);
             qemu_mutex_unlock_iothread();
         }
-#endif
+#endif /* TARGET_I386 */
         if (!cpu_has_work(cpu)) {
             return true;
         }
@@ -607,6 +608,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
 
     return false;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 static inline void cpu_handle_debug_exception(CPUState *cpu)
 {
@@ -865,9 +867,11 @@ int cpu_exec(CPUState *cpu)
     /* replay_interrupt may need current_cpu */
     current_cpu = cpu;
 
+#ifndef CONFIG_USER_ONLY
     if (cpu_handle_halt(cpu)) {
         return EXCP_HALTED;
     }
+#endif
 
     rcu_read_lock();
 
-- 
2.31.1



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

* [PATCH v3 02/30] hw/core: Restrict cpu_has_work() to sysemu
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

cpu_has_work() is only called from system emulation code.

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] 130+ messages in thread

* [PATCH v3 02/30] hw/core: Restrict cpu_has_work() to sysemu
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

cpu_has_work() is only called from system emulation code.

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] 130+ messages in thread

* [PATCH v3 03/30] hw/core: Un-inline cpu_has_work()
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

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

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 071085f840b..7e2cb2c571b 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] 130+ messages in thread

* [PATCH v3 03/30] hw/core: Un-inline cpu_has_work()
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

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

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 071085f840b..7e2cb2c571b 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] 130+ messages in thread

* [PATCH v3 04/30] sysemu: Introduce AccelOpsClass::has_work()
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

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

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 7e2cb2c571b..2a61dfd6287 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -255,6 +255,9 @@ bool cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
+    if (cpus_accel->has_work) {
+        return cpus_accel->has_work(cpu);
+    }
     g_assert(cc->has_work);
     return cc->has_work(cpu);
 }
-- 
2.31.1


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

* [PATCH v3 04/30] sysemu: Introduce AccelOpsClass::has_work()
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

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

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 7e2cb2c571b..2a61dfd6287 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -255,6 +255,9 @@ bool cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
+    if (cpus_accel->has_work) {
+        return cpus_accel->has_work(cpu);
+    }
     g_assert(cc->has_work);
     return cc->has_work(cpu);
 }
-- 
2.31.1



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

* [PATCH v3 05/30] accel/kvm: Implement AccelOpsClass::has_work()
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

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

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 2a61dfd6287..3db7bd4eb4d 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] 130+ messages in thread

* [PATCH v3 05/30] accel/kvm: Implement AccelOpsClass::has_work()
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

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

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 2a61dfd6287..3db7bd4eb4d 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] 130+ messages in thread

* [PATCH v3 06/30] accel/whpx: Implement AccelOpsClass::has_work()
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

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

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 3db7bd4eb4d..6bce52ce561 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] 130+ messages in thread

* [PATCH v3 06/30] accel/whpx: Implement AccelOpsClass::has_work()
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	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.

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 3db7bd4eb4d..6bce52ce561 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] 130+ messages in thread

* [PATCH v3 07/30] accel/tcg: Implement AccelOpsClass::has_work() as stub
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Add TCG target-specific has_work() handler in TCGCPUOps,
and add tcg_cpu_has_work() as AccelOpsClass has_work()
implementation.

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

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index bbec7760f48..919d9006e24 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 1a8e8390bd6..ed4ebe735fe 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"
@@ -73,6 +74,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->tcg_ops->has_work) {
+        return false;
+    }
+    return cc->tcg_ops->has_work(cpu);
+}
+
 /* mask must never be zero, except for A20 change call */
 void tcg_handle_interrupt(CPUState *cpu, int mask)
 {
@@ -108,6 +119,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)
-- 
2.31.1


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

* [PATCH v3 07/30] accel/tcg: Implement AccelOpsClass::has_work() as stub
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Add TCG target-specific has_work() handler in TCGCPUOps,
and add tcg_cpu_has_work() as AccelOpsClass has_work()
implementation.

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

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index bbec7760f48..919d9006e24 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 1a8e8390bd6..ed4ebe735fe 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"
@@ -73,6 +74,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->tcg_ops->has_work) {
+        return false;
+    }
+    return cc->tcg_ops->has_work(cpu);
+}
+
 /* mask must never be zero, except for A20 change call */
 void tcg_handle_interrupt(CPUState *cpu, int mask)
 {
@@ -108,6 +119,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)
-- 
2.31.1



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

* [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !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_TCG && !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] 130+ messages in thread

* [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !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_TCG && !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] 130+ messages in thread

* [PATCH v3 09/30] target/arm: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index ba0741b20e4..e11aa625a5f 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -73,8 +73,8 @@ void arm_cpu_synchronize_from_tb(CPUState *cs,
         env->regs[15] = tb->pc;
     }
 }
-#endif /* CONFIG_TCG */
 
+#ifndef CONFIG_USER_ONLY
 static bool arm_cpu_has_work(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
@@ -85,6 +85,9 @@ static 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)
@@ -2017,6 +2020,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,
@@ -2041,7 +2045,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;
-- 
2.31.1


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

* [PATCH v3 09/30] target/arm: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index ba0741b20e4..e11aa625a5f 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -73,8 +73,8 @@ void arm_cpu_synchronize_from_tb(CPUState *cs,
         env->regs[15] = tb->pc;
     }
 }
-#endif /* CONFIG_TCG */
 
+#ifndef CONFIG_USER_ONLY
 static bool arm_cpu_has_work(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
@@ -85,6 +85,9 @@ static 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)
@@ -2017,6 +2020,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,
@@ -2041,7 +2045,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;
-- 
2.31.1



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

* [PATCH v3 10/30] target/avr: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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

diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index e9fa54c9777..6267cc6d530 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -32,6 +32,7 @@ static void avr_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc_w = value / 2; /* internally PC points to words */
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool avr_cpu_has_work(CPUState *cs)
 {
     AVRCPU *cpu = AVR_CPU(cs);
@@ -40,6 +41,7 @@ static bool avr_cpu_has_work(CPUState *cs)
     return (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET))
             && cpu_interrupts_enabled(env);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void avr_cpu_synchronize_from_tb(CPUState *cs,
                                         const TranslationBlock *tb)
@@ -198,6 +200,7 @@ static const struct TCGCPUOps avr_tcg_ops = {
     .tlb_fill = avr_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = avr_cpu_has_work,
     .cpu_exec_interrupt = avr_cpu_exec_interrupt,
     .do_interrupt = avr_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -214,7 +217,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] 130+ messages in thread

* [PATCH v3 10/30] target/avr: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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

diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index e9fa54c9777..6267cc6d530 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -32,6 +32,7 @@ static void avr_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc_w = value / 2; /* internally PC points to words */
 }
 
+#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool avr_cpu_has_work(CPUState *cs)
 {
     AVRCPU *cpu = AVR_CPU(cs);
@@ -40,6 +41,7 @@ static bool avr_cpu_has_work(CPUState *cs)
     return (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET))
             && cpu_interrupts_enabled(env);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void avr_cpu_synchronize_from_tb(CPUState *cs,
                                         const TranslationBlock *tb)
@@ -198,6 +200,7 @@ static const struct TCGCPUOps avr_tcg_ops = {
     .tlb_fill = avr_cpu_tlb_fill,
 
 #ifndef CONFIG_USER_ONLY
+    .has_work = avr_cpu_has_work,
     .cpu_exec_interrupt = avr_cpu_exec_interrupt,
     .do_interrupt = avr_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
@@ -214,7 +217,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] 130+ messages in thread

* [PATCH v3 11/30] target/cris: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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

diff --git a/target/cris/cpu.c b/target/cris/cpu.c
index c2e7483f5bd..d6e486746be 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cris_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG && !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 */
@@ -294,7 +297,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] 130+ messages in thread

* [PATCH v3 11/30] target/cris: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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

diff --git a/target/cris/cpu.c b/target/cris/cpu.c
index c2e7483f5bd..d6e486746be 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool cris_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG && !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 */
@@ -294,7 +297,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] 130+ messages in thread

* [PATCH v3 12/30] target/hexagon: Remove unused has_work() handler
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

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

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] 130+ messages in thread

* [PATCH v3 12/30] target/hexagon: Remove unused has_work() handler
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

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

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] 130+ messages in thread

* [PATCH v3 13/30] target/hppa: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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 e8edd189bfc..cf1f656218f 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool hppa_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
 {
@@ -147,6 +149,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,
@@ -163,7 +166,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] 130+ messages in thread

* [PATCH v3 13/30] target/hppa: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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 e8edd189bfc..cf1f656218f 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool hppa_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
 {
@@ -147,6 +149,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,
@@ -163,7 +166,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] 130+ messages in thread

* [PATCH v3 14/30] target/i386: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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 04f59043804..b7417d29f44 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6548,11 +6548,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);
@@ -6757,7 +6752,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 fd86daf93d2..6cde53603ba 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_exception = 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] 130+ messages in thread

* [PATCH v3 14/30] target/i386: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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 04f59043804..b7417d29f44 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6548,11 +6548,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);
@@ -6757,7 +6752,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 fd86daf93d2..6cde53603ba 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_exception = 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] 130+ messages in thread

* [PATCH v3 15/30] target/m68k: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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..94b35cb4a50 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool m68k_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 15/30] target/m68k: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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..94b35cb4a50 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool m68k_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 16/30] target/microblaze: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/microblaze/cpu.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index 15db277925f..74fbb5d201a 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -92,12 +92,15 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
 }
 
+#ifndef CONFIG_USER_ONLY
+
+#ifdef CONFIG_TCG
 static bool mb_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG */
 
-#ifndef CONFIG_USER_ONLY
 static void mb_cpu_ns_axi_dp(void *opaque, int irq, int level)
 {
     MicroBlazeCPU *cpu = opaque;
@@ -142,7 +145,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 +371,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 +390,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] 130+ messages in thread

* [PATCH v3 16/30] target/microblaze: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/microblaze/cpu.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index 15db277925f..74fbb5d201a 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -92,12 +92,15 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
     cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
 }
 
+#ifndef CONFIG_USER_ONLY
+
+#ifdef CONFIG_TCG
 static bool mb_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG */
 
-#ifndef CONFIG_USER_ONLY
 static void mb_cpu_ns_axi_dp(void *opaque, int irq, int level)
 {
     MicroBlazeCPU *cpu = opaque;
@@ -142,7 +145,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 +371,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 +390,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] 130+ messages in thread

* [PATCH v3 17/30] target/mips: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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] 130+ messages in thread

* [PATCH v3 17/30] target/mips: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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] 130+ messages in thread

* [PATCH v3 18/30] target/nios2: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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..f1f976bdad7 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool nios2_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 18/30] target/nios2: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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..f1f976bdad7 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool nios2_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 19/30] target/openrisc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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..6544b549f12 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool openrisc_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD |
                                     CPU_INTERRUPT_TIMER);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 19/30] target/openrisc: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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..6544b549f12 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool openrisc_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & (CPU_INTERRUPT_HARD |
                                     CPU_INTERRUPT_TIMER);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 6aad01d1d3a..e2e721c2b81 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -8790,6 +8790,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 ppc_cpu_has_work(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -8797,6 +8798,7 @@ static bool ppc_cpu_has_work(CPUState *cs)
 
     return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void ppc_cpu_reset(DeviceState *dev)
 {
@@ -9017,6 +9019,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,
@@ -9042,7 +9045,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     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;
-- 
2.31.1


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

* [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 6aad01d1d3a..e2e721c2b81 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -8790,6 +8790,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 ppc_cpu_has_work(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -8797,6 +8798,7 @@ static bool ppc_cpu_has_work(CPUState *cs)
 
     return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
 }
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
 static void ppc_cpu_reset(DeviceState *dev)
 {
@@ -9017,6 +9019,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,
@@ -9042,7 +9045,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     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;
-- 
2.31.1



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

* [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Each POWER cpu has its own has_work() implementation. Instead of
overloading CPUClass on each PowerPCCPUClass init, register the
generic ppc_cpu_has_work() handler, and have it call the POWER
specific has_work().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu-qom.h  |  3 +++
 target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 5800fa324e8..ff2bafcde6f 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -189,6 +189,9 @@ struct PowerPCCPUClass {
     int bfd_mach;
     uint32_t l1_dcache_size, l1_icache_size;
 #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 e2e721c2b81..bbad16cc1ec 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,12 +7617,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -7673,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
@@ -7743,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);
@@ -7784,12 +7786,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -7848,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;
@@ -7941,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);
@@ -7998,12 +8001,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -8062,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;
@@ -8150,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);
@@ -8207,12 +8211,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -8275,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;
@@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
+    if (cs->halted) {
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        return pcc->has_work(cs);
+    }
+
     return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
-- 
2.31.1


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

* [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Each POWER cpu has its own has_work() implementation. Instead of
overloading CPUClass on each PowerPCCPUClass init, register the
generic ppc_cpu_has_work() handler, and have it call the POWER
specific has_work().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu-qom.h  |  3 +++
 target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 5800fa324e8..ff2bafcde6f 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -189,6 +189,9 @@ struct PowerPCCPUClass {
     int bfd_mach;
     uint32_t l1_dcache_size, l1_icache_size;
 #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 e2e721c2b81..bbad16cc1ec 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,12 +7617,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -7673,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
@@ -7743,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);
@@ -7784,12 +7786,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -7848,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;
@@ -7941,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);
@@ -7998,12 +8001,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -8062,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;
@@ -8150,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);
@@ -8207,12 +8211,12 @@ 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)
 {
     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 +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;
-    cc->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 |
@@ -8275,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;
@@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
+    if (cs->halted) {
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        return pcc->has_work(cs);
+    }
+
     return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
-- 
2.31.1



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

* [PATCH v3 22/30] target/ppc: Simplify has_work() handlers
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

The common ppc_cpu_has_work() handler already checks for cs->halted,
so we can simplify all callees.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu_init.c | 294 ++++++++++++++++++++----------------------
 1 file changed, 138 insertions(+), 156 deletions(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index bbad16cc1ec..c8ec47d58fa 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7589,33 +7589,29 @@ static bool cpu_has_work_POWER7(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
-    if (cs->halted) {
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE0)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE0)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -7750,41 +7746,37 @@ static bool cpu_has_work_POWER8(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
-    if (cs->halted) {
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE2)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE0)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE1)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE2)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE0)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE1)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -7948,58 +7940,53 @@ static bool cpu_has_work_POWER9(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
+    uint64_t psscr = env->spr[SPR_PSSCR];
 
-    if (cs->halted) {
-        uint64_t psscr = env->spr[SPR_PSSCR];
-
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-
-        /* If EC is clear, just return true on any pending interrupt */
-        if (!(psscr & PSSCR_EC)) {
-            return true;
-        }
-        /* External Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_EEE)) {
-            bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
-            if (heic == 0 || !msr_hv || msr_pr) {
-                return true;
-            }
-        }
-        /* Decrementer Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
-        }
-        /* Machine Check or Hypervisor Maintenance Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
-            1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
-            return true;
-        }
-        /* Privileged Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_PDEE)) {
-            return true;
-        }
-        /* Hypervisor Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_HDEE)) {
-            return true;
-        }
-        /* Hypervisor virtualization exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
-            (env->spr[SPR_LPCR] & LPCR_HVEE)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+
+    /* If EC is clear, just return true on any pending interrupt */
+    if (!(psscr & PSSCR_EC)) {
+        return true;
+    }
+    /* External Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_EEE)) {
+        bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
+        if (heic == 0 || !msr_hv || msr_pr) {
+            return true;
+        }
+    }
+    /* Decrementer Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_DEE)) {
+        return true;
+    }
+    /* Machine Check or Hypervisor Maintenance Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
+        1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
+        return true;
+    }
+    /* Privileged Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_PDEE)) {
+        return true;
+    }
+    /* Hypervisor Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_HDEE)) {
+        return true;
+    }
+    /* Hypervisor virtualization exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
+        (env->spr[SPR_LPCR] & LPCR_HVEE)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -8158,58 +8145,53 @@ static bool cpu_has_work_POWER10(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
+    uint64_t psscr = env->spr[SPR_PSSCR];
 
-    if (cs->halted) {
-        uint64_t psscr = env->spr[SPR_PSSCR];
-
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-
-        /* If EC is clear, just return true on any pending interrupt */
-        if (!(psscr & PSSCR_EC)) {
-            return true;
-        }
-        /* External Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_EEE)) {
-            bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
-            if (heic == 0 || !msr_hv || msr_pr) {
-                return true;
-            }
-        }
-        /* Decrementer Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
-        }
-        /* Machine Check or Hypervisor Maintenance Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
-            1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
-            return true;
-        }
-        /* Privileged Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_PDEE)) {
-            return true;
-        }
-        /* Hypervisor Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_HDEE)) {
-            return true;
-        }
-        /* Hypervisor virtualization exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
-            (env->spr[SPR_LPCR] & LPCR_HVEE)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+
+    /* If EC is clear, just return true on any pending interrupt */
+    if (!(psscr & PSSCR_EC)) {
+        return true;
+    }
+    /* External Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_EEE)) {
+        bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
+        if (heic == 0 || !msr_hv || msr_pr) {
+            return true;
+        }
+    }
+    /* Decrementer Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_DEE)) {
+        return true;
+    }
+    /* Machine Check or Hypervisor Maintenance Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
+        1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
+        return true;
+    }
+    /* Privileged Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_PDEE)) {
+        return true;
+    }
+    /* Hypervisor Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_HDEE)) {
+        return true;
+    }
+    /* Hypervisor virtualization exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
+        (env->spr[SPR_LPCR] & LPCR_HVEE)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
-- 
2.31.1


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

* [PATCH v3 22/30] target/ppc: Simplify has_work() handlers
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

The common ppc_cpu_has_work() handler already checks for cs->halted,
so we can simplify all callees.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/cpu_init.c | 294 ++++++++++++++++++++----------------------
 1 file changed, 138 insertions(+), 156 deletions(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index bbad16cc1ec..c8ec47d58fa 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7589,33 +7589,29 @@ static bool cpu_has_work_POWER7(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
-    if (cs->halted) {
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE0)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
-            (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE0)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
+        (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -7750,41 +7746,37 @@ static bool cpu_has_work_POWER8(CPUState *cs)
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
 
-    if (cs->halted) {
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE2)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE0)) {
-            return true;
-        }
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_P8_PECE1)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE2)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE0)) {
+        return true;
+    }
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_P8_PECE1)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -7948,58 +7940,53 @@ static bool cpu_has_work_POWER9(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
+    uint64_t psscr = env->spr[SPR_PSSCR];
 
-    if (cs->halted) {
-        uint64_t psscr = env->spr[SPR_PSSCR];
-
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-
-        /* If EC is clear, just return true on any pending interrupt */
-        if (!(psscr & PSSCR_EC)) {
-            return true;
-        }
-        /* External Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_EEE)) {
-            bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
-            if (heic == 0 || !msr_hv || msr_pr) {
-                return true;
-            }
-        }
-        /* Decrementer Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
-        }
-        /* Machine Check or Hypervisor Maintenance Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
-            1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
-            return true;
-        }
-        /* Privileged Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_PDEE)) {
-            return true;
-        }
-        /* Hypervisor Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_HDEE)) {
-            return true;
-        }
-        /* Hypervisor virtualization exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
-            (env->spr[SPR_LPCR] & LPCR_HVEE)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+
+    /* If EC is clear, just return true on any pending interrupt */
+    if (!(psscr & PSSCR_EC)) {
+        return true;
+    }
+    /* External Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_EEE)) {
+        bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
+        if (heic == 0 || !msr_hv || msr_pr) {
+            return true;
+        }
+    }
+    /* Decrementer Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_DEE)) {
+        return true;
+    }
+    /* Machine Check or Hypervisor Maintenance Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
+        1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
+        return true;
+    }
+    /* Privileged Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_PDEE)) {
+        return true;
+    }
+    /* Hypervisor Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_HDEE)) {
+        return true;
+    }
+    /* Hypervisor virtualization exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
+        (env->spr[SPR_LPCR] & LPCR_HVEE)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
@@ -8158,58 +8145,53 @@ static bool cpu_has_work_POWER10(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     CPUPPCState *env = &cpu->env;
+    uint64_t psscr = env->spr[SPR_PSSCR];
 
-    if (cs->halted) {
-        uint64_t psscr = env->spr[SPR_PSSCR];
-
-        if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-            return false;
-        }
-
-        /* If EC is clear, just return true on any pending interrupt */
-        if (!(psscr & PSSCR_EC)) {
-            return true;
-        }
-        /* External Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
-            (env->spr[SPR_LPCR] & LPCR_EEE)) {
-            bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
-            if (heic == 0 || !msr_hv || msr_pr) {
-                return true;
-            }
-        }
-        /* Decrementer Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
-            (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
-        }
-        /* Machine Check or Hypervisor Maintenance Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
-            1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
-            return true;
-        }
-        /* Privileged Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_PDEE)) {
-            return true;
-        }
-        /* Hypervisor Doorbell Exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
-            (env->spr[SPR_LPCR] & LPCR_HDEE)) {
-            return true;
-        }
-        /* Hypervisor virtualization exception */
-        if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
-            (env->spr[SPR_LPCR] & LPCR_HVEE)) {
-            return true;
-        }
-        if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
-            return true;
-        }
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
         return false;
-    } else {
-        return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
     }
+
+    /* If EC is clear, just return true on any pending interrupt */
+    if (!(psscr & PSSCR_EC)) {
+        return true;
+    }
+    /* External Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) &&
+        (env->spr[SPR_LPCR] & LPCR_EEE)) {
+        bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC);
+        if (heic == 0 || !msr_hv || msr_pr) {
+            return true;
+        }
+    }
+    /* Decrementer Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
+        (env->spr[SPR_LPCR] & LPCR_DEE)) {
+        return true;
+    }
+    /* Machine Check or Hypervisor Maintenance Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
+        1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) {
+        return true;
+    }
+    /* Privileged Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_PDEE)) {
+        return true;
+    }
+    /* Hypervisor Doorbell Exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) &&
+        (env->spr[SPR_LPCR] & LPCR_HDEE)) {
+        return true;
+    }
+    /* Hypervisor virtualization exception */
+    if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) &&
+        (env->spr[SPR_LPCR] & LPCR_HVEE)) {
+        return true;
+    }
+    if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) {
+        return true;
+    }
+    return false;
 }
 #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
 
-- 
2.31.1



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

* [PATCH v3 23/30] target/riscv: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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 13575c14085..abb555a8bdb 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)
@@ -647,6 +645,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,
@@ -666,7 +665,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] 130+ messages in thread

* [PATCH v3 23/30] target/riscv: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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 13575c14085..abb555a8bdb 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)
@@ -647,6 +645,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,
@@ -666,7 +665,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] 130+ messages in thread

* [PATCH v3 24/30] target/rx: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, David Gibson, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, Philippe Mathieu-Daudé,
	xen-devel, Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

Restrict has_work() to TCG sysemu.

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..0d0cf6f9028 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool rx_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request &
         (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 24/30] target/rx: Restrict has_work() handler to sysemu and TCG
@ 2021-09-02 16:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-02 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, David Gibson, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aurelien Jarno,
	Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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..0d0cf6f9028 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool rx_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request &
         (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR);
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* Re: [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03  0:49     ` David Gibson
  -1 siblings, 0 replies; 130+ messages in thread
From: David Gibson @ 2021-09-03  0:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, xen-devel, Marek Vasut, Stefano Stabellini,
	Aleksandar Rikalo, Mark Cave-Ayland, Colin Xu, Claudio Fontana,
	Palmer Dabbelt, Stafford Horne, Reinoud Zandijk, kvm

[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]

On Thu, Sep 02, 2021 at 06:15:33PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/cpu_init.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 6aad01d1d3a..e2e721c2b81 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -8790,6 +8790,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 ppc_cpu_has_work(CPUState *cs)
>  {
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
> @@ -8797,6 +8798,7 @@ static bool ppc_cpu_has_work(CPUState *cs)
>  
>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>  }
> +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
>  
>  static void ppc_cpu_reset(DeviceState *dev)
>  {
> @@ -9017,6 +9019,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,
> @@ -9042,7 +9045,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
>      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;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03  0:49     ` David Gibson
  0 siblings, 0 replies; 130+ messages in thread
From: David Gibson @ 2021-09-03  0:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Edgar E. Iglesias,
	Stafford Horne, Marek Vasut, Stefano Stabellini, Yoshinori Sato,
	Paul Durrant, Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aleksandar Rikalo,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]

On Thu, Sep 02, 2021 at 06:15:33PM +0200, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/cpu_init.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 6aad01d1d3a..e2e721c2b81 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -8790,6 +8790,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 ppc_cpu_has_work(CPUState *cs)
>  {
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
> @@ -8797,6 +8798,7 @@ static bool ppc_cpu_has_work(CPUState *cs)
>  
>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>  }
> +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
>  
>  static void ppc_cpu_reset(DeviceState *dev)
>  {
> @@ -9017,6 +9019,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,
> @@ -9042,7 +9045,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
>      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;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03  0:50     ` David Gibson
  -1 siblings, 0 replies; 130+ messages in thread
From: David Gibson @ 2021-09-03  0:50 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Richard Henderson, Bastian Koppelmann,
	Yoshinori Sato, Artyom Tarasenko, Aurelien Jarno, Paul Durrant,
	Peter Maydell, Alistair Francis, Edgar E. Iglesias,
	Roman Bolshakov, Laurent Vivier, Cornelia Huck, qemu-arm,
	Wenchao Wang, xen-devel, Marek Vasut, Stefano Stabellini,
	Aleksandar Rikalo, Mark Cave-Ayland, Colin Xu, Claudio Fontana,
	Palmer Dabbelt, Stafford Horne, Reinoud Zandijk, kvm

[-- Attachment #1: Type: text/plain, Size: 8607 bytes --]

On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
> Each POWER cpu has its own has_work() implementation. Instead of
> overloading CPUClass on each PowerPCCPUClass init, register the
> generic ppc_cpu_has_work() handler, and have it call the POWER
> specific has_work().

I don't quite see the rationale for introducing a second layer of
indirection here.  What's wrong with switching the base has_work for
each cpu variant?

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/ppc/cpu-qom.h  |  3 +++
>  target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
>  2 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index 5800fa324e8..ff2bafcde6f 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -189,6 +189,9 @@ struct PowerPCCPUClass {
>      int bfd_mach;
>      uint32_t l1_dcache_size, l1_icache_size;
>  #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 e2e721c2b81..bbad16cc1ec 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,12 +7617,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -7673,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
> @@ -7743,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);
> @@ -7784,12 +7786,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -7848,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;
> @@ -7941,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);
> @@ -7998,12 +8001,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -8062,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;
> @@ -8150,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);
> @@ -8207,12 +8211,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -8275,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;
> @@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>      CPUPPCState *env = &cpu->env;
>  
> +    if (cs->halted) {
> +        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
> +
> +        return pcc->has_work(cs);
> +    }
> +
>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>  }
>  #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-03  0:50     ` David Gibson
  0 siblings, 0 replies; 130+ messages in thread
From: David Gibson @ 2021-09-03  0:50 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Edgar E. Iglesias,
	Stafford Horne, Marek Vasut, Stefano Stabellini, Yoshinori Sato,
	Paul Durrant, Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aleksandar Rikalo,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 8607 bytes --]

On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
> Each POWER cpu has its own has_work() implementation. Instead of
> overloading CPUClass on each PowerPCCPUClass init, register the
> generic ppc_cpu_has_work() handler, and have it call the POWER
> specific has_work().

I don't quite see the rationale for introducing a second layer of
indirection here.  What's wrong with switching the base has_work for
each cpu variant?

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/ppc/cpu-qom.h  |  3 +++
>  target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
>  2 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
> index 5800fa324e8..ff2bafcde6f 100644
> --- a/target/ppc/cpu-qom.h
> +++ b/target/ppc/cpu-qom.h
> @@ -189,6 +189,9 @@ struct PowerPCCPUClass {
>      int bfd_mach;
>      uint32_t l1_dcache_size, l1_icache_size;
>  #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 e2e721c2b81..bbad16cc1ec 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,12 +7617,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -7673,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
> @@ -7743,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);
> @@ -7784,12 +7786,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -7848,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;
> @@ -7941,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);
> @@ -7998,12 +8001,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -8062,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;
> @@ -8150,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);
> @@ -8207,12 +8211,12 @@ 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)
>  {
>      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 +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;
> -    cc->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 |
> @@ -8275,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;
> @@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>      CPUPPCState *env = &cpu->env;
>  
> +    if (cs->halted) {
> +        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
> +
> +        return pcc->has_work(cs);
> +    }
> +
>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>  }
>  #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH v3 25/30] target/s390x: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
                   ` (24 preceding siblings ...)
  (?)
@ 2021-09-03 17:55 ` Philippe Mathieu-Daudé
  2021-09-03 20:44   ` Richard Henderson
  -1 siblings, 1 reply; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 17:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, David Hildenbrand, Cornelia Huck, Richard Henderson,
	Philippe Mathieu-Daudé,
	qemu-s390x

Restrict has_work() to TCG sysemu.

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

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] 130+ messages in thread

* [PATCH v3 26/30] target/sh4: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
                   ` (25 preceding siblings ...)
  (?)
@ 2021-09-03 18:13 ` Philippe Mathieu-Daudé
  2021-09-03 20:45   ` Richard Henderson
  -1 siblings, 1 reply; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Yoshinori Sato

Restrict has_work() to TCG sysemu.

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

diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 2047742d03c..6c47d28631c 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -58,12 +58,15 @@ static bool superh_io_recompile_replay_branch(CPUState *cs,
     }
     return false;
 }
-#endif
 
+#if defined(CONFIG_TCG)
 static bool superh_cpu_has_work(CPUState *cs)
 {
     return cs->interrupt_request & CPU_INTERRUPT_HARD;
 }
+#endif /* CONFIG_TCG */
+
+#endif /* !CONFIG_USER_ONLY */
 
 static void superh_cpu_reset(DeviceState *dev)
 {
@@ -239,6 +242,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 +262,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] 130+ messages in thread

* [PATCH v3 27/30] target/sparc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
                   ` (26 preceding siblings ...)
  (?)
@ 2021-09-03 18:14 ` Philippe Mathieu-Daudé
  2021-09-03 20:46   ` Richard Henderson
  -1 siblings, 1 reply; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mark Cave-Ayland, Richard Henderson, Philippe Mathieu-Daudé,
	Artyom Tarasenko

Restrict has_work() to TCG sysemu.

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 5a8a4ce7506..bb28ea78bfb 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_TCG) && !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_TCG && !CONFIG_USER_ONLY */
 
 static char *sparc_cpu_type_name(const char *cpu_model)
 {
@@ -868,6 +870,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,
@@ -890,7 +893,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] 130+ messages in thread

* [PATCH v3 28/30] target/tricore: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
                   ` (27 preceding siblings ...)
  (?)
@ 2021-09-03 18:14 ` Philippe Mathieu-Daudé
  2021-09-03 20:46   ` Richard Henderson
  -1 siblings, 1 reply; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Bastian Koppelmann, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

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..728da5d4ee3 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_TCG) && !defined(CONFIG_USER_ONLY)
 static bool tricore_cpu_has_work(CPUState *cs)
 {
     return true;
 }
+#endif /* CONFIG_TCG && !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] 130+ messages in thread

* [PATCH v3 29/30] target/xtensa: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
                   ` (28 preceding siblings ...)
  (?)
@ 2021-09-03 18:15 ` Philippe Mathieu-Daudé
  2021-09-03 20:47   ` Richard Henderson
  -1 siblings, 1 reply; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov, Richard Henderson, Philippe Mathieu-Daudé

Restrict has_work() to TCG sysemu.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/xtensa/cpu.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index c1cbd03595e..f7c3f368737 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -43,18 +43,19 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.pc = value;
 }
 
+#ifndef CONFIG_USER_ONLY
+
+#if defined(CONFIG_TCG)
 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
 }
+#endif /* CONFIG_TCG */
+
+#else /* CONFIG_USER_ONLY*/
 
-#ifdef CONFIG_USER_ONLY
 static bool abi_call0;
 
 void xtensa_set_abi_call0(void)
@@ -66,7 +67,8 @@ bool xtensa_abi_call0(void)
 {
     return abi_call0;
 }
-#endif
+
+#endif /* CONFIG_USER_ONLY */
 
 static void xtensa_cpu_reset(DeviceState *dev)
 {
@@ -196,6 +198,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 +218,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] 130+ messages in thread

* [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
  2021-09-02 16:15 ` Philippe Mathieu-Daudé
@ 2021-09-03 18:19   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Anthony Perard, Cameron Esfahani,
	Claudio Fontana, Colin Xu, Eduardo Habkost, haxm-team,
	Kamil Rytarowski, Laurent Vivier, Paolo Bonzini, Paul Durrant,
	Reinoud Zandijk, Roman Bolshakov, Stefano Stabellini,
	Thomas Huth, Wenchao Wang, xen-devel, Philippe Mathieu-Daudé

cpu_common_has_work() is the default has_work() implementation
and returns 'false'.

Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
and remove cpu_common_has_work().

Since there are no more implementations of SysemuCPUOps::has_work,
remove it along with the assertion in cpu_has_work().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h             | 2 --
 accel/hvf/hvf-accel-ops.c         | 6 ++++++
 accel/qtest/qtest.c               | 6 ++++++
 accel/xen/xen-all.c               | 6 ++++++
 hw/core/cpu-common.c              | 6 ------
 softmmu/cpus.c                    | 9 ++-------
 target/i386/hax/hax-accel-ops.c   | 6 ++++++
 target/i386/nvmm/nvmm-accel-ops.c | 6 ++++++
 8 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e2dd171a13f..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.
  * @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/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index d1691be9896..53c427ee42e 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -446,6 +446,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);
@@ -456,6 +461,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"),
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d52..eb5a17cef18 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)
+{
+    return false;
+}
+
 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 = {
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 = {
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 6bce52ce561..e6dad2243c6 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -251,13 +251,8 @@ void cpu_interrupt(CPUState *cpu, int mask)
 
 bool cpu_has_work(CPUState *cpu)
 {
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    if (cpus_accel->has_work) {
-        return cpus_accel->has_work(cpu);
-    }
-    g_assert(cc->has_work);
-    return cc->has_work(cpu);
+    g_assert(cpus_accel->has_work);
+    return cpus_accel->has_work(cpu);
 }
 
 static int do_vm_stop(RunState state, bool send_stop)
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 = {
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] 130+ messages in thread

* [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
@ 2021-09-03 18:19   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 18:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Eduardo Habkost,
	Paul Durrant, Richard Henderson, Roman Bolshakov,
	Cameron Esfahani, Philippe Mathieu-Daudé,
	Kamil Rytarowski, Wenchao Wang, haxm-team, Claudio Fontana,
	xen-devel, Anthony Perard, Paolo Bonzini, Reinoud Zandijk,
	Colin Xu

cpu_common_has_work() is the default has_work() implementation
and returns 'false'.

Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
and remove cpu_common_has_work().

Since there are no more implementations of SysemuCPUOps::has_work,
remove it along with the assertion in cpu_has_work().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/core/cpu.h             | 2 --
 accel/hvf/hvf-accel-ops.c         | 6 ++++++
 accel/qtest/qtest.c               | 6 ++++++
 accel/xen/xen-all.c               | 6 ++++++
 hw/core/cpu-common.c              | 6 ------
 softmmu/cpus.c                    | 9 ++-------
 target/i386/hax/hax-accel-ops.c   | 6 ++++++
 target/i386/nvmm/nvmm-accel-ops.c | 6 ++++++
 8 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e2dd171a13f..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.
  * @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/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index d1691be9896..53c427ee42e 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -446,6 +446,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);
@@ -456,6 +461,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"),
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d52..eb5a17cef18 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)
+{
+    return false;
+}
+
 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 = {
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 = {
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 6bce52ce561..e6dad2243c6 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -251,13 +251,8 @@ void cpu_interrupt(CPUState *cpu, int mask)
 
 bool cpu_has_work(CPUState *cpu)
 {
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    if (cpus_accel->has_work) {
-        return cpus_accel->has_work(cpu);
-    }
-    g_assert(cc->has_work);
-    return cc->has_work(cpu);
+    g_assert(cpus_accel->has_work);
+    return cpus_accel->has_work(cpu);
 }
 
 static int do_vm_stop(RunState state, bool send_stop)
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 = {
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] 130+ messages in thread

* Re: [PATCH v3 01/30] accel/tcg: Restrict cpu_handle_halt() to sysemu
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 19:31     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 19:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> +#ifndef CONFIG_USER_ONLY
>   static inline bool cpu_handle_halt(CPUState *cpu)
>   {

Hmm, slightly better to move the ifdef just inside here,

> @@ -607,6 +608,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
>   

and here,

>       return false;
>   }
> +#endif /* !CONFIG_USER_ONLY */
>   
>   static inline void cpu_handle_debug_exception(CPUState *cpu)
>   {
> @@ -865,9 +867,11 @@ int cpu_exec(CPUState *cpu)
>       /* replay_interrupt may need current_cpu */
>       current_cpu = cpu;
>   
> +#ifndef CONFIG_USER_ONLY
>       if (cpu_handle_halt(cpu)) {
>           return EXCP_HALTED;
>       }
> +#endif

which would eliminate this one.


r~

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

* Re: [PATCH v3 01/30] accel/tcg: Restrict cpu_handle_halt() to sysemu
@ 2021-09-03 19:31     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 19:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> +#ifndef CONFIG_USER_ONLY
>   static inline bool cpu_handle_halt(CPUState *cpu)
>   {

Hmm, slightly better to move the ifdef just inside here,

> @@ -607,6 +608,7 @@ static inline bool cpu_handle_halt(CPUState *cpu)
>   

and here,

>       return false;
>   }
> +#endif /* !CONFIG_USER_ONLY */
>   
>   static inline void cpu_handle_debug_exception(CPUState *cpu)
>   {
> @@ -865,9 +867,11 @@ int cpu_exec(CPUState *cpu)
>       /* replay_interrupt may need current_cpu */
>       current_cpu = cpu;
>   
> +#ifndef CONFIG_USER_ONLY
>       if (cpu_handle_halt(cpu)) {
>           return EXCP_HALTED;
>       }
> +#endif

which would eliminate this one.


r~


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

* Re: [PATCH v3 02/30] hw/core: Restrict cpu_has_work() to sysemu
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:11     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> cpu_has_work() is only called from system emulation code.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h | 32 ++++++++++++++++----------------
>   1 file changed, 16 insertions(+), 16 deletions(-)

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

r~

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

* Re: [PATCH v3 02/30] hw/core: Restrict cpu_has_work() to sysemu
@ 2021-09-03 20:11     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> cpu_has_work() is only called from system emulation code.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h | 32 ++++++++++++++++----------------
>   1 file changed, 16 insertions(+), 16 deletions(-)

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

r~


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

* Re: [PATCH v3 03/30] hw/core: Un-inline cpu_has_work()
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:11     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> We want to make cpu_has_work() per-accelerator. Only declare its
> prototype and move its definition to softmmu/cpus.c.
> 
> 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(-)

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

r~

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

* Re: [PATCH v3 03/30] hw/core: Un-inline cpu_has_work()
@ 2021-09-03 20:11     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> We want to make cpu_has_work() per-accelerator. Only declare its
> prototype and move its definition to softmmu/cpus.c.
> 
> 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(-)

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

r~


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

* Re: [PATCH v3 04/30] sysemu: Introduce AccelOpsClass::has_work()
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:14     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Introduce an accelerator-specific has_work() handler.
> Eventually call it from cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/sysemu/accel-ops.h | 5 +++++
>   softmmu/cpus.c             | 3 +++
>   2 files changed, 8 insertions(+)

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

r~

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

* Re: [PATCH v3 04/30] sysemu: Introduce AccelOpsClass::has_work()
@ 2021-09-03 20:14     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Introduce an accelerator-specific has_work() handler.
> Eventually call it from cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/sysemu/accel-ops.h | 5 +++++
>   softmmu/cpus.c             | 3 +++
>   2 files changed, 8 insertions(+)

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

r~


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

* Re: [PATCH v3 05/30] accel/kvm: Implement AccelOpsClass::has_work()
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:15     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Implement KVM has_work() handler in AccelOpsClass and
> remove it from cpu_thread_is_idle() since cpu_has_work()
> is already called.
> 
> 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(-)

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

r~

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

* Re: [PATCH v3 05/30] accel/kvm: Implement AccelOpsClass::has_work()
@ 2021-09-03 20:15     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Implement KVM has_work() handler in AccelOpsClass and
> remove it from cpu_thread_is_idle() since cpu_has_work()
> is already called.
> 
> 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(-)

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

r~


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

* Re: [PATCH v3 06/30] accel/whpx: Implement AccelOpsClass::has_work()
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:16     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Implement WHPX has_work() handler in AccelOpsClass and
> remove it from cpu_thread_is_idle() since cpu_has_work()
> is already called.
> 
> 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(-)

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

r~

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

* Re: [PATCH v3 06/30] accel/whpx: Implement AccelOpsClass::has_work()
@ 2021-09-03 20:16     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Implement WHPX has_work() handler in AccelOpsClass and
> remove it from cpu_thread_is_idle() since cpu_has_work()
> is already called.
> 
> 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(-)

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

r~


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

* Re: [PATCH v3 07/30] accel/tcg: Implement AccelOpsClass::has_work() as stub
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:17     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Add TCG target-specific has_work() handler in TCGCPUOps,
> and add tcg_cpu_has_work() as AccelOpsClass has_work()
> implementation.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/tcg-cpu-ops.h |  4 ++++
>   accel/tcg/tcg-accel-ops.c     | 12 ++++++++++++
>   2 files changed, 16 insertions(+)

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

r~

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

* Re: [PATCH v3 07/30] accel/tcg: Implement AccelOpsClass::has_work() as stub
@ 2021-09-03 20:17     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Add TCG target-specific has_work() handler in TCGCPUOps,
> and add tcg_cpu_has_work() as AccelOpsClass has_work()
> implementation.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/tcg-cpu-ops.h |  4 ++++
>   accel/tcg/tcg-accel-ops.c     | 12 ++++++++++++
>   2 files changed, 16 insertions(+)

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

r~


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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:18     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool alpha_cpu_has_work(CPUState *cs)

Drop CONFIG_TCG for alpha; it's always true.

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

r~

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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:18     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool alpha_cpu_has_work(CPUState *cs)

Drop CONFIG_TCG for alpha; it's always true.

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

r~


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

* Re: [PATCH v3 09/30] target/arm: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:19     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/arm/cpu.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

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

r~

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

* Re: [PATCH v3 09/30] target/arm: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:19     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/arm/cpu.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

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

r~


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

* Re: [PATCH v3 10/30] target/avr: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:20     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/avr/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> index e9fa54c9777..6267cc6d530 100644
> --- a/target/avr/cpu.c
> +++ b/target/avr/cpu.c
> @@ -32,6 +32,7 @@ static void avr_cpu_set_pc(CPUState *cs, vaddr value)
>       cpu->env.pc_w = value / 2; /* internally PC points to words */
>   }
>   
> +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool avr_cpu_has_work(CPUState *cs)

No CONFIG_TCG or CONFIG_USER_ONLY test for avr.

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


r~

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

* Re: [PATCH v3 10/30] target/avr: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:20     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/avr/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> index e9fa54c9777..6267cc6d530 100644
> --- a/target/avr/cpu.c
> +++ b/target/avr/cpu.c
> @@ -32,6 +32,7 @@ static void avr_cpu_set_pc(CPUState *cs, vaddr value)
>       cpu->env.pc_w = value / 2; /* internally PC points to words */
>   }
>   
> +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool avr_cpu_has_work(CPUState *cs)

No CONFIG_TCG or CONFIG_USER_ONLY test for avr.

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


r~


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

* Re: [PATCH v3 11/30] target/cris: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:21     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool cris_cpu_has_work(CPUState *cs)

No CONFIG_TCG for cris.  Otherwise,

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


r~

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

* Re: [PATCH v3 11/30] target/cris: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:21     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool cris_cpu_has_work(CPUState *cs)

No CONFIG_TCG for cris.  Otherwise,

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


r~


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

* Re: [PATCH v3 12/30] target/hexagon: Remove unused has_work() handler
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:21     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> has_work() is sysemu specific, and Hexagon target only provides
> a linux-user implementation. Remove the unused hexagon_cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/hexagon/cpu.c | 6 ------
>   1 file changed, 6 deletions(-)

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

r~

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

* Re: [PATCH v3 12/30] target/hexagon: Remove unused has_work() handler
@ 2021-09-03 20:21     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> has_work() is sysemu specific, and Hexagon target only provides
> a linux-user implementation. Remove the unused hexagon_cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/hexagon/cpu.c | 6 ------
>   1 file changed, 6 deletions(-)

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

r~


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

* Re: [PATCH v3 13/30] target/hppa: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:22     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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 e8edd189bfc..cf1f656218f 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool hppa_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 13/30] target/hppa: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:22     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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 e8edd189bfc..cf1f656218f 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool hppa_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 14/30] target/i386: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:23     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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(-)

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

r~

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

* Re: [PATCH v3 14/30] target/i386: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:23     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:23 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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(-)

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

r~


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

* Re: [PATCH v3 15/30] target/m68k: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:24     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..94b35cb4a50 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool m68k_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 15/30] target/m68k: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:24     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..94b35cb4a50 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool m68k_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 16/30] target/microblaze: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:25     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/microblaze/cpu.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> index 15db277925f..74fbb5d201a 100644
> --- a/target/microblaze/cpu.c
> +++ b/target/microblaze/cpu.c
> @@ -92,12 +92,15 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
>       cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
>   }
>   
> +#ifndef CONFIG_USER_ONLY
> +
> +#ifdef CONFIG_TCG
>   static bool mb_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 16/30] target/microblaze: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:25     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/microblaze/cpu.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> index 15db277925f..74fbb5d201a 100644
> --- a/target/microblaze/cpu.c
> +++ b/target/microblaze/cpu.c
> @@ -92,12 +92,15 @@ static void mb_cpu_synchronize_from_tb(CPUState *cs,
>       cpu->env.iflags = tb->flags & IFLAGS_TB_MASK;
>   }
>   
> +#ifndef CONFIG_USER_ONLY
> +
> +#ifdef CONFIG_TCG
>   static bool mb_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 17/30] target/mips: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:26     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/mips/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

r~

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

* Re: [PATCH v3 17/30] target/mips: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:26     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/mips/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

r~


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

* Re: [PATCH v3 18/30] target/nios2: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:31     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..f1f976bdad7 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool nios2_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 18/30] target/nios2: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:31     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..f1f976bdad7 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool nios2_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 19/30] target/openrisc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:31     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..6544b549f12 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool openrisc_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 19/30] target/openrisc: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:31     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..6544b549f12 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool openrisc_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
  2021-09-03 20:18     ` Richard Henderson
@ 2021-09-03 20:34       ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 20:34 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/3/21 10:18 PM, Richard Henderson wrote:
> On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
>> Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !defined(CONFIG_USER_ONLY)
>>   static bool alpha_cpu_has_work(CPUState *cs)
> 
> Drop CONFIG_TCG for alpha; it's always true.

What is the rational? "Old" architectures (with no active /
official hw development) are unlikely to add hardware
acceleration, so TCG is the single one possible? Thus no
need to clutter the code with obvious #ifdef'ry?

> Otherwise,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> r~
> 

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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:34       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 20:34 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Thomas Huth, Max Filippov, Taylor Simpson,
	haxm-team, Colin Xu, Edgar E. Iglesias, Sunil Muthuswamy,
	Marek Vasut, Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Aleksandar Rikalo, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Paolo Bonzini, qemu-ppc,
	Stafford Horne, David Gibson, qemu-riscv, Bastian Koppelmann,
	Cornelia Huck, Roman Bolshakov, Laurent Vivier, Palmer Dabbelt,
	Wenchao Wang, Alistair Francis, Aurelien Jarno

On 9/3/21 10:18 PM, Richard Henderson wrote:
> On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
>> Restrict has_work() to TCG 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..32cf5a2ea9f 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_TCG) && !defined(CONFIG_USER_ONLY)
>>   static bool alpha_cpu_has_work(CPUState *cs)
> 
> Drop CONFIG_TCG for alpha; it's always true.

What is the rational? "Old" architectures (with no active /
official hw development) are unlikely to add hardware
acceleration, so TCG is the single one possible? Thus no
need to clutter the code with obvious #ifdef'ry?

> Otherwise,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> r~
> 


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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-03  0:50     ` David Gibson
@ 2021-09-03 20:38       ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 20:38 UTC (permalink / raw)
  To: David Gibson
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Jiaxun Yang, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Stafford Horne, Marek Vasut, Stefano Stabellini, Yoshinori Sato,
	Paul Durrant, Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Marcel Apfelbaum, Anthony Perard, xen-devel, Artyom Tarasenko,
	Laurent Vivier, Thomas Huth, Eduardo Habkost, Richard Henderson,
	Greg Kurz, Cameron Esfahani, qemu-s390x, qemu-arm,
	Michael Rolnik, Sunil Muthuswamy, Palmer Dabbelt, qemu-riscv,
	Bastian Koppelmann, Chris Wulff, Roman Bolshakov, qemu-ppc,
	Wenchao Wang, Alistair Francis, Paolo Bonzini, Aleksandar Rikalo,
	Aurelien Jarno

On 9/3/21 2:50 AM, David Gibson wrote:
> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>> Each POWER cpu has its own has_work() implementation. Instead of
>> overloading CPUClass on each PowerPCCPUClass init, register the
>> generic ppc_cpu_has_work() handler, and have it call the POWER
>> specific has_work().
> 
> I don't quite see the rationale for introducing a second layer of
> indirection here.  What's wrong with switching the base has_work for
> each cpu variant?
> 
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  target/ppc/cpu-qom.h  |  3 +++
>>  target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
>>  2 files changed, 21 insertions(+), 8 deletions(-)

>> @@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
>>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>>      CPUPPCState *env = &cpu->env;
>>  
>> +    if (cs->halted) {
>> +        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);

Maybe I should have kept the 'if (cs->halted)' for the next patch,
simply dispatch here, then in the next patch the code simplification
is more apparent. I thought this approach would involve less #ifdef'ry
but haven't checked the other way around. Will do now.

>> +        return pcc->has_work(cs);
>> +    }
>> +
>>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>>  }
>>  #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
> 

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-03 20:38       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 20:38 UTC (permalink / raw)
  To: David Gibson
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Taylor Simpson,
	haxm-team, Colin Xu, Sunil Muthuswamy, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Richard Henderson, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Paolo Bonzini, qemu-ppc, Stafford Horne, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Roman Bolshakov,
	Laurent Vivier, Palmer Dabbelt, Wenchao Wang, Alistair Francis,
	Aleksandar Rikalo, Aurelien Jarno

On 9/3/21 2:50 AM, David Gibson wrote:
> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>> Each POWER cpu has its own has_work() implementation. Instead of
>> overloading CPUClass on each PowerPCCPUClass init, register the
>> generic ppc_cpu_has_work() handler, and have it call the POWER
>> specific has_work().
> 
> I don't quite see the rationale for introducing a second layer of
> indirection here.  What's wrong with switching the base has_work for
> each cpu variant?
> 
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  target/ppc/cpu-qom.h  |  3 +++
>>  target/ppc/cpu_init.c | 26 ++++++++++++++++++--------
>>  2 files changed, 21 insertions(+), 8 deletions(-)

>> @@ -8796,6 +8800,12 @@ static bool ppc_cpu_has_work(CPUState *cs)
>>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>>      CPUPPCState *env = &cpu->env;
>>  
>> +    if (cs->halted) {
>> +        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);

Maybe I should have kept the 'if (cs->halted)' for the next patch,
simply dispatch here, then in the next patch the code simplification
is more apparent. I thought this approach would involve less #ifdef'ry
but haven't checked the other way around. Will do now.

>> +        return pcc->has_work(cs);
>> +    }
>> +
>>      return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD);
>>  }
>>  #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
> 


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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
  2021-09-03 20:34       ` Philippe Mathieu-Daudé
@ 2021-09-03 20:38         ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:38 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/3/21 10:34 PM, Philippe Mathieu-Daudé wrote:
>> Drop CONFIG_TCG for alpha; it's always true.
> 
> What is the rational? "Old" architectures (with no active /
> official hw development) are unlikely to add hardware
> acceleration, so TCG is the single one possible? Thus no
> need to clutter the code with obvious #ifdef'ry?

Correct.  Broadly, if git grep CONFIG_TCG is empty in a subdirectory, don't add the first 
instance.


r~

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

* Re: [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:38         ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:38 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Thomas Huth, Max Filippov, Taylor Simpson,
	haxm-team, Colin Xu, Edgar E. Iglesias, Sunil Muthuswamy,
	Marek Vasut, Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Aleksandar Rikalo, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Paolo Bonzini, qemu-ppc,
	Stafford Horne, David Gibson, qemu-riscv, Bastian Koppelmann,
	Cornelia Huck, Roman Bolshakov, Laurent Vivier, Palmer Dabbelt,
	Wenchao Wang, Alistair Francis, Aurelien Jarno

On 9/3/21 10:34 PM, Philippe Mathieu-Daudé wrote:
>> Drop CONFIG_TCG for alpha; it's always true.
> 
> What is the rational? "Old" architectures (with no active /
> official hw development) are unlikely to add hardware
> acceleration, so TCG is the single one possible? Thus no
> need to clutter the code with obvious #ifdef'ry?

Correct.  Broadly, if git grep CONFIG_TCG is empty in a subdirectory, don't add the first 
instance.


r~


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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-03  0:50     ` David Gibson
@ 2021-09-03 20:42       ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:42 UTC (permalink / raw)
  To: David Gibson, Philippe Mathieu-Daudé
  Cc: qemu-devel, Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, Alistair Francis,
	Edgar E. Iglesias, Roman Bolshakov, Laurent Vivier,
	Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel, Marek Vasut,
	Stefano Stabellini, Aleksandar Rikalo, Mark Cave-Ayland,
	Colin Xu, Claudio Fontana, Palmer Dabbelt, Stafford Horne,
	Reinoud Zandijk, kvm

On 9/3/21 2:50 AM, David Gibson wrote:
> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>> Each POWER cpu has its own has_work() implementation. Instead of
>> overloading CPUClass on each PowerPCCPUClass init, register the
>> generic ppc_cpu_has_work() handler, and have it call the POWER
>> specific has_work().
> 
> I don't quite see the rationale for introducing a second layer of
> indirection here.  What's wrong with switching the base has_work for
> each cpu variant?

We're moving the hook from CPUState to TCGCPUOps.
Phil was trying to avoid creating N versions of

static const struct TCGCPUOps ppc_tcg_ops = {
     ...
};

A plausible alternative is to remove the const from this struct and modify it, just as we 
do for CPUState, on the assumption that we cannot mix and match ppc cpu types in any one 
machine.


r~

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-03 20:42       ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:42 UTC (permalink / raw)
  To: David Gibson, Philippe Mathieu-Daudé
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Edgar E. Iglesias,
	Stafford Horne, Marek Vasut, Stefano Stabellini, Yoshinori Sato,
	Paul Durrant, Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Roman Bolshakov, qemu-ppc, Wenchao Wang, Alistair Francis,
	Paolo Bonzini, Aleksandar Rikalo, Aurelien Jarno

On 9/3/21 2:50 AM, David Gibson wrote:
> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>> Each POWER cpu has its own has_work() implementation. Instead of
>> overloading CPUClass on each PowerPCCPUClass init, register the
>> generic ppc_cpu_has_work() handler, and have it call the POWER
>> specific has_work().
> 
> I don't quite see the rationale for introducing a second layer of
> indirection here.  What's wrong with switching the base has_work for
> each cpu variant?

We're moving the hook from CPUState to TCGCPUOps.
Phil was trying to avoid creating N versions of

static const struct TCGCPUOps ppc_tcg_ops = {
     ...
};

A plausible alternative is to remove the const from this struct and modify it, just as we 
do for CPUState, on the assumption that we cannot mix and match ppc cpu types in any one 
machine.


r~


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

* Re: [PATCH v3 22/30] target/ppc: Simplify has_work() handlers
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:43     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> The common ppc_cpu_has_work() handler already checks for cs->halted,
> so we can simplify all callees.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/cpu_init.c | 294 ++++++++++++++++++++----------------------
>   1 file changed, 138 insertions(+), 156 deletions(-)

Well, I'm not actually a fan of this; I'd rather the outer function merely dispatch here, 
or preferably arrange to arrive here to begin.


r~

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

* Re: [PATCH v3 22/30] target/ppc: Simplify has_work() handlers
@ 2021-09-03 20:43     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> The common ppc_cpu_has_work() handler already checks for cs->halted,
> so we can simplify all callees.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/cpu_init.c | 294 ++++++++++++++++++++----------------------
>   1 file changed, 138 insertions(+), 156 deletions(-)

Well, I'm not actually a fan of this; I'd rather the outer function merely dispatch here, 
or preferably arrange to arrive here to begin.


r~


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

* Re: [PATCH v3 23/30] target/riscv: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:43     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/riscv/cpu.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)

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

r~

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

* Re: [PATCH v3 23/30] target/riscv: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:43     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/riscv/cpu.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)

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

r~


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

* Re: [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:43     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/cpu_init.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

r~

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

* Re: [PATCH v3 20/30] target/ppc: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:43     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/cpu_init.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

r~


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

* Re: [PATCH v3 24/30] target/rx: Restrict has_work() handler to sysemu and TCG
  2021-09-02 16:15   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:44     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Bin Meng, Eduardo Habkost, Greg Kurz, haxm-team,
	Kamil Rytarowski, qemu-ppc, Anthony Perard, Marcel Apfelbaum,
	Michael Rolnik, qemu-riscv, Paolo Bonzini, Jiaxun Yang,
	Thomas Huth, David Hildenbrand, Chris Wulff, Laurent Vivier,
	Cameron Esfahani, Sunil Muthuswamy, Max Filippov, Taylor Simpson,
	qemu-s390x, Bastian Koppelmann, Yoshinori Sato, Artyom Tarasenko,
	Aurelien Jarno, Paul Durrant, Peter Maydell, David Gibson,
	Alistair Francis, Edgar E. Iglesias, Roman Bolshakov,
	Laurent Vivier, Cornelia Huck, qemu-arm, Wenchao Wang, xen-devel,
	Marek Vasut, Stefano Stabellini, Aleksandar Rikalo,
	Mark Cave-Ayland, Colin Xu, Claudio Fontana, Palmer Dabbelt,
	Stafford Horne, Reinoud Zandijk, kvm

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..0d0cf6f9028 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool rx_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

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

* Re: [PATCH v3 24/30] target/rx: Restrict has_work() handler to sysemu and TCG
@ 2021-09-03 20:44     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, Aleksandar Rikalo, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Edgar E. Iglesias, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Sunil Muthuswamy,
	Palmer Dabbelt, David Gibson, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aurelien Jarno

On 9/2/21 6:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> 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..0d0cf6f9028 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_TCG) && !defined(CONFIG_USER_ONLY)
>   static bool rx_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH v3 25/30] target/s390x: Restrict has_work() handler to sysemu and TCG
  2021-09-03 17:55 ` [PATCH v3 25/30] target/s390x: " Philippe Mathieu-Daudé
@ 2021-09-03 20:44   ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: qemu-s390x, Cornelia Huck, Thomas Huth, David Hildenbrand

On 9/3/21 7:55 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/s390x/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

r~


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

* Re: [PATCH v3 26/30] target/sh4: Restrict has_work() handler to sysemu and TCG
  2021-09-03 18:13 ` [PATCH v3 26/30] target/sh4: " Philippe Mathieu-Daudé
@ 2021-09-03 20:45   ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:45 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Yoshinori Sato

On 9/3/21 8:13 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/sh4/cpu.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
> index 2047742d03c..6c47d28631c 100644
> --- a/target/sh4/cpu.c
> +++ b/target/sh4/cpu.c
> @@ -58,12 +58,15 @@ static bool superh_io_recompile_replay_branch(CPUState *cs,
>       }
>       return false;
>   }
> -#endif
>   
> +#if defined(CONFIG_TCG)
>   static bool superh_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v3 27/30] target/sparc: Restrict has_work() handler to sysemu and TCG
  2021-09-03 18:14 ` [PATCH v3 27/30] target/sparc: " Philippe Mathieu-Daudé
@ 2021-09-03 20:46   ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Mark Cave-Ayland, Artyom Tarasenko

On 9/3/21 8:14 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/sparc/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Though I think the one existing reference to CONFIG_TCG for this target is a mistake,

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

r~


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

* Re: [PATCH v3 28/30] target/tricore: Restrict has_work() handler to sysemu and TCG
  2021-09-03 18:14 ` [PATCH v3 28/30] target/tricore: " Philippe Mathieu-Daudé
@ 2021-09-03 20:46   ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Bastian Koppelmann

On 9/3/21 8:14 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/tricore/cpu.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v3 29/30] target/xtensa: Restrict has_work() handler to sysemu and TCG
  2021-09-03 18:15 ` [PATCH v3 29/30] target/xtensa: " Philippe Mathieu-Daudé
@ 2021-09-03 20:47   ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Max Filippov

On 9/3/21 8:15 PM, Philippe Mathieu-Daudé wrote:
> Restrict has_work() to TCG sysemu.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/xtensa/cpu.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
> index c1cbd03595e..f7c3f368737 100644
> --- a/target/xtensa/cpu.c
> +++ b/target/xtensa/cpu.c
> @@ -43,18 +43,19 @@ static void xtensa_cpu_set_pc(CPUState *cs, vaddr value)
>       cpu->env.pc = value;
>   }
>   
> +#ifndef CONFIG_USER_ONLY
> +
> +#if defined(CONFIG_TCG)
>   static bool xtensa_cpu_has_work(CPUState *cs)

No CONFIG_TCG, otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



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

* Re: [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
  2021-09-03 18:19   ` Philippe Mathieu-Daudé
@ 2021-09-03 20:48     ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Anthony Perard, Cameron Esfahani, Claudio Fontana, Colin Xu,
	Eduardo Habkost, haxm-team, Kamil Rytarowski, Laurent Vivier,
	Paolo Bonzini, Paul Durrant, Reinoud Zandijk, Roman Bolshakov,
	Stefano Stabellini, Thomas Huth, Wenchao Wang, xen-devel

On 9/3/21 8:19 PM, Philippe Mathieu-Daudé wrote:
> cpu_common_has_work() is the default has_work() implementation
> and returns 'false'.
> 
> Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
> and remove cpu_common_has_work().
> 
> Since there are no more implementations of SysemuCPUOps::has_work,
> remove it along with the assertion in cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h             | 2 --
>   accel/hvf/hvf-accel-ops.c         | 6 ++++++
>   accel/qtest/qtest.c               | 6 ++++++
>   accel/xen/xen-all.c               | 6 ++++++
>   hw/core/cpu-common.c              | 6 ------
>   softmmu/cpus.c                    | 9 ++-------
>   target/i386/hax/hax-accel-ops.c   | 6 ++++++
>   target/i386/nvmm/nvmm-accel-ops.c | 6 ++++++
>   8 files changed, 32 insertions(+), 15 deletions(-)

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

r~


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

* Re: [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
@ 2021-09-03 20:48     ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-03 20:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Eduardo Habkost,
	Paul Durrant, Roman Bolshakov, Cameron Esfahani,
	Kamil Rytarowski, Wenchao Wang, haxm-team, Claudio Fontana,
	xen-devel, Anthony Perard, Paolo Bonzini, Reinoud Zandijk,
	Colin Xu

On 9/3/21 8:19 PM, Philippe Mathieu-Daudé wrote:
> cpu_common_has_work() is the default has_work() implementation
> and returns 'false'.
> 
> Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
> and remove cpu_common_has_work().
> 
> Since there are no more implementations of SysemuCPUOps::has_work,
> remove it along with the assertion in cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   include/hw/core/cpu.h             | 2 --
>   accel/hvf/hvf-accel-ops.c         | 6 ++++++
>   accel/qtest/qtest.c               | 6 ++++++
>   accel/xen/xen-all.c               | 6 ++++++
>   hw/core/cpu-common.c              | 6 ------
>   softmmu/cpus.c                    | 9 ++-------
>   target/i386/hax/hax-accel-ops.c   | 6 ++++++
>   target/i386/nvmm/nvmm-accel-ops.c | 6 ++++++
>   8 files changed, 32 insertions(+), 15 deletions(-)

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

r~


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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-03 20:42       ` Richard Henderson
@ 2021-09-03 21:11         ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 21:11 UTC (permalink / raw)
  To: Richard Henderson, David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Jiaxun Yang, Laurent Vivier,
	Max Filippov, Taylor Simpson, haxm-team, Colin Xu,
	Stafford Horne, Marek Vasut, Stefano Stabellini, Yoshinori Sato,
	Paul Durrant, Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Marcel Apfelbaum, Anthony Perard, xen-devel, Artyom Tarasenko,
	Laurent Vivier, Thomas Huth, Eduardo Habkost, Greg Kurz,
	Cameron Esfahani, qemu-s390x, qemu-arm, Michael Rolnik,
	Sunil Muthuswamy, Palmer Dabbelt, qemu-riscv, Bastian Koppelmann,
	Chris Wulff, Roman Bolshakov, qemu-ppc, Wenchao Wang,
	Alistair Francis, Paolo Bonzini, Aleksandar Rikalo,
	Aurelien Jarno

On 9/3/21 10:42 PM, Richard Henderson wrote:
> On 9/3/21 2:50 AM, David Gibson wrote:
>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>> Each POWER cpu has its own has_work() implementation. Instead of
>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>> specific has_work().
>>
>> I don't quite see the rationale for introducing a second layer of
>> indirection here.  What's wrong with switching the base has_work for
>> each cpu variant?
> 
> We're moving the hook from CPUState to TCGCPUOps.
> Phil was trying to avoid creating N versions of
> 
> static const struct TCGCPUOps ppc_tcg_ops = {
>     ...
> };

Ah yes this is the reason! Too many context switching so
I forgot about it.

> A plausible alternative is to remove the const from this struct and
> modify it, just as we do for CPUState, on the assumption that we cannot
> mix and match ppc cpu types in any one machine.

I thought about this case and remembered how it works on the ARM arch,
i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
similar PPC machine exists, IMHO we should try to generally allow to
possibility to experiment machine with different CPUs. Restricting it
on PPC goes the other way around. Thoughts?

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-03 21:11         ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-03 21:11 UTC (permalink / raw)
  To: Richard Henderson, David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Max Filippov, Taylor Simpson,
	haxm-team, Colin Xu, Sunil Muthuswamy, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Greg Kurz, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Paolo Bonzini, qemu-ppc,
	Stafford Horne, qemu-riscv, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Wenchao Wang,
	Alistair Francis, Aleksandar Rikalo, Aurelien Jarno

On 9/3/21 10:42 PM, Richard Henderson wrote:
> On 9/3/21 2:50 AM, David Gibson wrote:
>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>> Each POWER cpu has its own has_work() implementation. Instead of
>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>> specific has_work().
>>
>> I don't quite see the rationale for introducing a second layer of
>> indirection here.  What's wrong with switching the base has_work for
>> each cpu variant?
> 
> We're moving the hook from CPUState to TCGCPUOps.
> Phil was trying to avoid creating N versions of
> 
> static const struct TCGCPUOps ppc_tcg_ops = {
>     ...
> };

Ah yes this is the reason! Too many context switching so
I forgot about it.

> A plausible alternative is to remove the const from this struct and
> modify it, just as we do for CPUState, on the assumption that we cannot
> mix and match ppc cpu types in any one machine.

I thought about this case and remembered how it works on the ARM arch,
i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
similar PPC machine exists, IMHO we should try to generally allow to
possibility to experiment machine with different CPUs. Restricting it
on PPC goes the other way around. Thoughts?


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

* Re: [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
  2021-09-03 18:19   ` Philippe Mathieu-Daudé
@ 2021-09-06  6:48     ` Paul Durrant
  -1 siblings, 0 replies; 130+ messages in thread
From: Paul Durrant @ 2021-09-06  6:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, Anthony Perard, Cameron Esfahani,
	Claudio Fontana, Colin Xu, Eduardo Habkost, haxm-team,
	Kamil Rytarowski, Laurent Vivier, Paolo Bonzini, Reinoud Zandijk,
	Roman Bolshakov, Stefano Stabellini, Thomas Huth, Wenchao Wang,
	xen-devel

On 03/09/2021 19:19, Philippe Mathieu-Daudé wrote:
> cpu_common_has_work() is the default has_work() implementation
> and returns 'false'.
> 
> Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
> and remove cpu_common_has_work().
> 
> Since there are no more implementations of SysemuCPUOps::has_work,
> remove it along with the assertion in cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Xen parts...

Acked-by: Paul Durrant <paul@xen.org>


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

* Re: [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
@ 2021-09-06  6:48     ` Paul Durrant
  0 siblings, 0 replies; 130+ messages in thread
From: Paul Durrant @ 2021-09-06  6:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Eduardo Habkost,
	Richard Henderson, Roman Bolshakov, Cameron Esfahani,
	Kamil Rytarowski, Wenchao Wang, haxm-team, Claudio Fontana,
	xen-devel, Anthony Perard, Paolo Bonzini, Reinoud Zandijk,
	Colin Xu

On 03/09/2021 19:19, Philippe Mathieu-Daudé wrote:
> cpu_common_has_work() is the default has_work() implementation
> and returns 'false'.
> 
> Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
> and remove cpu_common_has_work().
> 
> Since there are no more implementations of SysemuCPUOps::has_work,
> remove it along with the assertion in cpu_has_work().
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Xen parts...

Acked-by: Paul Durrant <paul@xen.org>


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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-03 21:11         ` Philippe Mathieu-Daudé
@ 2021-09-11 22:31           ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-11 22:31 UTC (permalink / raw)
  To: Richard Henderson, David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Jiaxun Yang, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Sunil Muthuswamy,
	Marek Vasut, Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Marcel Apfelbaum, Anthony Perard, xen-devel, Artyom Tarasenko,
	Laurent Vivier, Thomas Huth, Eduardo Habkost, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Paolo Bonzini, qemu-ppc,
	Stafford Horne, qemu-riscv, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Wenchao Wang,
	Alistair Francis, Aleksandar Rikalo, Aurelien Jarno

On 9/3/21 11:11 PM, Philippe Mathieu-Daudé wrote:
> On 9/3/21 10:42 PM, Richard Henderson wrote:
>> On 9/3/21 2:50 AM, David Gibson wrote:
>>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>>> Each POWER cpu has its own has_work() implementation. Instead of
>>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>>> specific has_work().
>>>
>>> I don't quite see the rationale for introducing a second layer of
>>> indirection here.  What's wrong with switching the base has_work for
>>> each cpu variant?
>>
>> We're moving the hook from CPUState to TCGCPUOps.
>> Phil was trying to avoid creating N versions of
>>
>> static const struct TCGCPUOps ppc_tcg_ops = {
>>     ...
>> };
> 
> Ah yes this is the reason! Too many context switching so
> I forgot about it.
> 
>> A plausible alternative is to remove the const from this struct and
>> modify it, just as we do for CPUState, on the assumption that we cannot
>> mix and match ppc cpu types in any one machine.
> 
> I thought about this case and remembered how it works on the ARM arch,
> i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
> similar PPC machine exists, IMHO we should try to generally allow to
> possibility to experiment machine with different CPUs. Restricting it
> on PPC goes the other way around. Thoughts?

I'm running out of ideas to do avoid the indirection and multiple
copies of TCGCPUOps. I'm not giving up, I suppose I'm simply not
seeing it... David, any suggestions?

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-11 22:31           ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 130+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-11 22:31 UTC (permalink / raw)
  To: Richard Henderson, David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Cameron Esfahani, qemu-s390x,
	qemu-arm, Michael Rolnik, Sunil Muthuswamy, Palmer Dabbelt,
	qemu-riscv, Bastian Koppelmann, Chris Wulff, Roman Bolshakov,
	qemu-ppc, Wenchao Wang, Alistair Francis, Paolo Bonzini,
	Aleksandar Rikalo, Aurelien Jarno

On 9/3/21 11:11 PM, Philippe Mathieu-Daudé wrote:
> On 9/3/21 10:42 PM, Richard Henderson wrote:
>> On 9/3/21 2:50 AM, David Gibson wrote:
>>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>>> Each POWER cpu has its own has_work() implementation. Instead of
>>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>>> specific has_work().
>>>
>>> I don't quite see the rationale for introducing a second layer of
>>> indirection here.  What's wrong with switching the base has_work for
>>> each cpu variant?
>>
>> We're moving the hook from CPUState to TCGCPUOps.
>> Phil was trying to avoid creating N versions of
>>
>> static const struct TCGCPUOps ppc_tcg_ops = {
>>     ...
>> };
> 
> Ah yes this is the reason! Too many context switching so
> I forgot about it.
> 
>> A plausible alternative is to remove the const from this struct and
>> modify it, just as we do for CPUState, on the assumption that we cannot
>> mix and match ppc cpu types in any one machine.
> 
> I thought about this case and remembered how it works on the ARM arch,
> i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
> similar PPC machine exists, IMHO we should try to generally allow to
> possibility to experiment machine with different CPUs. Restricting it
> on PPC goes the other way around. Thoughts?

I'm running out of ideas to do avoid the indirection and multiple
copies of TCGCPUOps. I'm not giving up, I suppose I'm simply not
seeing it... David, any suggestions?


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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
  2021-09-11 22:31           ` Philippe Mathieu-Daudé
@ 2021-09-12 12:31             ` Richard Henderson
  -1 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-12 12:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Chris Wulff, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Jiaxun Yang, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Sunil Muthuswamy,
	Marek Vasut, Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Marcel Apfelbaum, Anthony Perard, xen-devel, Artyom Tarasenko,
	Laurent Vivier, Thomas Huth, Eduardo Habkost, Cameron Esfahani,
	qemu-s390x, qemu-arm, Michael Rolnik, Paolo Bonzini, qemu-ppc,
	Stafford Horne, qemu-riscv, Bastian Koppelmann, Cornelia Huck,
	Roman Bolshakov, Laurent Vivier, Palmer Dabbelt, Wenchao Wang,
	Alistair Francis, Aleksandar Rikalo, Aurelien Jarno

On 9/11/21 3:31 PM, Philippe Mathieu-Daudé wrote:
> On 9/3/21 11:11 PM, Philippe Mathieu-Daudé wrote:
>> On 9/3/21 10:42 PM, Richard Henderson wrote:
>>> On 9/3/21 2:50 AM, David Gibson wrote:
>>>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>>>> Each POWER cpu has its own has_work() implementation. Instead of
>>>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>>>> specific has_work().
>>>>
>>>> I don't quite see the rationale for introducing a second layer of
>>>> indirection here.  What's wrong with switching the base has_work for
>>>> each cpu variant?
>>>
>>> We're moving the hook from CPUState to TCGCPUOps.
>>> Phil was trying to avoid creating N versions of
>>>
>>> static const struct TCGCPUOps ppc_tcg_ops = {
>>>      ...
>>> };
>>
>> Ah yes this is the reason! Too many context switching so
>> I forgot about it.
>>
>>> A plausible alternative is to remove the const from this struct and
>>> modify it, just as we do for CPUState, on the assumption that we cannot
>>> mix and match ppc cpu types in any one machine.
>>
>> I thought about this case and remembered how it works on the ARM arch,
>> i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
>> similar PPC machine exists, IMHO we should try to generally allow to
>> possibility to experiment machine with different CPUs. Restricting it
>> on PPC goes the other way around. Thoughts?
> 
> I'm running out of ideas to do avoid the indirection and multiple
> copies of TCGCPUOps. I'm not giving up, I suppose I'm simply not
> seeing it... David, any suggestions?

I think multiple copies of TCGCPUOps is the solution.  Macro-ized, perhaps, so that the 
amount of typing is minimal across the versions.


r~

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

* Re: [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work()
@ 2021-09-12 12:31             ` Richard Henderson
  0 siblings, 0 replies; 130+ messages in thread
From: Richard Henderson @ 2021-09-12 12:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	David Gibson, Cédric Le Goater, Greg Kurz
  Cc: Peter Maydell, Cornelia Huck, kvm, David Hildenbrand, Bin Meng,
	Mark Cave-Ayland, qemu-devel, Laurent Vivier, Max Filippov,
	Taylor Simpson, haxm-team, Colin Xu, Stafford Horne, Marek Vasut,
	Stefano Stabellini, Yoshinori Sato, Paul Durrant,
	Kamil Rytarowski, Reinoud Zandijk, Claudio Fontana,
	Anthony Perard, xen-devel, Artyom Tarasenko, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Cameron Esfahani, qemu-s390x,
	qemu-arm, Michael Rolnik, Sunil Muthuswamy, Palmer Dabbelt,
	qemu-riscv, Bastian Koppelmann, Chris Wulff, Roman Bolshakov,
	qemu-ppc, Wenchao Wang, Alistair Francis, Paolo Bonzini,
	Aleksandar Rikalo, Aurelien Jarno

On 9/11/21 3:31 PM, Philippe Mathieu-Daudé wrote:
> On 9/3/21 11:11 PM, Philippe Mathieu-Daudé wrote:
>> On 9/3/21 10:42 PM, Richard Henderson wrote:
>>> On 9/3/21 2:50 AM, David Gibson wrote:
>>>> On Thu, Sep 02, 2021 at 06:15:34PM +0200, Philippe Mathieu-Daudé wrote:
>>>>> Each POWER cpu has its own has_work() implementation. Instead of
>>>>> overloading CPUClass on each PowerPCCPUClass init, register the
>>>>> generic ppc_cpu_has_work() handler, and have it call the POWER
>>>>> specific has_work().
>>>>
>>>> I don't quite see the rationale for introducing a second layer of
>>>> indirection here.  What's wrong with switching the base has_work for
>>>> each cpu variant?
>>>
>>> We're moving the hook from CPUState to TCGCPUOps.
>>> Phil was trying to avoid creating N versions of
>>>
>>> static const struct TCGCPUOps ppc_tcg_ops = {
>>>      ...
>>> };
>>
>> Ah yes this is the reason! Too many context switching so
>> I forgot about it.
>>
>>> A plausible alternative is to remove the const from this struct and
>>> modify it, just as we do for CPUState, on the assumption that we cannot
>>> mix and match ppc cpu types in any one machine.
>>
>> I thought about this case and remembered how it works on the ARM arch,
>> i.e. ZynqMP machine uses both Cortex-R5F and Cortex-A53. Even if no
>> similar PPC machine exists, IMHO we should try to generally allow to
>> possibility to experiment machine with different CPUs. Restricting it
>> on PPC goes the other way around. Thoughts?
> 
> I'm running out of ideas to do avoid the indirection and multiple
> copies of TCGCPUOps. I'm not giving up, I suppose I'm simply not
> seeing it... David, any suggestions?

I think multiple copies of TCGCPUOps is the solution.  Macro-ized, perhaps, so that the 
amount of typing is minimal across the versions.


r~


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

end of thread, other threads:[~2021-09-12 12:37 UTC | newest]

Thread overview: 130+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 16:15 [PATCH v3 00/30] accel: Move has_work() from SysemuCPUOps to AccelOpsClass Philippe Mathieu-Daudé
2021-09-02 16:15 ` Philippe Mathieu-Daudé
2021-09-02 16:15 ` [PATCH v3 01/30] accel/tcg: Restrict cpu_handle_halt() to sysemu Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 19:31   ` Richard Henderson
2021-09-03 19:31     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 02/30] hw/core: Restrict cpu_has_work() " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:11   ` Richard Henderson
2021-09-03 20:11     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 03/30] hw/core: Un-inline cpu_has_work() Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:11   ` Richard Henderson
2021-09-03 20:11     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 04/30] sysemu: Introduce AccelOpsClass::has_work() Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:14   ` Richard Henderson
2021-09-03 20:14     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 05/30] accel/kvm: Implement AccelOpsClass::has_work() Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:15   ` Richard Henderson
2021-09-03 20:15     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 06/30] accel/whpx: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:16   ` Richard Henderson
2021-09-03 20:16     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 07/30] accel/tcg: Implement AccelOpsClass::has_work() as stub Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:17   ` Richard Henderson
2021-09-03 20:17     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 08/30] target/alpha: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:18   ` Richard Henderson
2021-09-03 20:18     ` Richard Henderson
2021-09-03 20:34     ` Philippe Mathieu-Daudé
2021-09-03 20:34       ` Philippe Mathieu-Daudé
2021-09-03 20:38       ` Richard Henderson
2021-09-03 20:38         ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 09/30] target/arm: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:19   ` Richard Henderson
2021-09-03 20:19     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 10/30] target/avr: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:20   ` Richard Henderson
2021-09-03 20:20     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 11/30] target/cris: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:21   ` Richard Henderson
2021-09-03 20:21     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 12/30] target/hexagon: Remove unused has_work() handler Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:21   ` Richard Henderson
2021-09-03 20:21     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 13/30] target/hppa: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:22   ` Richard Henderson
2021-09-03 20:22     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 14/30] target/i386: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:23   ` Richard Henderson
2021-09-03 20:23     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 15/30] target/m68k: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:24   ` Richard Henderson
2021-09-03 20:24     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 16/30] target/microblaze: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:25   ` Richard Henderson
2021-09-03 20:25     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 17/30] target/mips: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:26   ` Richard Henderson
2021-09-03 20:26     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 18/30] target/nios2: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:31   ` Richard Henderson
2021-09-03 20:31     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 19/30] target/openrisc: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:31   ` Richard Henderson
2021-09-03 20:31     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 20/30] target/ppc: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03  0:49   ` David Gibson
2021-09-03  0:49     ` David Gibson
2021-09-03 20:43   ` Richard Henderson
2021-09-03 20:43     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 21/30] target/ppc: Introduce PowerPCCPUClass::has_work() Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03  0:50   ` David Gibson
2021-09-03  0:50     ` David Gibson
2021-09-03 20:38     ` Philippe Mathieu-Daudé
2021-09-03 20:38       ` Philippe Mathieu-Daudé
2021-09-03 20:42     ` Richard Henderson
2021-09-03 20:42       ` Richard Henderson
2021-09-03 21:11       ` Philippe Mathieu-Daudé
2021-09-03 21:11         ` Philippe Mathieu-Daudé
2021-09-11 22:31         ` Philippe Mathieu-Daudé
2021-09-11 22:31           ` Philippe Mathieu-Daudé
2021-09-12 12:31           ` Richard Henderson
2021-09-12 12:31             ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 22/30] target/ppc: Simplify has_work() handlers Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:43   ` Richard Henderson
2021-09-03 20:43     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 23/30] target/riscv: Restrict has_work() handler to sysemu and TCG Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:43   ` Richard Henderson
2021-09-03 20:43     ` Richard Henderson
2021-09-02 16:15 ` [PATCH v3 24/30] target/rx: " Philippe Mathieu-Daudé
2021-09-02 16:15   ` Philippe Mathieu-Daudé
2021-09-03 20:44   ` Richard Henderson
2021-09-03 20:44     ` Richard Henderson
2021-09-03 17:55 ` [PATCH v3 25/30] target/s390x: " Philippe Mathieu-Daudé
2021-09-03 20:44   ` Richard Henderson
2021-09-03 18:13 ` [PATCH v3 26/30] target/sh4: " Philippe Mathieu-Daudé
2021-09-03 20:45   ` Richard Henderson
2021-09-03 18:14 ` [PATCH v3 27/30] target/sparc: " Philippe Mathieu-Daudé
2021-09-03 20:46   ` Richard Henderson
2021-09-03 18:14 ` [PATCH v3 28/30] target/tricore: " Philippe Mathieu-Daudé
2021-09-03 20:46   ` Richard Henderson
2021-09-03 18:15 ` [PATCH v3 29/30] target/xtensa: " Philippe Mathieu-Daudé
2021-09-03 20:47   ` Richard Henderson
2021-09-03 18:19 ` [PATCH v3 30/30] accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one Philippe Mathieu-Daudé
2021-09-03 18:19   ` Philippe Mathieu-Daudé
2021-09-03 20:48   ` Richard Henderson
2021-09-03 20:48     ` Richard Henderson
2021-09-06  6:48   ` Paul Durrant
2021-09-06  6:48     ` Paul Durrant

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.