From nobody Mon Feb 9 23:58:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487258871440732.6533486689785; Thu, 16 Feb 2017 07:27:51 -0800 (PST) Received: from localhost ([::1]:47331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNyH-00057r-VY for importer@patchew.org; Thu, 16 Feb 2017 10:27:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceN6g-0003sU-IK for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceN6f-0008D7-6l for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:26 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceN6f-0008CW-0N for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:32:25 -0500 Received: by mail-wr0-x243.google.com with SMTP id c4so2275630wrd.1 for ; Thu, 16 Feb 2017 06:32:24 -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.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 06:32:23 -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=MUHRgiAbIxDrsdnFzUR/4sf6GwHfWsA4xp6xSQV7BT4=; b=rOL1ESzgaI017cb2Tm73s4xHlrb2VTpzUHJlyubxNirVlYPj/VN6rSP0uUvqZ7K8zu AtLc6nylsPo+/IiF0Wtj0bzR+UCX5co8Y3UcU2rZuElzj1Ujsf6K4XZdkrXm1ovC/4MU SY23fc94ULOmlo/Rf/YR8MuNxz8QG+xOvt4w6vV1+X3s1ix7XwUE8zJX0Zl2CB3bnCEM pwjBAGjocnEXT28oujcTeHnqtRR1p4dmYda7exCRfC9rcAir0z6JMXdc79Jorn2U5x+b TQKskGrfYTVegO5Mxry3IRICXwgK6/JSjOB7LunqcGblq0E/0fTKy1XizXWTHlfHSMSx iRSw== 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=MUHRgiAbIxDrsdnFzUR/4sf6GwHfWsA4xp6xSQV7BT4=; b=lIsJanomVzp6F75uH9oF1HfJ10pi8nPVUJoDp64nCG2rsWc8Bpvfd8VeVTSG4crO21 CZcJRD1hs4h4exHCUJlNY+paxmtUKnepHnM1cpMFXkFUK3LcJDzuUMhSP3l9E/Jz2O9r xLCbrmpfVOJrqL0tq0OBri8vvSd3cdTbJ8K/tgC1L4F8W2PLvPXNGQfvZpoewQuJzE87 XpzpTjbQXq8IfrRwHx1BVCyIkQJDsLdr6GQUUFIeBzA6ZD1hi9rHxAdNhDvg/3vhl4fR hISOuZYQThhmp05LppNtVtt72zBuSibyy4IyvqJaUxP90a5OqVJAAqmV4195+hbjvqY7 j75g== X-Gm-Message-State: AMke39mujK2vKrK5MAUuBuMtl9Mw1pCQ5gcxkd4haUR33zN/Pw7HdczRevt4MnVhYHTo/A== X-Received: by 10.223.129.4 with SMTP id 4mr2970814wrm.27.1487255543807; Thu, 16 Feb 2017 06:32:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:31:37 +0100 Message-Id: <1487255507-106654-14-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:c0c::243 Subject: [Qemu-devel] [PULL 13/23] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The siglongjmp goes straight back to the beginning of cpu_exec's outermost loop. We do not need a siglongjmp, we can simply leave the inner TB execution loop. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index d50625b..ed2fbc6 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -461,7 +461,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) return false; } =20 -static inline void cpu_handle_interrupt(CPUState *cpu, +static inline bool cpu_handle_interrupt(CPUState *cpu, TranslationBlock **last_tb) { CPUClass *cc =3D CPU_GET_CLASS(cpu); @@ -475,7 +475,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &=3D ~CPU_INTERRUPT_DEBUG; cpu->exception_index =3D EXCP_DEBUG; - cpu_loop_exit(cpu); + return true; } if (replay_mode =3D=3D REPLAY_MODE_PLAY && !replay_has_interrupt()= ) { /* Do nothing */ @@ -484,7 +484,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu, cpu->interrupt_request &=3D ~CPU_INTERRUPT_HALT; cpu->halted =3D 1; cpu->exception_index =3D EXCP_HLT; - cpu_loop_exit(cpu); + return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { @@ -494,13 +494,13 @@ static inline void cpu_handle_interrupt(CPUState *cpu, cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0); do_cpu_init(x86_cpu); cpu->exception_index =3D EXCP_HALTED; - cpu_loop_exit(cpu); + return true; } #else else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - cpu_loop_exit(cpu); + return true; } #endif /* The target hook has 3 exit conditions: @@ -526,8 +526,10 @@ static inline void cpu_handle_interrupt(CPUState *cpu, if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt()= )) { atomic_set(&cpu->exit_request, 0); cpu->exception_index =3D EXCP_INTERRUPT; - cpu_loop_exit(cpu); + return true; } + + return false; } =20 static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, @@ -625,7 +627,7 @@ int cpu_exec(CPUState *cpu) for(;;) { /* prepare setjmp context for exception handling */ if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { - TranslationBlock *tb, *last_tb =3D NULL; + TranslationBlock *last_tb =3D NULL; int tb_exit =3D 0; =20 /* if an exception is pending, we execute it here */ @@ -633,14 +635,13 @@ int cpu_exec(CPUState *cpu) break; } =20 - for(;;) { - cpu_handle_interrupt(cpu, &last_tb); - tb =3D tb_find(cpu, last_tb, tb_exit); + while (!cpu_handle_interrupt(cpu, &last_tb)) { + TranslationBlock *tb =3D 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); - } /* for(;;) */ + } } else { #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) /* Some compilers wrongly smash all local variables after --=20 1.8.3.1