Received: from eggs.gnu.org ([2001:4830:134:3::10]:41449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtAh-0007am-Js for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHtAg-0000SN-Qw for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:16:43 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHtAg-0000MW-Ib for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:16:42 -0400 Received: by mail-wr1-x442.google.com with SMTP id i17-v6so17100376wre.7 for ; Wed, 31 Oct 2018 09:16:39 -0700 (PDT) References: <20181025144644.15464-1-cota@braap.org> <20181025144644.15464-29-cota@braap.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <20181025144644.15464-29-cota@braap.org> Date: Wed, 31 Oct 2018 16:16:36 +0000 Message-ID: <87tvl26qhn.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC v4 29/71] cpu-exec: convert to cpu_halted List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson Emilio G. Cota writes: > Signed-off-by: Emilio G. Cota > --- > accel/tcg/cpu-exec.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c > index 870027d435..f37c9b1e94 100644 > --- a/accel/tcg/cpu-exec.c > +++ b/accel/tcg/cpu-exec.c > @@ -422,14 +422,20 @@ static inline TranslationBlock *tb_find(CPUState *c= pu, > return tb; > } > > -static inline bool cpu_handle_halt(CPUState *cpu) > +static inline bool cpu_handle_halt_locked(CPUState *cpu) > { > - if (cpu->halted) { > + g_assert(cpu_mutex_locked(cpu)); > + > + if (cpu_halted(cpu)) { > #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) > if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) > && replay_interrupt()) { > X86CPU *x86_cpu =3D X86_CPU(cpu); > + > + cpu_mutex_unlock(cpu); > qemu_mutex_lock_iothread(); > + cpu_mutex_lock(cpu); > + I think we need a comment or reference to the locking rules for this case here. > apic_poll_irq(x86_cpu->apic_state); > cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); > qemu_mutex_unlock_iothread(); > @@ -439,12 +445,22 @@ static inline bool cpu_handle_halt(CPUState *cpu) > return true; > } > > - cpu->halted =3D 0; > + cpu_halted_set(cpu, 0); > } > > return false; > } > > +static inline bool cpu_handle_halt(CPUState *cpu) > +{ > + bool ret; > + > + cpu_mutex_lock(cpu); > + ret =3D cpu_handle_halt_locked(cpu); > + cpu_mutex_unlock(cpu); > + return ret; > +} > + > static inline void cpu_handle_debug_exception(CPUState *cpu) > { > CPUClass *cc =3D CPU_GET_CLASS(cpu); > @@ -543,7 +559,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, > } else if (interrupt_request & CPU_INTERRUPT_HALT) { > replay_interrupt(); > cpu->interrupt_request &=3D ~CPU_INTERRUPT_HALT; > - cpu->halted =3D 1; > + cpu_halted_set(cpu, 1); > cpu->exception_index =3D EXCP_HLT; > qemu_mutex_unlock_iothread(); > return true; -- Alex Benn=C3=A9e