From patchwork Thu Oct 25 14:46:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 10656037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0280A14DE for ; Thu, 25 Oct 2018 15:30:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEB4A2BDB5 for ; Thu, 25 Oct 2018 15:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC7622BDB8; Thu, 25 Oct 2018 15:30:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D0BD2BD8B for ; Thu, 25 Oct 2018 15:30:22 +0000 (UTC) Received: from localhost ([::1]:55187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFhaX-0002kb-Ld for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Oct 2018 11:30:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFh5O-0002yq-Ue for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFgv9-00088l-3I for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:47:36 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:45015) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFgv6-0007tf-RS for qemu-devel@nongnu.org; Thu, 25 Oct 2018 10:47:33 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C2F682212D; Thu, 25 Oct 2018 10:46:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 10:46:52 -0400 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=pKGI5WSbQVpfuaT2ZuF6qCDuoJq+N6ADzw47FzwF3rg=; b=jMqNy JPeFr0sl+rAX6aD4ZGRVt7xhFgEwoWiEEjfLq6yPpJDVm6bmmbHIZibWT/05XyKo CQ/KImPkHy3/mPvfDuzJ+9Z7iCT/WdjtWjlmIMoJ0kTh4iriwfhObLMYv9ts33HW IULq6ZEUPtzPnEbPrhsoU8uXyZ384jrMpB1X+U= 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=pKGI5WSbQVpfuaT2ZuF6qCDuoJq+N 6ADzw47FzwF3rg=; b=MquXBbJF8JVaj33Qe+bIUZgBZqG2MZhfbhtOlG437GUNc m+3FqOvcaX8NjcbcmZ4beg1XQxnl+qJxJm32YYpjwKiMghlKhyf+8zvJmZc5ZMWa LNJVSgPROEzzAzOKaA2Uxt1mwq6sye+tNsvFHc/ATjmjrqClio8P2yXAcOBSxnSV +SczrMnVJLvNWCLxH3d1b1C8IUOBfaeWc/C68YzHz1GE4mctq4O0xX8fQg4zqLVF jiAbOHuvCQ2RS0hj6YSylygIFkNsPVrJ3suBm+qjiOeRC8gekLxRpccf6YJdYhgq NvQfJlVTKWyt0uKjyA8+3gP5eAQi4sP5EANnmgDZQ== X-ME-Sender: X-ME-Proxy: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 4FDF5E4A27; Thu, 25 Oct 2018 10:46:52 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 10:46:02 -0400 Message-Id: <20181025144644.15464-29-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025144644.15464-1-cota@braap.org> References: <20181025144644.15464-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC v4 29/71] 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: Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- 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 *cpu, 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 = X86_CPU(cpu); + + 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 +445,22 @@ static inline bool cpu_handle_halt(CPUState *cpu) return true; } - cpu->halted = 0; + cpu_halted_set(cpu, 0); } return false; } +static inline bool cpu_handle_halt(CPUState *cpu) +{ + bool ret; + + cpu_mutex_lock(cpu); + ret = cpu_handle_halt_locked(cpu); + cpu_mutex_unlock(cpu); + return ret; +} + static inline void cpu_handle_debug_exception(CPUState *cpu) { CPUClass *cc = 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 &= ~CPU_INTERRUPT_HALT; - cpu->halted = 1; + cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; qemu_mutex_unlock_iothread(); return true;