From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH qom-next 34/59] cpus: Pass CPUState to qemu_cpu_kick() Date: Wed, 23 May 2012 05:07:57 +0200 Message-ID: <1337742502-28565-35-git-send-email-afaerber@suse.de> References: <1337742502-28565-1-git-send-email-afaerber@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Blue Swirl (maintainer:Sun4m), Avi Kivity (supporter:Overall), Marcelo Tosatti (supporter:Overall), Alexander Graf (maintainer:PPC), kvm@vger.kernel.org (open list:Overall), qemu-ppc@nongnu.org (open list:PowerPC) To: qemu-devel@nongnu.org Return-path: Received: from cantor2.suse.de ([195.135.220.15]:35607 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964938Ab2EWDJM (ORCPT ); Tue, 22 May 2012 23:09:12 -0400 In-Reply-To: <1337742502-28565-1-git-send-email-afaerber@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 13 +++++-------- exec.c | 2 +- hw/ppc.c | 4 ++-- hw/ppce500_spin.c | 2 +- hw/spapr_rtas.c | 5 ++++- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- include/qemu/cpu.h | 8 ++++++++ kvm-all.c | 2 +- qemu-common.h | 1 - target-ppc/kvm.c | 3 +-- target-s390x/kvm.c | 2 +- 12 files changed, 26 insertions(+), 20 deletions(-) diff --git a/cpus.c b/cpus.c index 5bae5fc..3873da1 100644 --- a/cpus.c +++ b/cpus.c @@ -663,7 +663,7 @@ void run_on_cpu(CPUArchState *env, void (*func)(voi= d *data), void *data) wi.next =3D NULL; wi.done =3D false; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); while (!wi.done) { CPUArchState *self_env =3D cpu_single_env; =20 @@ -872,11 +872,8 @@ static void qemu_cpu_kick_thread(CPUState *cpu) #endif } =20 -void qemu_cpu_kick(void *_env) +void qemu_cpu_kick(CPUState *cpu) { - CPUArchState *env =3D _env; - CPUState *cpu =3D ENV_GET_CPU(env); - qemu_cond_broadcast(cpu->halt_cond); if (!tcg_enabled() && !cpu->thread_kicked) { qemu_cpu_kick_thread(cpu); @@ -947,7 +944,7 @@ void pause_all_vcpus(void) while (penv) { CPUState *pcpu =3D ENV_GET_CPU(penv); pcpu->stop =3D true; - qemu_cpu_kick(penv); + qemu_cpu_kick(pcpu); penv =3D penv->next_cpu; } =20 @@ -968,7 +965,7 @@ void pause_all_vcpus(void) qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex); penv =3D first_cpu; while (penv) { - qemu_cpu_kick(penv); + qemu_cpu_kick(ENV_GET_CPU(penv)); penv =3D penv->next_cpu; } } @@ -983,7 +980,7 @@ void resume_all_vcpus(void) CPUState *pcpu =3D ENV_GET_CPU(penv); pcpu->stop =3D false; pcpu->stopped =3D false; - qemu_cpu_kick(penv); + qemu_cpu_kick(pcpu); penv =3D penv->next_cpu; } } diff --git a/exec.c b/exec.c index 79e553c..6e5ac67 100644 --- a/exec.c +++ b/exec.c @@ -1745,7 +1745,7 @@ static void tcg_handle_interrupt(CPUArchState *en= v, int mask) * case its halted. */ if (!qemu_cpu_is_self(cpu)) { - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); return; } =20 diff --git a/hw/ppc.c b/hw/ppc.c index ada100b..fa7ae74 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -206,7 +206,7 @@ static void ppc970_set_irq(void *opaque, int pin, i= nt level) } else { LOG_IRQ("%s: restart the CPU\n", __func__); env->halted =3D 0; - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } break; case PPC970_INPUT_HRESET: @@ -335,7 +335,7 @@ static void ppc40x_set_irq(void *opaque, int pin, i= nt level) } else { LOG_IRQ("%s: restart the CPU\n", __func__); env->halted =3D 0; - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } break; case PPC40x_INPUT_DEBUG: diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c index a03a4d3..1c0d8b6 100644 --- a/hw/ppce500_spin.c +++ b/hw/ppce500_spin.c @@ -115,7 +115,7 @@ static void spin_kick(void *data) env->halted =3D 0; env->exception_index =3D -1; cpu->stopped =3D false; - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); } =20 static void spin_write(void *opaque, target_phys_addr_t addr, uint64_t= value, diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c index ae18595..a343055 100644 --- a/hw/spapr_rtas.c +++ b/hw/spapr_rtas.c @@ -163,6 +163,7 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, uint32_t nret, target_ulong rets) { target_ulong id, start, r3; + CPUState *cpu; CPUPPCState *env; =20 if (nargs !=3D 3 || nret !=3D 1) { @@ -175,6 +176,8 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, r3 =3D rtas_ld(args, 2); =20 for (env =3D first_cpu; env; env =3D env->next_cpu) { + cpu =3D ENV_GET_CPU(env); + if (env->cpu_index !=3D id) { continue; } @@ -189,7 +192,7 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, env->gpr[3] =3D r3; env->halted =3D 0; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); =20 rtas_st(rets, 0, 0); return; diff --git a/hw/sun4m.c b/hw/sun4m.c index 8846f93..4929677 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -259,7 +259,7 @@ static void cpu_kick_irq(SPARCCPU *cpu) =20 env->halted =3D 0; cpu_check_irqs(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 static void cpu_set_irq(void *opaque, int irq, int level) diff --git a/hw/sun4u.c b/hw/sun4u.c index 0453522..d41e80a 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -316,7 +316,7 @@ static void cpu_kick_irq(SPARCCPU *cpu) =20 env->halted =3D 0; cpu_check_irqs(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 static void cpu_set_ivec_irq(void *opaque, int irq, int level) diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index 75e0f8d..bfeb224 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -96,6 +96,14 @@ void cpu_reset(CPUState *cpu); bool qemu_cpu_is_self(CPUState *cpu); =20 /** + * qemu_cpu_kick: + * @cpu: The vCPU to kick. + * + * Kicks @cpu's thread. + */ +void qemu_cpu_kick(CPUState *cpu); + +/** * cpu_is_stopped: * @cpu: The CPU to check. * diff --git a/kvm-all.c b/kvm-all.c index f25cf6d..3b247a0 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -836,7 +836,7 @@ static void kvm_handle_interrupt(CPUArchState *env,= int mask) env->interrupt_request |=3D mask; =20 if (!qemu_cpu_is_self(cpu)) { - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); } } =20 diff --git a/qemu-common.h b/qemu-common.h index 653e0e5..bfd7943 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -283,7 +283,6 @@ void cpu_save(QEMUFile *f, void *opaque); int cpu_load(QEMUFile *f, void *opaque, int version_id); =20 /* Unblock cpu */ -void qemu_cpu_kick(void *env); void qemu_cpu_kick_self(void); bool all_cpu_threads_idle(void); =20 diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index f111e87..a5bdbef 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -74,9 +74,8 @@ static QEMUTimer *idle_timer; static void kvm_kick_cpu(void *opaque) { PowerPCCPU *cpu =3D opaque; - CPUPPCState *env =3D &cpu->env; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 int kvm_arch_init(KVMState *s) diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 5800fd6..e09709d 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -298,7 +298,7 @@ static int s390_cpu_restart(S390CPU *cpu) =20 kvm_s390_interrupt(env, KVM_S390_RESTART, 0); s390_add_running_cpu(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); dprintf("DONE: SIGP cpu restart: %p\n", env); return 0; } --=20 1.7.7 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1ws-0000s2-RD for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SX1wn-0005it-7h for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:18 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 23 May 2012 05:07:57 +0200 Message-Id: <1337742502-28565-35-git-send-email-afaerber@suse.de> In-Reply-To: <1337742502-28565-1-git-send-email-afaerber@suse.de> References: <1337742502-28565-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-next 34/59] cpus: Pass CPUState to qemu_cpu_kick() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "open list:Overall" , Marcelo Tosatti , Alexander Graf , Blue Swirl , "open list:PowerPC" , Avi Kivity , =?UTF-8?q?Andreas=20F=C3=A4rber?= Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 13 +++++-------- exec.c | 2 +- hw/ppc.c | 4 ++-- hw/ppce500_spin.c | 2 +- hw/spapr_rtas.c | 5 ++++- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- include/qemu/cpu.h | 8 ++++++++ kvm-all.c | 2 +- qemu-common.h | 1 - target-ppc/kvm.c | 3 +-- target-s390x/kvm.c | 2 +- 12 files changed, 26 insertions(+), 20 deletions(-) diff --git a/cpus.c b/cpus.c index 5bae5fc..3873da1 100644 --- a/cpus.c +++ b/cpus.c @@ -663,7 +663,7 @@ void run_on_cpu(CPUArchState *env, void (*func)(void = *data), void *data) wi.next =3D NULL; wi.done =3D false; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); while (!wi.done) { CPUArchState *self_env =3D cpu_single_env; =20 @@ -872,11 +872,8 @@ static void qemu_cpu_kick_thread(CPUState *cpu) #endif } =20 -void qemu_cpu_kick(void *_env) +void qemu_cpu_kick(CPUState *cpu) { - CPUArchState *env =3D _env; - CPUState *cpu =3D ENV_GET_CPU(env); - qemu_cond_broadcast(cpu->halt_cond); if (!tcg_enabled() && !cpu->thread_kicked) { qemu_cpu_kick_thread(cpu); @@ -947,7 +944,7 @@ void pause_all_vcpus(void) while (penv) { CPUState *pcpu =3D ENV_GET_CPU(penv); pcpu->stop =3D true; - qemu_cpu_kick(penv); + qemu_cpu_kick(pcpu); penv =3D penv->next_cpu; } =20 @@ -968,7 +965,7 @@ void pause_all_vcpus(void) qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex); penv =3D first_cpu; while (penv) { - qemu_cpu_kick(penv); + qemu_cpu_kick(ENV_GET_CPU(penv)); penv =3D penv->next_cpu; } } @@ -983,7 +980,7 @@ void resume_all_vcpus(void) CPUState *pcpu =3D ENV_GET_CPU(penv); pcpu->stop =3D false; pcpu->stopped =3D false; - qemu_cpu_kick(penv); + qemu_cpu_kick(pcpu); penv =3D penv->next_cpu; } } diff --git a/exec.c b/exec.c index 79e553c..6e5ac67 100644 --- a/exec.c +++ b/exec.c @@ -1745,7 +1745,7 @@ static void tcg_handle_interrupt(CPUArchState *env,= int mask) * case its halted. */ if (!qemu_cpu_is_self(cpu)) { - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); return; } =20 diff --git a/hw/ppc.c b/hw/ppc.c index ada100b..fa7ae74 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -206,7 +206,7 @@ static void ppc970_set_irq(void *opaque, int pin, int= level) } else { LOG_IRQ("%s: restart the CPU\n", __func__); env->halted =3D 0; - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } break; case PPC970_INPUT_HRESET: @@ -335,7 +335,7 @@ static void ppc40x_set_irq(void *opaque, int pin, int= level) } else { LOG_IRQ("%s: restart the CPU\n", __func__); env->halted =3D 0; - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } break; case PPC40x_INPUT_DEBUG: diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c index a03a4d3..1c0d8b6 100644 --- a/hw/ppce500_spin.c +++ b/hw/ppce500_spin.c @@ -115,7 +115,7 @@ static void spin_kick(void *data) env->halted =3D 0; env->exception_index =3D -1; cpu->stopped =3D false; - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); } =20 static void spin_write(void *opaque, target_phys_addr_t addr, uint64_t v= alue, diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c index ae18595..a343055 100644 --- a/hw/spapr_rtas.c +++ b/hw/spapr_rtas.c @@ -163,6 +163,7 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, uint32_t nret, target_ulong rets) { target_ulong id, start, r3; + CPUState *cpu; CPUPPCState *env; =20 if (nargs !=3D 3 || nret !=3D 1) { @@ -175,6 +176,8 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, r3 =3D rtas_ld(args, 2); =20 for (env =3D first_cpu; env; env =3D env->next_cpu) { + cpu =3D ENV_GET_CPU(env); + if (env->cpu_index !=3D id) { continue; } @@ -189,7 +192,7 @@ static void rtas_start_cpu(sPAPREnvironment *spapr, env->gpr[3] =3D r3; env->halted =3D 0; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); =20 rtas_st(rets, 0, 0); return; diff --git a/hw/sun4m.c b/hw/sun4m.c index 8846f93..4929677 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -259,7 +259,7 @@ static void cpu_kick_irq(SPARCCPU *cpu) =20 env->halted =3D 0; cpu_check_irqs(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 static void cpu_set_irq(void *opaque, int irq, int level) diff --git a/hw/sun4u.c b/hw/sun4u.c index 0453522..d41e80a 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -316,7 +316,7 @@ static void cpu_kick_irq(SPARCCPU *cpu) =20 env->halted =3D 0; cpu_check_irqs(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 static void cpu_set_ivec_irq(void *opaque, int irq, int level) diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index 75e0f8d..bfeb224 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -96,6 +96,14 @@ void cpu_reset(CPUState *cpu); bool qemu_cpu_is_self(CPUState *cpu); =20 /** + * qemu_cpu_kick: + * @cpu: The vCPU to kick. + * + * Kicks @cpu's thread. + */ +void qemu_cpu_kick(CPUState *cpu); + +/** * cpu_is_stopped: * @cpu: The CPU to check. * diff --git a/kvm-all.c b/kvm-all.c index f25cf6d..3b247a0 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -836,7 +836,7 @@ static void kvm_handle_interrupt(CPUArchState *env, i= nt mask) env->interrupt_request |=3D mask; =20 if (!qemu_cpu_is_self(cpu)) { - qemu_cpu_kick(env); + qemu_cpu_kick(cpu); } } =20 diff --git a/qemu-common.h b/qemu-common.h index 653e0e5..bfd7943 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -283,7 +283,6 @@ void cpu_save(QEMUFile *f, void *opaque); int cpu_load(QEMUFile *f, void *opaque, int version_id); =20 /* Unblock cpu */ -void qemu_cpu_kick(void *env); void qemu_cpu_kick_self(void); bool all_cpu_threads_idle(void); =20 diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index f111e87..a5bdbef 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -74,9 +74,8 @@ static QEMUTimer *idle_timer; static void kvm_kick_cpu(void *opaque) { PowerPCCPU *cpu =3D opaque; - CPUPPCState *env =3D &cpu->env; =20 - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); } =20 int kvm_arch_init(KVMState *s) diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 5800fd6..e09709d 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -298,7 +298,7 @@ static int s390_cpu_restart(S390CPU *cpu) =20 kvm_s390_interrupt(env, KVM_S390_RESTART, 0); s390_add_running_cpu(env); - qemu_cpu_kick(env); + qemu_cpu_kick(CPU(cpu)); dprintf("DONE: SIGP cpu restart: %p\n", env); return 0; } --=20 1.7.7