From patchwork Thu Feb 16 14:31:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 728739 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vPKMH27Ywz9s8T for ; Fri, 17 Feb 2017 02:09:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HFJdOj9K"; dkim-atps=neutral Received: from localhost ([::1]:47232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNgm-0007LN-Kz for incoming@patchwork.ozlabs.org; Thu, 16 Feb 2017 10:09:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6h-0003tv-PO for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6g-0008ES-Vt for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:27 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6g-0008Dv-Pn for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:26 -0500 Received: by mail-wm0-x243.google.com with SMTP id v77so3429115wmv.0 for ; Thu, 16 Feb 2017 06:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=1TTYfXqbKG+aN88Xyh3R+gs6WXoY4FWdnBM8F5xEq8Q=; b=HFJdOj9KgX8sXs0LrOu5MRbYNGibBdEGxS03+FvJGLt5X6R5+55btyTl7Aw1cA+Kkt dGiXByGt8tnJRFieqozt+PvGEoH5FJS8lr0OH20xEmMyZRQJpn4gK4UGZnz8Q9mH76cN 0exWVQ2Izj4+OP9eEHLLCubZy8qX+y3eyxgKi9fG78rbo4zkBO4asDM7jOOdIt06FWbf 2q6KSHuEZxjBDqoz6bAtwtAKaH6Ze4hlv++g73ryHyfBIRICSVXET0FbhZY2PcxDCFBM sDpdKNSDy47xHaR9eNLkiHYR1g12eg0hq6mMDd5a+P3No9/B8PNNRPzq6O51FnZam8uq rCxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=1TTYfXqbKG+aN88Xyh3R+gs6WXoY4FWdnBM8F5xEq8Q=; b=beksvpZGU8jHBr/xbp+W9Ff5fW917RSF1+iz6zQXcwwBrEuGkiVIjc8CjFS8O7cE9k DnOl3xIf6Rsw7ErRCHkLwJAd2GYK2newZpAnTGCmoSeHUjqH9CHF8J53pZzFgQCw1dLO MgQZ6kP0okx2z/sOSNovisHKZfznhYn7cjF1z1w2M04dU3rTAvlUPN3lNlcm12uBTTs2 VlPFBWh9INzQ8tV3CzrNog33eyK7JUV1gALQ949oIAQjn3/Dd1DWxqY6t/p8smir66P1 RngfqnsdhkPnGmgQ6qOdr4TPUsguMWqARhRiSpqQE3WmK8FeXhZ03dRlMGHLRHBjaCpY wjFA== X-Gm-Message-State: AMke39mkYh6Hqm4BuUVvFBE9s64ulnSVzIt04PC3dpofOsgGFOSoarq2/7Xg1JcB5kK06w== X-Received: by 10.28.126.12 with SMTP id z12mr2941004wmc.84.1487255545648; Thu, 16 Feb 2017 06:32:25 -0800 (PST) Received: from 640k.lan (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.gmail.com with ESMTPSA id g5sm9203365wrd.0.2017.02.16.06.32.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:38 +0100 Message-Id: <1487255507-106654-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> References: <1487255507-106654-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 14/23] cpu-exec: avoid repeated sigsetjmp on interrupts 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The sigsetjmp only needs to be prepared once for the whole execution of cpu_exec. This patch takes care of the "== 0" side, using a nested loop so that cpu_handle_interrupt goes straight back to cpu_handle_exception without doing another sigsetjmp. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index ed2fbc6..865015c 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -627,21 +627,21 @@ int cpu_exec(CPUState *cpu) for(;;) { /* prepare setjmp context for exception handling */ if (sigsetjmp(cpu->jmp_env, 0) == 0) { - TranslationBlock *last_tb = NULL; - int tb_exit = 0; - /* if an exception is pending, we execute it here */ - if (cpu_handle_exception(cpu, &ret)) { - break; + while (!cpu_handle_exception(cpu, &ret)) { + TranslationBlock *last_tb = NULL; + int tb_exit = 0; + + while (!cpu_handle_interrupt(cpu, &last_tb)) { + TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); + cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + /* Try to align the host and virtual clocks + if the guest is in advance */ + align_clocks(&sc, cpu); + } } + break; - while (!cpu_handle_interrupt(cpu, &last_tb)) { - TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); - /* Try to align the host and virtual clocks - if the guest is in advance */ - align_clocks(&sc, cpu); - } } else { #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) /* Some compilers wrongly smash all local variables after