From patchwork Wed May 11 10:21:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sergey.fedorov@linaro.org X-Patchwork-Id: 9067531 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63BAFBF440 for ; Wed, 11 May 2016 10:22:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE905201BB for ; Wed, 11 May 2016 10:22:30 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id F072C20145 for ; Wed, 11 May 2016 10:22:29 +0000 (UTC) Received: from localhost ([::1]:51466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RHg-0002bJ-U1 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 May 2016 06:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RHQ-0002Q8-JI for qemu-devel@nongnu.org; Wed, 11 May 2016 06:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0RHK-0000a1-Ob for qemu-devel@nongnu.org; Wed, 11 May 2016 06:22:11 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:35420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RHK-0000Zf-H2 for qemu-devel@nongnu.org; Wed, 11 May 2016 06:22:06 -0400 Received: by mail-lf0-x22d.google.com with SMTP id j8so44072054lfd.2 for ; Wed, 11 May 2016 03:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vPVu8NA0+aJ37WosLq+tlQAM7/62MM2Y/AtwBv1X87I=; b=YwVaKZu7XpTK9mjbeDT5574kMMqnGqADvrv5IyHzarscFTQsxYoVhx9E/57tcda1YR BNoVD8lT7ZySqEEpdZRDuHjuXn05eOp24YptO/ffZ/dU3FMB9m+l/JW9+GmIbWfQJNYV Ry63cdmXCZdnIUJtHRshIgkYUURKyhGycgnK4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vPVu8NA0+aJ37WosLq+tlQAM7/62MM2Y/AtwBv1X87I=; b=mRMPhxqNDqdVoDEg+ltxK321zTIDDy9asqn2tBzq1Icq9XAK8XH3nEuugnZhZIacFi QrpWCEYklbx5/r8APJfKffhv7nlxqn29ExMPGtWadPuzSzYlCeVV4NKZyATjmDr3rHBd 9YakfycWK4dxbvzB53yrvGbgG6BsNLYLFQBQHPSZh5l7ud5CFz88xEafmDxg+lxJdHue H01tjKGVtu0z3SG4AcvdehuphhcYDLVCvbe2pFae0EJWY+pu0GaShjxiJq64jIe4+Hwy iAnD8WlDL6oyXw4aONrSOJGvZccw1EmhAAw5QxVJctd5pvhkWTsd7UeH21aFPP5mOoUC YmuQ== X-Gm-Message-State: AOPr4FWkVoUgH+m7mDMv8d41/jhaMSBR2S8vAvBwlx4aMFtO1gF9fIonv03x9zO0ORqiQHaU X-Received: by 10.25.155.195 with SMTP id d186mr985142lfe.141.1462962125739; Wed, 11 May 2016 03:22:05 -0700 (PDT) Received: from sergey-laptop.Dlink (broadband-46-188-121-115.2com.net. [46.188.121.115]) by smtp.gmail.com with ESMTPSA id m1sm1196398lfb.45.2016.05.11.03.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 03:22:04 -0700 (PDT) From: Sergey Fedorov To: qemu-devel@nongnu.org Date: Wed, 11 May 2016 13:21:47 +0300 Message-Id: <1462962111-32237-2-git-send-email-sergey.fedorov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462962111-32237-1-git-send-email-sergey.fedorov@linaro.org> References: <1462962111-32237-1-git-send-email-sergey.fedorov@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22d Subject: [Qemu-devel] [PATCH 1/5] cpu-exec: Move halt handling out of cpu_exec() 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: Sergey Fedorov , Richard Henderson , Peter Crosthwaite , Sergey Fedorov , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sergey Fedorov Simplify cpu_exec() by extracting CPU halt state handling code out of cpu_exec() into a new static inline function cpu_handle_halt(). Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov Reviewed-by: Richard Henderson --- Changes in v2: * Declare x86_cpu variable in the inner-most block cpu-exec.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index d55faa5114c7..1fcdc3fabb39 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -352,6 +352,29 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, return tb; } +static inline bool cpu_handle_halt(CPUState *cpu) +{ + if (cpu->halted) { +#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) + + if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) + && replay_interrupt()) { + X86CPU *x86_cpu = X86_CPU(cpu); + apic_poll_irq(x86_cpu->apic_state); + cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); + } +#endif + if (!cpu_has_work(cpu)) { + current_cpu = NULL; + return true; + } + + cpu->halted = 0; + } + + return false; +} + static void cpu_handle_debug_exception(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); @@ -383,20 +406,8 @@ int cpu_exec(CPUState *cpu) /* replay_interrupt may need current_cpu */ current_cpu = cpu; - if (cpu->halted) { -#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) - if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) - && replay_interrupt()) { - apic_poll_irq(x86_cpu->apic_state); - cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); - } -#endif - if (!cpu_has_work(cpu)) { - current_cpu = NULL; - return EXCP_HALTED; - } - - cpu->halted = 0; + if (cpu_handle_halt(cpu)) { + return EXCP_HALTED; } atomic_mb_set(&tcg_current_cpu, cpu);