From nobody Fri Nov 7 01:05:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154467822222530.076056067251557; Wed, 12 Dec 2018 21:17:02 -0800 (PST) Received: from localhost ([::1]:50488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJMm-0008LQ-TT for importer@patchew.org; Thu, 13 Dec 2018 00:16:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJCm-0007nw-T7 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXJCl-0001oB-9S for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:36 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:48279) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXJCk-0001Tz-Rs for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:34 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C61CA221EE; Thu, 13 Dec 2018 00:05:43 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 13 Dec 2018 00:05:43 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 6011210084; Thu, 13 Dec 2018 00:05:43 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=R0qL5ALc2AdPSNQTSO6CEwyQEGomJ05tL+mh+zVcH+w=; b=LHofX 8ORFY6MOioupA5yqVJY+s1nn8cOyRqVYl/1AXUQ5hFp17rIYi7gqOPvFV2RVn1Pi PSNsoC4ib+fd+OmZO2zkJ4Ng1dxUo9XvLZSuEhk/5AsBJEGhYzw6jKDBSSe94IY2 GuFfqsbKYepdDA1J1Al7liWdPUwcYO/+ofYyuM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=R0qL5ALc2AdPSNQTSO6CEwyQEGomJ 05tL+mh+zVcH+w=; b=UA0MhHrkoos6QLluw3FOOFmRRDg3Vs/yCNv4WFEjJ8maO pCo27u64VDLxu7yE6O8IFT2OIFGBe/Y+UbsURRaGuK5xG2AeIF6pxX+6CsjUKJUR LxEdggvgCU0f7GuzpGHP+xmAciKeMTivV0MBsGOJtQDvtW1tn5fDU/ajxVHNQz2u ZadHTwc2UbaScVlmioEHe8fliNJN6wgNMWP41kAwVtRkdG6UT+B++Fk/2BQk9wdu IOLa5lqI2jYARo2FaWqgOIVoAkHKDq142VN4ZaTirTUfaJgZKDqSlJJBxWTs7EwR NK/SoIJeeNgX5EPlE1NggKeI9iLmGkOMgLHxrevBQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkof gjfhestddtredtredttdenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohhtrgdfuceo tghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvdduieenuc frrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecuvehluhhs thgvrhfuihiivgepge X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 00:04:10 -0500 Message-Id: <20181213050453.9677-31-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213050453.9677-1-cota@braap.org> References: <20181213050453.9677-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v5 30/73] cpu-exec: convert to cpu_halted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 870027d435..b4f46134d3 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -422,14 +422,21 @@ static inline TranslationBlock *tb_find(CPUState *cpu, return tb; } =20 -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); + + /* prevent deadlock; cpu_mutex must be acquired _after_ the BQ= L */ + cpu_mutex_unlock(cpu); qemu_mutex_lock_iothread(); + cpu_mutex_lock(cpu); + apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); qemu_mutex_unlock_iothread(); @@ -439,12 +446,22 @@ static inline bool cpu_handle_halt(CPUState *cpu) return true; } =20 - cpu->halted =3D 0; + cpu_halted_set(cpu, 0); } =20 return false; } =20 +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 +560,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; --=20 2.17.1