From nobody Tue Dec 16 07:06:22 2025 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.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520983859346464.18701945227804; Tue, 13 Mar 2018 16:30:59 -0700 (PDT) Received: from localhost ([::1]:43522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evtNi-0001OB-BJ for importer@patchew.org; Tue, 13 Mar 2018 19:30:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evsiZ-0006FI-Ka for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evsiY-00042h-LG for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:27 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:54943) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evsiY-000427-Do for qemu-devel@nongnu.org; Tue, 13 Mar 2018 18:48:26 -0400 Received: by mail-wm0-x244.google.com with SMTP id h76so872307wme.4 for ; Tue, 13 Mar 2018 15:48:26 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id x107sm1557951wrb.97.2018.03.13.15.48.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 15:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dEqAtHiYGIMCeu4sUlZ5EN0affr9x1E9X7PP6TWOz7E=; b=uZ/wTptQvFl2AFrd/PQ1/e/AlKqFy4cxyNF9v4UXdLQsyXikJV/Rn1tDcctcX+yQ4+ mGDOohrx8hg9Cng2LCP2FzL4tzt0QxSke43dhnteUhEpcaGpXySKB9cEis+NBOlWNL/t PW5TbYaDpR9TGnDvjifg8XEIZpKs7Kc3Z6QgutHQ8Vjr3BnHSdLC8lpEl69DuZSshPdw 6SuFCuKQU5ZZLM7BEF38t4JKSm/4CkSZ2kkNPtLI5/zIGh/ZvT9icYkrZVoRVvj49qDL q9msG6yvuVxNvcXWbiwnACr682yvUcmL9RrxQ+74580mOqQEeGsbqEDmhFqXgSrp6diW lhSA== 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:cc:subject:date:message-id :in-reply-to:references; bh=dEqAtHiYGIMCeu4sUlZ5EN0affr9x1E9X7PP6TWOz7E=; b=ROBykS1dGtXQyb2qI6tj/zyl0Zec9v0DIuYVkhp2DqhvobRLfZNK5fqiCCO986U0e4 mrAgiVZEsCLMN2iZZ1/VSqQJizVOczKP1eis6JMSqOdw4kcJHwVhB1HfA78MgsDF2AmD Ws8LrkmkhooWs0CuEFeGlkfg2R1AF/Y4nMM98zz5rnmGkvZcTKDnxfYLKnhIOFpQFQUU PNIx/qLQBwe9lqXZoTLsttGKrKHnfpSMushzzA1opaymUk4zrjLLVU9mzMiEXt3AFJhM HyBFp2RUNd1i/Y4SJOHHwXaa1YMSf7q1AvbHlqFw6hDJy+oXrDV1MvTmfwjf2fyfxIsc kHvg== X-Gm-Message-State: AElRT7HNTo8e4inxNCLDEwoQPYsXubNNWj6kOSlrquqq2pkFB5ovNkVi 05MnEml9Q+FO/W5kcEKWd30Z3dnt X-Google-Smtp-Source: AG47ELvcU1zV4X9vIOjLeYBoIiZ1NLD4LVgqyAR+D5maaftNqUB56vay9y241mm4jf4yb/zWbi3Vkg== X-Received: by 10.28.51.67 with SMTP id z64mr1966209wmz.59.1520981305057; Tue, 13 Mar 2018 15:48:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 23:47:02 +0100 Message-Id: <20180313224719.4954-53-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313224719.4954-1-pbonzini@redhat.com> References: <20180313224719.4954-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 52/69] cpu-exec: fix exception_index handling 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: Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk Function cpu_handle_interrupt calls cc->cpu_exec_interrupt to process pending hardware interrupts. Under the hood cpu_exec_interrupt uses cpu->exception_index to pass information to the internal function which is usually common for exception and interrupt processing. But this value is not reset after return and may be processed again by cpu_handle_exception. This does not happen due to overwriting the exception_index at the end of cpu_handle_interrupt. But this branch may also overwrite the valid exception_index in some cases. Therefore this patch: 1. resets exception_index just after the call to cpu_exec_interrupt 2. prevents overwriting the meaningful value of exception_index Signed-off-by: Pavel Dovgalyuk Signed-off-by: Paolo Bonzini Message-Id: <20180227095140.1060.61357.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- accel/tcg/cpu-exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 280200f737..9cc697205c 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -585,6 +585,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, else { if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { replay_interrupt(); + cpu->exception_index =3D -1; *last_tb =3D NULL; } /* The target hook may have updated the 'cpu->interrupt_reques= t'; @@ -606,7 +607,9 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(atomic_read(&cpu->exit_request) || (use_icount && cpu->icount_decr.u16.low + cpu->icount_extra =3D= =3D 0))) { atomic_set(&cpu->exit_request, 0); - cpu->exception_index =3D EXCP_INTERRUPT; + if (cpu->exception_index =3D=3D -1) { + cpu->exception_index =3D EXCP_INTERRUPT; + } return true; } =20 --=20 2.14.3