From patchwork Fri Jul 17 18:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 235748 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1940582ilg; Fri, 17 Jul 2020 11:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKaX9OKZveE7hNi9ICMLlli2Xr63Dq2XllrBt73F79q4tUbTkJjL6uRJE8X3UgaqaEDWfp X-Received: by 2002:a25:d1cf:: with SMTP id i198mr17220079ybg.406.1595009938919; Fri, 17 Jul 2020 11:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595009938; cv=none; d=google.com; s=arc-20160816; b=FOrpm9FSrhUSdMrN8+6IVhTFMZrpilnQmQv9yb3W9Lf4OqqPe+maJws1XIxfgNeNw5 mS3nh+VkXEy8iglAXFFToJuuL6wiKTFguFr58rAPoGHPkGpaNSsftkDbtpTfnnnvnVZ8 dG/bm99Ivsh/G8oq12NN7g9j8ekI6IEybQlI0t9gOZKuYDx7zUxmePtij7AjhuF5EyB/ e9l9FxizABc/8BtKJo16KwYvDWAvVsYsWtIX4ue3IyKZeiE58ZyIPFBkpOee3pjZJPAs FxC/EmoTSxbGpvw6ejIgmd9AG2u45zIoN+isOrQwew4/tjJpG2pyYOdihu05jk3+WsYv aLsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=soz5/dc63AWvfYnTeEOXYkPjarLppwOrJCQsvAF2Sbw=; b=nQG8iEKLrII0JZvyjiqjoDHhpHjE8G/UZ+B/Eye2HDfSZF1tq5U+d+N11CiviMuCca KEvhvBOaP7pYW3Ind0+MxcPMzezIhNKJrW9T7G8v+fq34jkJea2ySlPNFRD5i0hSTKVc zmhpqU1KF0UPVgb/GFjtdx6MgaPHMeeRjy0e7qAe9yXtvSLsP8KZaYw+3o6P9yLlCris 4xuygHbs3/tAIzkcctXUInPXMOdcJ0BXxM0ymXYW3fKuLC43jpPc2UmnV6WDiv4LsFYa 6SBE6nK/cwbLwIi+SyrTZtD5Duk+gtNGiSOkn5bk/fHaEqF5DnyMR76sbjJkCO4Rdv7p 4hvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtEOIcjc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i68si9507260ybg.464.2020.07.17.11.18.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Jul 2020 11:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtEOIcjc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwUwk-0002f5-DA for patch@linaro.org; Fri, 17 Jul 2020 14:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwUuP-0008U6-1i for qemu-devel@nongnu.org; Fri, 17 Jul 2020 14:16:33 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:38896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwUuM-0003HK-Un for qemu-devel@nongnu.org; Fri, 17 Jul 2020 14:16:32 -0400 Received: by mail-pl1-x633.google.com with SMTP id m16so5792005pls.5 for ; Fri, 17 Jul 2020 11:16:29 -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 :mime-version:content-transfer-encoding; bh=soz5/dc63AWvfYnTeEOXYkPjarLppwOrJCQsvAF2Sbw=; b=gtEOIcjcSir6uFvFnTXVDiyfze6bhdwMBkKx2ZxGa1H7E9PSk6uAFCNXuVNEVUm1lU a91XLoqcSnUN6/wK8SPhT1VpCiguqm8uRiEqNXpwRC1XOB2xAwy76DXUnFFBLkcGaZtK 89jzGTEsufPI4cwSp7DqtDFrAnQ3oef738QHIEaV5exRLdti1Hbp3c96WpsxJpFQdWj4 k6LvLDlDxOH2WlhWGEsQ9O+ex11Uk/xzEhXk4Hgnu8uThqvN3Ppgd3Ech4x/ax8B/pRd ER/9n9ub4asA14dCSAdIMEG+JsRlxeITYDzOyX7XdrmxM6kXR/LN2SMRIbO/0dWdd2mb fjig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=soz5/dc63AWvfYnTeEOXYkPjarLppwOrJCQsvAF2Sbw=; b=dBw3Tjkn7ckfkEyTs/F5fPyFuLW8obPo225nmx2VH/Mdb66LDxJTGuQxEVgXGsStNQ Xjox4tPm69C1HgcxcYKkStWcsa5a7csSdnTSMNw8wN382V23dJ2L29gQahhUTzHuyB9r RKBZALdd53n4wPSTL7Zmr1p0jzosiJ4SYOnJYiu7sdGw5PjzdPivSfH4a31/gzspmod7 wPeExavkPI1rSYBlvWvslhl7f68oh5SPadQIOwk0CWbVFeA5EPnBYPwvqbmzVDHqq+/O Z5ddqY9xrptt5KuY0xl01cGym5o3hSJN1ZWDO3efHq3EST+kbhH7EfZYsAqxRJLm15Dq Pxfg== X-Gm-Message-State: AOAM533N7Ab6B/at1TgqPFFKigpRt5NARvABw+bVQVxyR1xZd3/4qUMi uBjzl/t/K/zLSIC/M5xxOIfH6kUYAks= X-Received: by 2002:a17:902:be06:: with SMTP id r6mr8129071pls.143.1595009788686; Fri, 17 Jul 2020 11:16:28 -0700 (PDT) Received: from localhost.localdomain (216-160-65-90.tukw.qwest.net. [216.160.65.90]) by smtp.gmail.com with ESMTPSA id r7sm8698578pgu.51.2020.07.17.11.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 11:16:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-5.1 3/3] tcg/cpu-exec: precise single-stepping after an interrupt Date: Fri, 17 Jul 2020 11:16:23 -0700 Message-Id: <20200717181623.2742758-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200717181623.2742758-1-richard.henderson@linaro.org> References: <20200717181623.2742758-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Luc Michel Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When single-stepping with a debugger attached to QEMU, and when an interrupt is raised, the debugger misses the first instruction after the interrupt. Tested-by: Luc Michel Reviewed-by: Luc Michel Buglink: https://bugs.launchpad.net/qemu/+bug/757702 Message-Id: <20200717163029.2737546-1-richard.henderson@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6a3d3a3cfc..66d38f9d85 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -588,7 +588,13 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, else { if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { replay_interrupt(); - cpu->exception_index = -1; + /* + * After processing the interrupt, ensure an EXCP_DEBUG is + * raised when single-stepping so that GDB doesn't miss the + * next instruction. + */ + cpu->exception_index = + (cpu->singlestep_enabled ? EXCP_DEBUG : -1); *last_tb = NULL; } /* The target hook may have updated the 'cpu->interrupt_request';