From patchwork Fri May 13 00:13:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9087141 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 63161BF29F for ; Fri, 13 May 2016 00:25:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B477F200DC for ; Fri, 13 May 2016 00:25:51 +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 04EC3200D4 for ; Fri, 13 May 2016 00:25:51 +0000 (UTC) Received: from localhost ([::1]:60401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10vO-0003gD-4k for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 20:25:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10lx-00035g-0x for qemu-devel@nongnu.org; Thu, 12 May 2016 20:16:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b10lo-00038M-3V for qemu-devel@nongnu.org; Thu, 12 May 2016 20:16:03 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:34210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10ln-00038D-Te for qemu-devel@nongnu.org; Thu, 12 May 2016 20:15:55 -0400 Received: by mail-qk0-x241.google.com with SMTP id i7so7140863qkd.1 for ; Thu, 12 May 2016 17:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8avz0t+gH7Dqns5hRBmeCHeZ9tmvcAioYZ27FP1vfX4=; b=T7KleWna8/6zBDmMjsUo1VIKPR6YF1OGggGMh8GJ0wwd3HOgju3Z7Gj527ZdGaNmiv RaSF01nsdzmFk1YGXNOtNQFBagpXIKFZ+sFAvgqCjHXIf0sOVDm3KO8Wc2XwlvV1K5cX isfTt8+79ipJ1VOpsmlLg1Hm8LDtqXp9x4XMYodMb5VWKRyqbKpFiTboOxIZeW0wboXF eidSakDvx0xF/cf6aurePMoTvupSPS6rfc3jtKLnyqM8bP+Vt5ifbr5hCK3n4BM5aJqT 5stYkeNPp0Jgux5Suc52i6Xl7GYlOWgVqkFLjC0WQsZHI5/V1cazJdjIjuZ4mllrJxjC p2FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8avz0t+gH7Dqns5hRBmeCHeZ9tmvcAioYZ27FP1vfX4=; b=HQQr+anExQh0AiY5GpyEdh2vVnW/NoKNotJkVzo9RGH0vXkDavNiaB8yETJx8ZoPAz 8d9GMi12nBC20O6uXSV2d7nmza1mqE4p2dp41p/233xDogjEM7fKqnjlHjwkWW/crv4u nfGdjr759sZFihBYLhWVR3xepRarWosFkE4J5ZGBG+lxsQEO/CCAJ8lCS8rESPBtSq/v 4zU/66KWFwRN4kvSR9aMPvbW/yE+ntQOPOoWA98tNaDlxTBuyER/bYwVWS/g7GZg8LzG j7RnZ52gTKfomKNTG6fKE20JVc0cELGjmwhEapU+sc3baU+WtXIzuWggkyrxeDcqu3iw EpSw== X-Gm-Message-State: AOPr4FXg2kARSWqzxsmT21TBPx7RynVpooK9FZirOShBZUBiBoIYzW/Njk9Gh8oPz0hqSg== X-Received: by 10.55.201.68 with SMTP id q65mr4188083qki.34.1463098555697; Thu, 12 May 2016 17:15:55 -0700 (PDT) Received: from bigtime.com ([172.56.44.137]) by smtp.gmail.com with ESMTPSA id w16sm7171321qka.35.2016.05.12.17.15.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2016 17:15:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 14:13:35 -1000 Message-Id: <1463098420-29113-35-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463098420-29113-1-git-send-email-rth@twiddle.net> References: <1463098420-29113-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PULL 34/39] 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: peter.maydell@linaro.org, Sergey Fedorov , Sergey Fedorov 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 Message-Id: <1462962111-32237-2-git-send-email-sergey.fedorov@linaro.org> Signed-off-by: Richard Henderson --- cpu-exec.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index d55faa5..529cac2 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -352,6 +352,28 @@ 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 +405,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);