Message ID | 20181213050453.9677-31-cota@braap.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> 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 036C6112E for <patchwork-qemu-devel@patchwork.kernel.org>; Thu, 13 Dec 2018 05:16:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A612B148 for <patchwork-qemu-devel@patchwork.kernel.org>; Thu, 13 Dec 2018 05:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD35B2B1A4; Thu, 13 Dec 2018 05:16:19 +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 849E02B148 for <patchwork-qemu-devel@patchwork.kernel.org>; Thu, 13 Dec 2018 05:16:19 +0000 (UTC) Received: from localhost ([::1]:50478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org>) id 1gXJMA-00078R-Jr for patchwork-qemu-devel@patchwork.kernel.org; Thu, 13 Dec 2018 00:16:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <cota@braap.org>) 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 <cota@braap.org>) 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 <cota@braap.org>) 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 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: <xms:p-gRXH4_9XdQPU4w9uxv6Cq7C-tIIVU7BHmth9FW2eoIc9hyur3uQg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkof gjfhestddtredtredttdenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohhtrgdfuceo tghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvdduieenuc frrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecuvehluhhs thgvrhfuihiivgepge X-ME-Proxy: <xmx:p-gRXBIyxNcWvLIYTnaA8Fb_2TFfpaH78GzjThqxq5N5nRxJkNoryA> <xmx:p-gRXJdqyKmQ7N2wOi4sIwbsu-2aG9F88pazFXVD8teNymsVRwb6Rg> <xmx:p-gRXMcVTJ6THxF4WsS0d3CG-sNTJ97Ht2PM1b5w1fOEQZCNAb3ISA> <xmx:p-gRXKZhlcX434XusOYI0jzdHnm2CKeXju4Ym3ZA7tCTb0ePCnGsPg> 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) From: "Emilio G. Cota" <cota@braap.org> 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org> Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
per-CPU locks
|
expand
|
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; } -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); + + /* prevent deadlock; cpu_mutex must be acquired _after_ the BQL */ + 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; } - 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 +560,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;