From patchwork Mon Feb 28 18:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 546699 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp2970180imf; Mon, 28 Feb 2022 10:11:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9R80jCq4mB+30ePC8wY8SIDJxWRGmlVwpxsCXVEBgX/5vCV4onW2kvCTyYUhKZzmz68DI X-Received: by 2002:a0d:c585:0:b0:2d7:85cd:d9e5 with SMTP id h127-20020a0dc585000000b002d785cdd9e5mr21433303ywd.118.1646071887593; Mon, 28 Feb 2022 10:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646071887; cv=none; d=google.com; s=arc-20160816; b=EhhMrvDboQW27p/Z5VxmhH2FYifHqCZd61pg9rKjaV6RvWccZ5xvMsQJCinMT8cUnF Fki3W0f5IZz6on0yeiNz4GHIT/g1hJJTmoiVFmA4EtD02SZ0TEaI42h/hQrA8vpk98eg QZz5YDdXPQ20bpZ6pblQHEeeuQJsasJmzxCEFqckLETw9JmEn8xvSGFy1uExu6aIIAb/ SoKhtBThY0uCXicNsMM33AujhefhR2KQHNN0C5nZt4JkxPb+YAa49DrspDCUNKQNcEPq hqeQddXKpc5tqI/ZGal3Pu4HNW5vUgPzMJk53M4V/s3jMSKNvBbLiRmyRcOBre3SwBk5 KOWA== 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=JX1igWOeqSJm9dC+Azizqq1/K1aDjmaX8UXrJxn6OL8=; b=xVUibmYYZikF9y30TwW+X/WwLlc0EU/YCPIKLCkHuf0mXgF9JQw+XWIY6XkRKl14p2 5535vMUyTjKAB32ITaOW3nAyHpqfGCfAR6lXqwz2D41ORPZqGZkfcxvTbaGL1ncTmEIS ZbCaf8iekxRik3P/c86ieof8Wk4n6knv9XsrICAu4RcJfGOfHph1ChhzKsXNk/wxi3NH KMo+4+SUZQ8Y/2j75mjjWq1ptcyxSxXf4/eXkNiKF9tP/B0wl2eizyGKT3RTs9KMxb+T nuMZCZn537iKFFfRI25QenAQjZ1Zn83jEqUj/4PLH2X4PjyGs95masTZt0keuQ4TIcHS x+TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=emlsnLng; 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 y137-20020a25dc8f000000b0061fb67a9aefsi9594011ybe.151.2022.02.28.10.11.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Feb 2022 10:11:27 -0800 (PST) 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=emlsnLng; 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]:43178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkUZ-0004xk-4O for patch@linaro.org; Mon, 28 Feb 2022 13:11:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkSd-0004vv-0P for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:09:27 -0500 Received: from [2607:f8b0:4864:20::529] (port=39501 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkSb-0005xN-G3 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:09:26 -0500 Received: by mail-pg1-x529.google.com with SMTP id 195so12237723pgc.6 for ; Mon, 28 Feb 2022 10:09:25 -0800 (PST) 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=JX1igWOeqSJm9dC+Azizqq1/K1aDjmaX8UXrJxn6OL8=; b=emlsnLngKp+iC5JSB7gyQfJcEbsCNT4DBPPPimMi5C/4alkuTz5HxXu0Oi7zKqsE77 T5PHHj+polxnO0T2ERYRAv5fBNe6q1np/kKM0mnH7RF1ijvlNMe6JPdvVCyEgLDb9qOl QDQn8nrn0w6Yla+/fqVUnVtjRiXv80flu0AfzEPbSwNAse4fneRcdB003DVKHEYwM1Vy mCV2sjNEjwVej7mPyNmWXgSSjdKHbsJJpog9u90PbV7VSilaPixQkuDlJQ9JJii2wdRt hjL08XzMvYPij0JLR32Vw7rwNYwyE5haJNfCc0qr10NYvvx0N25vaMr5K6zqqgg7vl0G ugSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JX1igWOeqSJm9dC+Azizqq1/K1aDjmaX8UXrJxn6OL8=; b=iN8wpKem+XmvB7zVv5DKtcplJJoNI1VOD0h7fA0haiIvBdokt/J+iLXlStT0QFR2nG kEqi0NGEOSKjdP2ShTqQOBCIzJ3sIY+j3WGSi7jZHWzMRbqHcZjylmrHPQqGiOkOM4DC 0JOGrjCcGmh/WXy1MOveVSM+0ZAaic712H5Ny6i/4lqRJl9pfIPajpIuMi+BHG8E56jy py35RobqKNpyDlCPsUL++uq6VI4dRlMerS+JA9a7XJ05dSAwMuX8Q1BUVnKiYx+nyVO5 RExIJURTRDuVMxkkQxFhCLX1v3EzMqYdGpaEP1bYcJ8Q6FGTrsK9K3XsSjKEUpJE05fX qO6g== X-Gm-Message-State: AOAM530Dkty43q3d4AQxBboQ8vUdx1j0yJoU3RCPE9PPY9Ax+0AnqZCR rAFNQA6AlOgeR2Jr+55RcpZeVKnMeV1thA== X-Received: by 2002:a05:6a00:140b:b0:4e1:2cbd:30ba with SMTP id l11-20020a056a00140b00b004e12cbd30bamr22929569pfu.46.1646071764054; Mon, 28 Feb 2022 10:09:24 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-483f-d486-138f-7868.res6.spectrum.com. [2603:800c:1201:c600:483f:d486:138f:7868]) by smtp.gmail.com with ESMTPSA id q24-20020aa79618000000b004e0e89985eesm13463223pfg.156.2022.02.28.10.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:09:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 2/3] accel/tcg/cpu-exec: Fix precise single-stepping after interrupt Date: Mon, 28 Feb 2022 08:09:17 -1000 Message-Id: <20220228180918.38188-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228180918.38188-1-richard.henderson@linaro.org> References: <20220228180918.38188-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" From: Luc Michel In some cases, cpu->exit_request can be false after handling the interrupt, leading to another TB being executed instead of returning to the main loop. Fix this by returning true unconditionally when in single-step mode. Fixes: ba3c35d9c402 ("tcg/cpu-exec: precise single-stepping after an interrupt") Signed-off-by: Luc Michel Message-Id: <20220214132656.11397-1-lmichel@kalray.eu> [rth: Unlock iothread mutex; simplify indentation] Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8da6a55593..c68270f794 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -799,8 +799,12 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, * raised when single-stepping so that GDB doesn't miss the * next instruction. */ - cpu->exception_index = - (cpu->singlestep_enabled ? EXCP_DEBUG : -1); + if (unlikely(cpu->singlestep_enabled)) { + cpu->exception_index = EXCP_DEBUG; + qemu_mutex_unlock_iothread(); + return true; + } + cpu->exception_index = -1; *last_tb = NULL; } /* The target hook may have updated the 'cpu->interrupt_request';