From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104552910341.0689562095854;
 Mon, 12 Jul 2021 08:42:32 -0700 (PDT)
Received: from localhost ([::1]:36104 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y4l-0006oA-Qy
	for importer@patchew.org; Mon, 12 Jul 2021 11:42:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59782)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2V-0003zO-7G
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:12 -0400
Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:45740)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2S-0000sb-9f
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:10 -0400
Received: by mail-pl1-x629.google.com with SMTP id p17so8874958plf.12
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:06 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:05 -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=MxG3oPkWJFIg64tHYkF9MZw/VV9NOtSqfDFOnVqpJsY=;
 b=rZ/78dB6wptn2cCwk6chjyCaNQw4ZM8Co/YU0CkLvyVUU/fY1LyU1YSQCd23Z3d+uD
 k6eKc6Qy82kZzrl1hbMA36a2TivnoBQeuv3e8mDQu8oAe827sdsuHb95D7DApAE8G8NN
 8a04Jh1LabaLupv2ABiUYvls7eSSYfKjvws5Axz5/yN+BltowqbFSWnVx22MB0Lu6iE6
 38LXBPStEtdcuCCukxL5hFtbArI5pT5vwTIMhG//I95Zn9WSoGkZaQcQSw4RV3MKWLUT
 +8VsuGzvCwYnaO7InZ0B0y491yKcdrhb0I8m7+i1L18PlsTzHwC3Of2piSYFtuAUSWdT
 hwbw==
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=MxG3oPkWJFIg64tHYkF9MZw/VV9NOtSqfDFOnVqpJsY=;
 b=O+XrINwcmtf04d+C9Us16YQ0Ms1bZwWnJDFLIQNNZn1n+unv38lPrhWde8Yjqyx4k+
 vH+HvDATk0Aea9pwdiGP0XU14RnRDPj8eyRuaUnOJHkNX5GH8deGlFK0nVX5Ayv/Lb2u
 FImzlS3pf03PbU+/tNTxLW1zHXbMcc/GK33KSJeG4XEq92fHpTB/wnkj0ksYhwT1ukqT
 Uoh/yRO20JgjzSMo0o6vsZQvq7bMay0a4fyYfnvJKMfs6L1hgFH6II5sd5KhdNr8ucCD
 s1aKC3lGPO/QfzMwCQpFrfdf+/vTXPdzeBg3biz67V62btJ3q4o2C+/2aAa/eDZorzxD
 VOww==
X-Gm-Message-State: AOAM533FyK+O4tXQ4FecN8UWVw+Cj1f+QcsoFnGsPFwTAiYmAoC0LC69
 /DRe+skQf/0aYNB7gKNbp5ycTcIDUXYoVA==
X-Google-Smtp-Source: 
 ABdhPJzHkg8noKKI6HdFo8zpP7lPqV6lM1AlRa2QG2gPh8KllpbWCcmDGwdz+HkcQJRUdMAnF9bUbQ==
X-Received: by 2002:a17:90a:420b:: with SMTP id
 o11mr52733681pjg.201.1626104405723;
 Mon, 12 Jul 2021 08:40:05 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 01/10] accel/tcg: Reduce CF_COUNT_MASK to match
 TCG_MAX_INSNS
Date: Mon, 12 Jul 2021 08:39:55 -0700
Message-Id: <20210712154004.1410832-2-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::629;
 envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104631602100005
Content-Type: text/plain; charset="utf-8"

The space reserved for CF_COUNT_MASK was overly large.
Reduce to free up cflags bits and eliminate an extra test.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/exec/exec-all.h   | 4 +++-
 accel/tcg/translate-all.c | 5 ++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 754f4130c9..dfe82ed19c 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -492,7 +492,9 @@ struct TranslationBlock {
     target_ulong cs_base; /* CS base for this block */
     uint32_t flags; /* flags defining in which context the code was genera=
ted */
     uint32_t cflags;    /* compile flags */
-#define CF_COUNT_MASK  0x00007fff
+
+/* Note that TCG_MAX_INSNS is 512; we validate this match elsewhere. */
+#define CF_COUNT_MASK  0x000001ff
 #define CF_LAST_IO     0x00008000 /* Last insn may be an IO access.  */
 #define CF_MEMI_ONLY   0x00010000 /* Only instrument memory ops */
 #define CF_USE_ICOUNT  0x00020000
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 4df26de858..997e44c73b 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1430,9 +1430,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
     if (max_insns =3D=3D 0) {
         max_insns =3D CF_COUNT_MASK;
     }
-    if (max_insns > TCG_MAX_INSNS) {
-        max_insns =3D TCG_MAX_INSNS;
-    }
+    QEMU_BUILD_BUG_ON(CF_COUNT_MASK + 1 !=3D TCG_MAX_INSNS);
+
     if (cpu->singlestep_enabled || singlestep) {
         max_insns =3D 1;
     }
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104661673592.0324681659455;
 Mon, 12 Jul 2021 08:44:21 -0700 (PDT)
Received: from localhost ([::1]:44478 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y6W-0003sC-Jh
	for importer@patchew.org; Mon, 12 Jul 2021 11:44:20 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59850)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2c-0003zd-38
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:23 -0400
Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:41692)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2S-0000so-NW
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:12 -0400
Received: by mail-pl1-x635.google.com with SMTP id z2so6501045plg.8
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:07 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:05 -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=se0upj8uwwed3TnJTE/iIfzC0n2efWNdGM2VdkwZygY=;
 b=JU75f5JD818jhOvM37jFGK3n5GcdI6qqJwqUizQupDNLpzIaPL7FAQzmMPaIfE26Ph
 A8/8Rao6288hIj0iz1JbyEk36zMOPthnnktlmrG+UMbO9oY/IZIfftIp5hNok3XPp/Dr
 uozt6VRY2kF5yAup7it5Q/fAie/MzEKLrgyNkEdPusuwxL0woLnNId9EpW0Ox4YJPrPu
 imENpzFhUDMysrqLnV+/0NBR46GiZj2s4EC/YwPAVAg0AJgF8viGpv0ETApl5kmcy3z8
 4o+FmwY9d7BRsOCe724qyxN6lbyP3X6D9g7xN1N8rv6zSzJxRQ0Vw7zwF74vfZBYR0Np
 4PYg==
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=se0upj8uwwed3TnJTE/iIfzC0n2efWNdGM2VdkwZygY=;
 b=UMz48aC2Fmd5pdBCU3E5DXtg2Zl5wyM6diGQMzD+QP6ID6Mpbe9mNIuZwNzXyMyO2r
 RluNjDUGEFU2bs9CBgqUP3PDWtKhxxvCPTlRKFwLbsKyBgz6kCHURBdsDQ5NaSagvZl+
 kAbZugjM6fY8/dzgCYljiRCdO4BQtKnr8uetPvWmBavvA9jy4DVtGjiQvpaaFbN6mAkg
 5n2LzvNy2N59oH4HIP5sWe3ibC9z8nv6V2NHygSbAmxhRBhNawwe6M/PWj57Z+duEp16
 ixEnMKlkuxNoKF5+LABl9Ky2emHq4QeylFDQI31sjsOO7DZhZnt1CKdCMJrWYL5ZoW8h
 mWLA==
X-Gm-Message-State: AOAM5335/GuPB/gQFWPr3SePfIIRIuRf3tKmyemdshGK9bhbrMomoMvB
 C6M2oH4UJyZRI9edaz0pWgV8Me6xnq4b2w==
X-Google-Smtp-Source: 
 ABdhPJw9uBI189BcJX0kw0wB+CEY4c6QxtMS+BO8Oof2d23MZf5unRftecVFQTmuDg3SbHiJSKFVWw==
X-Received: by 2002:a17:90a:a107:: with SMTP id
 s7mr14641787pjp.1.1626104406231;
 Mon, 12 Jul 2021 08:40:06 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 02/10] accel/tcg: Move curr_cflags into cpu-exec.c
Date: Mon, 12 Jul 2021 08:39:56 -0700
Message-Id: <20210712154004.1410832-3-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::635;
 envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104681373100001
Content-Type: text/plain; charset="utf-8"

We will shortly have more than a simple member read here,
with stuff not necessarily exposed to exec/exec-all.h.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/exec/exec-all.h | 5 +----
 accel/tcg/cpu-exec.c    | 5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index dfe82ed19c..ae7603ca75 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -565,10 +565,7 @@ static inline uint32_t tb_cflags(const TranslationBloc=
k *tb)
 }
=20
 /* current cflags for hashing/comparison */
-static inline uint32_t curr_cflags(CPUState *cpu)
-{
-    return cpu->tcg_cflags;
-}
+uint32_t curr_cflags(CPUState *cpu);
=20
 /* TranslationBlock invalidate API */
 #if defined(CONFIG_USER_ONLY)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index e22bcb99f7..ef4214d893 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -145,6 +145,11 @@ static void init_delay_params(SyncClocks *sc, const CP=
UState *cpu)
 }
 #endif /* CONFIG USER ONLY */
=20
+uint32_t curr_cflags(CPUState *cpu)
+{
+    return cpu->tcg_cflags;
+}
+
 /* Might cause an exception, so have a longjmp destination ready */
 static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc,
                                           target_ulong cs_base,
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104654391943.3275591640988;
 Mon, 12 Jul 2021 08:44:14 -0700 (PDT)
Received: from localhost ([::1]:43890 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y6P-0003Vc-BB
	for importer@patchew.org; Mon, 12 Jul 2021 11:44:13 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59878)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2h-0003zi-8W
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:24 -0400
Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:47074)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2S-0000tp-A1
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:17 -0400
Received: by mail-pj1-x1031.google.com with SMTP id
 b5-20020a17090a9905b029016fc06f6c5bso220285pjp.5
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:07 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:06 -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=88OJpuFNwx0H+XAN0LuxIptp2x4kYtdoZWDr35UNZ2k=;
 b=lvk1IQDOdSMPL6l7UIBaByeoAUBPTtUo4ThWHeBmRRdQJvZZBz83XTSGLlz5cyo+R0
 4K4MUak9H7jyoT3aU52yIvzx39WLZMclT0B6qyhd57i3IqlfmtsCw0c6tpg8gZSOR95k
 PREypxBKLm82uJekk32hIVeHj38vx7mv9WbnP6d4v/HsEmZLEfMFBEosZUC8forekUde
 Q47ViV9ySmPT1vmN7KD02aeGwzOsl6/Q/wv+J89DTufz4tXbKbDdmiCpI72+24H17kec
 AVmxr7gUiHXVuoO+WD9iV8hQcfRLr5MVC92UUKo5pGxwvosFR5cd3CHa4SQbB7FC/a4M
 xBSQ==
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=88OJpuFNwx0H+XAN0LuxIptp2x4kYtdoZWDr35UNZ2k=;
 b=oxRAQe1SxQXizUMqwoNtxRNwPn+kx2Ek6L47+Q5b4cXK9R3OelyYoFUKVb1Vy+flyU
 15d7dLW6pA+SNFIjVZbrrEuZHL87Uskqe5VtGtOZymaJJ7IMRH51GZUBcksG6FgyiC8w
 uwc5L6iRzU3mVHnQKlUg2kHa2EXh1a+gtJLev39imntk+aQwASY1B1uv6s40RpceJ9GL
 3TQECVh2qjXMWWVqLLghQwizsJdHmuy/nnLFSdUBggdOHSYk/7laJ+OePgf1v6qTEbzG
 +YWAK/4W3qNms19wTmJOmyjeM6LcO/+UwF23lNrgw1zomXyHGbD5bU/YGFaHzy3wzrmr
 ZAvw==
X-Gm-Message-State: AOAM532mf0HX5Ikp0D+MbMBS8nuylmhcVSKuHplV8OeSMKwSpc+Ab7It
 SfHgo1Q/PBImuOP1l6dkbp5g1BIzpZHIsA==
X-Google-Smtp-Source: 
 ABdhPJzl+U9bDGn7MctGw+elxAEmwihmYNzMAowAtognyKGt3zc5/vGG/mFCYzz05NdTdKe/enPJAg==
X-Received: by 2002:a17:90a:5e06:: with SMTP id
 w6mr52464526pjf.98.1626104406753;
 Mon, 12 Jul 2021 08:40:06 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 03/10] accel/tcg: Add CF_NO_GOTO_TB and CF_NO_GOTO_PTR
Date: Mon, 12 Jul 2021 08:39:57 -0700
Message-Id: <20210712154004.1410832-4-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::1031;
 envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104677419100003
Content-Type: text/plain; charset="utf-8"

Move the -d nochain check to bits on tb->cflags.
These will be used for more than -d nochain shortly.

Set bits during curr_cflags, test them in translator_use_goto_tb,
assert we're not doing anything odd in tcg_gen_goto_tb.  The test
in tcg_gen_exit_tb is redundant with the assert for goto_tb_issue_mask.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/exec/exec-all.h | 16 +++++++++-------
 accel/tcg/cpu-exec.c    |  8 +++++++-
 accel/tcg/translator.c  |  5 +++++
 tcg/tcg-op.c            | 28 ++++++++++++----------------
 4 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index ae7603ca75..6873cce8df 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -494,13 +494,15 @@ struct TranslationBlock {
     uint32_t cflags;    /* compile flags */
=20
 /* Note that TCG_MAX_INSNS is 512; we validate this match elsewhere. */
-#define CF_COUNT_MASK  0x000001ff
-#define CF_LAST_IO     0x00008000 /* Last insn may be an IO access.  */
-#define CF_MEMI_ONLY   0x00010000 /* Only instrument memory ops */
-#define CF_USE_ICOUNT  0x00020000
-#define CF_INVALID     0x00040000 /* TB is stale. Set with @jmp_lock held =
*/
-#define CF_PARALLEL    0x00080000 /* Generate code for a parallel context =
*/
-#define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */
+#define CF_COUNT_MASK    0x000001ff
+#define CF_NO_GOTO_TB    0x00000200 /* Do not chain with goto_tb */
+#define CF_NO_GOTO_PTR   0x00000400 /* Do not chain with goto_ptr */
+#define CF_LAST_IO       0x00008000 /* Last insn may be an IO access.  */
+#define CF_MEMI_ONLY     0x00010000 /* Only instrument memory ops */
+#define CF_USE_ICOUNT    0x00020000
+#define CF_INVALID       0x00040000 /* TB is stale. Set with @jmp_lock hel=
d */
+#define CF_PARALLEL      0x00080000 /* Generate code for a parallel contex=
t */
+#define CF_CLUSTER_MASK  0xff000000 /* Top 8 bits are cluster ID */
 #define CF_CLUSTER_SHIFT 24
=20
     /* Per-vCPU dynamic tracing state used to generate this TB */
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index ef4214d893..d3232d5764 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -147,7 +147,13 @@ static void init_delay_params(SyncClocks *sc, const CP=
UState *cpu)
=20
 uint32_t curr_cflags(CPUState *cpu)
 {
-    return cpu->tcg_cflags;
+    uint32_t cflags =3D cpu->tcg_cflags;
+
+    if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
+        cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR;
+    }
+
+    return cflags;
 }
=20
 /* Might cause an exception, so have a longjmp destination ready */
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 59804af37b..2ea5a74f30 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -33,6 +33,11 @@ void translator_loop_temp_check(DisasContextBase *db)
=20
 bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
 {
+    /* Suppress goto_tb if requested. */
+    if (tb_cflags(db->tb) & CF_NO_GOTO_TB) {
+        return false;
+    }
+
     /* Suppress goto_tb in the case of single-steping.  */
     if (db->singlestep_enabled || singlestep) {
         return false;
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 0c561fb253..e0d54d537f 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -2723,10 +2723,6 @@ void tcg_gen_exit_tb(const TranslationBlock *tb, uns=
igned idx)
            seen this numbered exit before, via tcg_gen_goto_tb.  */
         tcg_debug_assert(tcg_ctx->goto_tb_issue_mask & (1 << idx));
 #endif
-        /* When not chaining, exit without indicating a link.  */
-        if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
-            val =3D 0;
-        }
     } else {
         /* This is an exit via the exitreq label.  */
         tcg_debug_assert(idx =3D=3D TB_EXIT_REQUESTED);
@@ -2738,6 +2734,8 @@ void tcg_gen_exit_tb(const TranslationBlock *tb, unsi=
gned idx)
=20
 void tcg_gen_goto_tb(unsigned idx)
 {
+    /* We tested CF_NO_GOTO_TB in translator_use_goto_tb. */
+    tcg_debug_assert(!(tcg_ctx->tb_cflags & CF_NO_GOTO_TB));
     /* We only support two chained exits.  */
     tcg_debug_assert(idx <=3D TB_EXIT_IDXMAX);
 #ifdef CONFIG_DEBUG_TCG
@@ -2746,25 +2744,23 @@ void tcg_gen_goto_tb(unsigned idx)
     tcg_ctx->goto_tb_issue_mask |=3D 1 << idx;
 #endif
     plugin_gen_disable_mem_helpers();
-    /* When not chaining, we simply fall through to the "fallback" exit.  =
*/
-    if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
-        tcg_gen_op1i(INDEX_op_goto_tb, idx);
-    }
+    tcg_gen_op1i(INDEX_op_goto_tb, idx);
 }
=20
 void tcg_gen_lookup_and_goto_ptr(void)
 {
-    if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
-        TCGv_ptr ptr;
+    TCGv_ptr ptr;
=20
-        plugin_gen_disable_mem_helpers();
-        ptr =3D tcg_temp_new_ptr();
-        gen_helper_lookup_tb_ptr(ptr, cpu_env);
-        tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr));
-        tcg_temp_free_ptr(ptr);
-    } else {
+    if (tcg_ctx->tb_cflags & CF_NO_GOTO_PTR) {
         tcg_gen_exit_tb(NULL, 0);
+        return;
     }
+
+    plugin_gen_disable_mem_helpers();
+    ptr =3D tcg_temp_new_ptr();
+    gen_helper_lookup_tb_ptr(ptr, cpu_env);
+    tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr));
+    tcg_temp_free_ptr(ptr);
 }
=20
 static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104651401686.4435872725592;
 Mon, 12 Jul 2021 08:44:11 -0700 (PDT)
Received: from localhost ([::1]:43606 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y6M-0003If-CL
	for importer@patchew.org; Mon, 12 Jul 2021 11:44:10 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59856)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2d-0003zf-VD
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:23 -0400
Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:47076)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2S-0000uY-OG
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:16 -0400
Received: by mail-pj1-x1033.google.com with SMTP id
 b5-20020a17090a9905b029016fc06f6c5bso220303pjp.5
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:08 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:07 -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=QXN13A+EVZfIbPM/1TIJvsr4KsfxBAPJnkVnda2aJXw=;
 b=n+wppY5leLz4nK2f+4e4tKJFIwD+DcFF4kZ58g488gEEh8rScuvhwfpD4wMxQOHAg+
 LRVuCbYJvtunb0AgVA6wOTBSwIW3Pl5eFTfSUSgzVrTcGxqOc2eHfLpSEMElYK4g/5Ut
 F6L7SoTsb6j4sflRKtM4HzHShFEkZNFS9hkSAw4eiLTh5GkgxtaRPotkK4lxgyl6iGv7
 +JSS0awY16VjGfsU7rtWcgL8pBlR1Q39f9yO7ZGiwfLvPSKJHtNePe11MZzUUMDHJq+f
 0CcSAolZXTVKtgcqKVByzMoZ/JwCREiCFM5alCBaCPo6La3S46GwpLD7cgCwGdyZ5YGH
 1+4g==
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=QXN13A+EVZfIbPM/1TIJvsr4KsfxBAPJnkVnda2aJXw=;
 b=VifruAn8vefmY7PBPrECR+cSAdjxpt8JMf0XL5vtoYKF8xMovINwYIaMp6psxtyqzF
 /w9IU1gv3tdMsQTHJojrQ4omNSYbG9FVv2o8UdlCSWqYmRQUxrNE2IlNKjNLVKG8EGSK
 KTZYvuAqN974SicEFFTfhcoDbFLv7pfOoh+6YgN3XqCgYc/ife8DgZGupoRaHkqZ9JJC
 slL2Kv7oJlt4Cq4ord+drOR0xuLJ866JlN+QITNq7/Lk9gRPo/1B17sOjdRmJvbYsAfW
 SvTj4XKpMTuIk4JfvWh+62PJGJDP2af7apTU03zCAnfl4dDdZ3/myNtoao8301muwZxV
 dlpw==
X-Gm-Message-State: AOAM533nY5kt8RhojuGhklCeVH7URgw4C12iBJl7zxjbbnQQNjzS1kqy
 xHhyM/MVPGpnVFaMwkn3i3naj8bgcxeU8w==
X-Google-Smtp-Source: 
 ABdhPJxU89mwi2pP7PdV/+qNsMMXknXaDE/IDGOHzkVtNNwXgacbP1dopWbNpO0TLLQonKTNtM/PHg==
X-Received: by 2002:a17:90a:17ad:: with SMTP id
 q42mr14861669pja.181.1626104407370;
 Mon, 12 Jul 2021 08:40:07 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 04/10] accel/tcg: Drop CF_NO_GOTO_PTR from -d nochain
Date: Mon, 12 Jul 2021 08:39:58 -0700
Message-Id: <20210712154004.1410832-5-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::1033;
 envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com
X-Spam_score_int: -1
X-Spam_score: -0.2
X-Spam_bar: /
X-Spam_report: (-0.2 / 5.0 requ) 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104676041100001
Content-Type: text/plain; charset="utf-8"

The purpose of suppressing goto_ptr from -d nochain had been
to return to the main loop so that -d cpu would be recognized.
But we now include -d cpu logging in helper_lookup_tb_ptr so
there is no need to exclude goto_ptr.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 accel/tcg/cpu-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index d3232d5764..70ea3c7d68 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -150,7 +150,7 @@ uint32_t curr_cflags(CPUState *cpu)
     uint32_t cflags =3D cpu->tcg_cflags;
=20
     if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
-        cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR;
+        cflags |=3D CF_NO_GOTO_TB;
     }
=20
     return cflags;
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104556290936.1385116464262;
 Mon, 12 Jul 2021 08:42:36 -0700 (PDT)
Received: from localhost ([::1]:36224 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y4p-0006tO-8I
	for importer@patchew.org; Mon, 12 Jul 2021 11:42:35 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59852)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2c-0003ze-3Q
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:21 -0400
Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:44842)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2U-0000v3-MQ
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:14 -0400
Received: by mail-pj1-x102b.google.com with SMTP id
 p4-20020a17090a9304b029016f3020d867so226416pjo.3
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:08 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.07
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:07 -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=aJUMslg4EAxSiYS9zA1U7hEkodGULeANuLs91s86cRg=;
 b=d/+oLDVTeNIirW6asf3jP7Xxzanwb7rHfjtheWoqnNFbNCWLohCEx68oAJJnYQLAfD
 JjiudqrtjkProhmLDgwN6Z5/sNSEoCmG3DD7cDc5fIRPlwJoQxi1l5sXaHPqqjPEhboQ
 iOzKj5Igyez22zcVGsKiC5Fl1wYbKzRBvNU327Ad5SMkPwm3KFWc6dPiN8BKwCFPEtcD
 LTRiRqBseTB97t/KW/mpVEBtTm9QDhx6mv9Sbxluz8vhHNCdHZz4RVNhAdFa7d7aLxod
 YIH/kmT9M5vEveRSSiiLITYJIxNjJvCiyPri11WykHNTvcCWkZ4MI6JPgWhb3OhWezdT
 zjhQ==
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=aJUMslg4EAxSiYS9zA1U7hEkodGULeANuLs91s86cRg=;
 b=j07OwgDGrXv5JB68ODoqHQacsDtH1LIvXRo0mr4hu2Ae3JUsa/t2UQnnDCBUH6VzaJ
 JHJtKBfJPl46DcYPi1G/dOKXDbKS6AB0B9Dg2ea5JDELX50OU0/NtVLjuDjFZQPbyNcB
 E6QF9XOslS1RQJh0kAijVepCFzFD6Dao/Zvuyzm+FXPTlNeN9kEIca8356MSWmUVQOro
 9Uwl+TtRaInvakNeCkb+fM9tb2A//TSOw29x+eVmEGi9UxCazmc+nQgTFFG4rgsojxUf
 MzMiwub8PoWLS5tgYdUQ8zeneQtlJ91GSvkgG3TR6r/6InSkmo3g0HfcjEIxwvO3ptp9
 Qwdg==
X-Gm-Message-State: AOAM530ky8gnMGsATkh9DpX92haFtzTN9K8mEJmX8G11ii60uRRpNy4V
 ofal3wKzjZxt6JrGEWnhrPXA4CdIl3mlBA==
X-Google-Smtp-Source: 
 ABdhPJz1ric2mj46jRlMcO+Na5K97Q9TCfTktfESSAnr6lM1kcOr4+s8wedjyfiz0f1jjFs2+3E2tg==
X-Received: by 2002:a17:90a:8912:: with SMTP id
 u18mr24154112pjn.90.1626104407967;
 Mon, 12 Jul 2021 08:40:07 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 05/10] accel/tcg: Handle -singlestep in curr_cflags
Date: Mon, 12 Jul 2021 08:39:59 -0700
Message-Id: <20210712154004.1410832-6-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::102b;
 envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104633454100007
Content-Type: text/plain; charset="utf-8"

Exchange the test in translator_use_goto_tb for CF_NO_GOTO_TB,
and the test in tb_gen_code for setting CF_COUNT_MASK to 1.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 accel/tcg/cpu-exec.c      | 8 +++++++-
 accel/tcg/translate-all.c | 2 +-
 accel/tcg/translator.c    | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 70ea3c7d68..2206c463f5 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -149,7 +149,13 @@ uint32_t curr_cflags(CPUState *cpu)
 {
     uint32_t cflags =3D cpu->tcg_cflags;
=20
-    if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
+    /*
+     * For singlestep and -d nochain, suppress goto_tb so that
+     * we can log -d cpu,exec after every TB.
+     */
+    if (singlestep) {
+        cflags |=3D CF_NO_GOTO_TB | 1;
+    } else if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
         cflags |=3D CF_NO_GOTO_TB;
     }
=20
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 997e44c73b..491c1a56b2 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1432,7 +1432,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
     }
     QEMU_BUILD_BUG_ON(CF_COUNT_MASK + 1 !=3D TCG_MAX_INSNS);
=20
-    if (cpu->singlestep_enabled || singlestep) {
+    if (cpu->singlestep_enabled) {
         max_insns =3D 1;
     }
=20
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 2ea5a74f30..a59eb7c11b 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -39,7 +39,7 @@ bool translator_use_goto_tb(DisasContextBase *db, target_=
ulong dest)
     }
=20
     /* Suppress goto_tb in the case of single-steping.  */
-    if (db->singlestep_enabled || singlestep) {
+    if (db->singlestep_enabled) {
         return false;
     }
=20
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104771566926.6841937986051;
 Mon, 12 Jul 2021 08:46:11 -0700 (PDT)
Received: from localhost ([::1]:50260 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y8I-0007n9-Fj
	for importer@patchew.org; Mon, 12 Jul 2021 11:46:10 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59882)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2h-0003zj-Mh
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:24 -0400
Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:38855)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2V-0000vB-0c
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:19 -0400
Received: by mail-pj1-x102a.google.com with SMTP id
 me13-20020a17090b17cdb0290173bac8b9c9so2450189pjb.3
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:09 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:08 -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=aZodwPrqQjUt8vQ3rujRtm0PKCZdI4rcPhp5DEtvTCc=;
 b=LfdovceokOsOtRtP4Q0rw0GoW5OJXAhkoOS/0RHQj1yIuTX0RidxI0NirnLryYNtL2
 hPvVbXbQI77hBiZW9FyDMgytDwVQIo3C/E6o4QkrgOYbgQcpxp17zIVnYref4h07jJxv
 /bDXO3yox1j1UxSQ/FBuVI8VM3dwPW6xJ8DDndiulttjEAb93mmJxJsR5/lGcAIMgEqi
 uORkw1HiAXy/8lcRIk1FNzo1Uhikx8aVJ0xwBKREhoHwkkL4sxlZGwjNX0K68stWqQOq
 6QwedpLgTSpMSIIpz/RAY35nCGDt53PKJeGF5+PT6yRVU1t+i+LQ7ScZZKKeH81STMZD
 hEAw==
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=aZodwPrqQjUt8vQ3rujRtm0PKCZdI4rcPhp5DEtvTCc=;
 b=U5HFzaBfDC8UylRsREBMyE/ZzSYgiZVxKWCx6sAXWsNpr6xB5Xo6y/Kaetp6+UBG/+
 6lD4WdMN+L3uP728gteRr8HwuVnAf8fyS4gxie7s914VLzrIwocQTNCryQuh7kl10b0Z
 Fu1aukTJC46axrJenM8ulMlHHUPiy1xWL+ZSC5srGkNrDdiqev1zKGJdZhuJy0fCWQ5w
 XRETaXv9IVXs6YZRlICKofKO6YQapskziWQsBiQuDoihimMJQOrtAr4HduAHa7k8fm/9
 BRsvllQkf3eOOv21NiLZi3W1HFPy21sSnL7Ipw3IMSfFs0D4PY6xkjNflWm0F2c21s7W
 kNfg==
X-Gm-Message-State: AOAM5311hQWyk0CjXxQdbT3+ZAOAizCK0SxuPhu8vYVv1TXIft/DfN6N
 OxCFAKFBSknrnu1vJHN7Dq9RrMZsHjft9g==
X-Google-Smtp-Source: 
 ABdhPJyLKQB3nWRFqQ7hvqIvAqKtTqFRQiBw+EMe0rppJ+7Q13F5K5sp2N96wXpC0jYI36o0kcvu6g==
X-Received: by 2002:a17:90a:a60f:: with SMTP id
 c15mr52640766pjq.187.1626104408642;
 Mon, 12 Jul 2021 08:40:08 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 06/10] accel/tcg: Use CF_NO_GOTO_{TB,
 PTR} in cpu_exec_step_atomic
Date: Mon, 12 Jul 2021 08:40:00 -0700
Message-Id: <20210712154004.1410832-7-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::102a;
 envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com
X-Spam_score_int: -1
X-Spam_score: -0.2
X-Spam_bar: /
X-Spam_report: (-0.2 / 5.0 requ) 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104773102100001
Content-Type: text/plain; charset="utf-8"

Request that the one TB returns immediately, so that
we release the exclusive lock as soon as possible.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 accel/tcg/cpu-exec.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 2206c463f5..5bb099174f 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -330,8 +330,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
     CPUArchState *env =3D (CPUArchState *)cpu->env_ptr;
     TranslationBlock *tb;
     target_ulong cs_base, pc;
-    uint32_t flags;
-    uint32_t cflags =3D (curr_cflags(cpu) & ~CF_PARALLEL) | 1;
+    uint32_t flags, cflags;
     int tb_exit;
=20
     if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) {
@@ -341,8 +340,14 @@ void cpu_exec_step_atomic(CPUState *cpu)
         cpu->running =3D true;
=20
         cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
-        tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
=20
+        cflags =3D curr_cflags(cpu);
+        /* Execute in a serial context. */
+        cflags &=3D ~CF_PARALLEL;
+        /* After 1 insn, return and release the exclusive lock. */
+        cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | 1;
+
+        tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
         if (tb =3D=3D NULL) {
             mmap_lock();
             tb =3D tb_gen_code(cpu, pc, cs_base, flags, cflags);
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104551218663.0801427155892;
 Mon, 12 Jul 2021 08:42:31 -0700 (PDT)
Received: from localhost ([::1]:36054 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y4j-0006mY-Nk
	for importer@patchew.org; Mon, 12 Jul 2021 11:42:29 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59860)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2d-0003zg-Ve
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:23 -0400
Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:39567)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2V-0000vi-0l
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:14 -0400
Received: by mail-pl1-x62b.google.com with SMTP id h1so9405944plf.6
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:10 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:09 -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=XZ18+TbN3l0IvM4lcz8To1nUnlGMGwhY3IWR1y85/oQ=;
 b=gI6xTTdnbo+dVvl890e3D1fB75Er7s3Y9ef+qEIB1HhVEAfhMqqIKNmOC051ZQ7kDh
 YYraKEY6edBRoF8atXLg42hzlFsOmLMhJiFeMbuVLzQ+rfcK/kCObuuhaH6t5nxuV5+Z
 VOjjp5X3iAqHPwNOge2CJL88BIMbmIrGCt0E+PTKmWLRcbAX8mgvq065U7l1v7QhhOqE
 5NFES8AyXAiw+gtyPic4Baozvl0JsJJtb9xh6BQts1lenfU5uzf6q+/ulo25RKXgIcuK
 6o1PAfg9w286WMF7WZGRCrZV6d/W66WU1cUXqoh+PNwXfCN+FN04wQYGMLHKcbuJgtue
 mE8A==
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=XZ18+TbN3l0IvM4lcz8To1nUnlGMGwhY3IWR1y85/oQ=;
 b=uQjOGo6qw566X2fO+2LGG+/Zvi96A1akMMNkLfwjanRW2SUDZrcfHxplGj4zbtoXDf
 DQOMl8KA4XtIslU/pDnwm+jB1bdpV8d5EHwYvnTxjGwkskH6pDpmxA3tAzTMnSB8lQnh
 S2sAQjtYHm2dK3adV5+9uaARFlcnn5N4lrAJDFwhfrzJrhOa8UXT8VII/k7hTkeCYiwj
 Ovf7NKfyHRdYBEK8/bVtuhfoC6fZkrzXtRhyl5N18rVhUsDYQDyoTcta2V9tvmcGDq/b
 lDNXJr28gS9Rrq16gekyWrp9fX1UIc7qDS+OXx6aLETAfHcIg/PTNc5Df+It9X2oZXDM
 eLbQ==
X-Gm-Message-State: AOAM5301ZG/OyukaonJyQwdUTlacFCJMBibOx7rDP1myCKGdBbLCPZwC
 v7SDIY0jtmqIkntY7AQq1SsAuhs4tzvIMA==
X-Google-Smtp-Source: 
 ABdhPJzlIwcESTdLMrsDegvt1h+A9OxIaBabWXg6U+HehjhOskaH96U3a4sO9frHxiG9qrUqDhsyvA==
X-Received: by 2002:a17:90a:bd94:: with SMTP id
 z20mr10211718pjr.214.1626104409474;
 Mon, 12 Jul 2021 08:40:09 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 07/10] accel/tcg: Move cflags lookup into tb_find
Date: Mon, 12 Jul 2021 08:40:01 -0700
Message-Id: <20210712154004.1410832-8-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::62b;
 envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104630712100001
Content-Type: text/plain; charset="utf-8"

We will shortly require the guest pc for computing cflags,
so move the choice just after cpu_get_tb_cpu_state.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 accel/tcg/cpu-exec.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 5bb099174f..4d043a11aa 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -502,15 +502,29 @@ static inline void tb_add_jump(TranslationBlock *tb, =
int n,
=20
 static inline TranslationBlock *tb_find(CPUState *cpu,
                                         TranslationBlock *last_tb,
-                                        int tb_exit, uint32_t cflags)
+                                        int tb_exit)
 {
     CPUArchState *env =3D (CPUArchState *)cpu->env_ptr;
     TranslationBlock *tb;
     target_ulong cs_base, pc;
-    uint32_t flags;
+    uint32_t flags, cflags;
=20
     cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
=20
+    /*
+     * When requested, use an exact setting for cflags for the next
+     * execution.  This is used for icount, precise smc, and stop-
+     * after-access watchpoints.  Since this request should never
+     * have CF_INVALID set, -1 is a convenient invalid value that
+     * does not require tcg headers for cpu_common_reset.
+     */
+    cflags =3D cpu->cflags_next_tb;
+    if (cflags =3D=3D -1) {
+        cflags =3D curr_cflags(cpu);
+    } else {
+        cpu->cflags_next_tb =3D -1;
+    }
+
     tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
     if (tb =3D=3D NULL) {
         mmap_lock();
@@ -868,21 +882,7 @@ int cpu_exec(CPUState *cpu)
         int tb_exit =3D 0;
=20
         while (!cpu_handle_interrupt(cpu, &last_tb)) {
-            uint32_t cflags =3D cpu->cflags_next_tb;
-            TranslationBlock *tb;
-
-            /* When requested, use an exact setting for cflags for the next
-               execution.  This is used for icount, precise smc, and stop-
-               after-access watchpoints.  Since this request should never
-               have CF_INVALID set, -1 is a convenient invalid value that
-               does not require tcg headers for cpu_common_reset.  */
-            if (cflags =3D=3D -1) {
-                cflags =3D curr_cflags(cpu);
-            } else {
-                cpu->cflags_next_tb =3D -1;
-            }
-
-            tb =3D tb_find(cpu, last_tb, tb_exit, cflags);
+            TranslationBlock *tb =3D tb_find(cpu, last_tb, tb_exit);
             cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit);
             /* Try to align the host and virtual clocks
                if the guest is in advance */
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 16261048715161023.2598538106131;
 Mon, 12 Jul 2021 08:47:51 -0700 (PDT)
Received: from localhost ([::1]:55210 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y9u-0002sW-78
	for importer@patchew.org; Mon, 12 Jul 2021 11:47:50 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59922)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2k-00040y-CP
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:26 -0400
Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:36839)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2W-0000w8-GQ
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:24 -0400
Received: by mail-pf1-x430.google.com with SMTP id 21so16770357pfp.3
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:11 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:09 -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=QOTuvyksQiIBkfzm4LrHsE59VKvyyyzWoWOeiH690Tg=;
 b=JgOg6q6nLAWkFr96IA75KuT2gG5NpCoULoUx0jDmqbY3iwoJiD2CSnLLFXdvUu6Pji
 9i1EAZMnMw+MWmq08EztzWRIr/VtMlvwZNNKIWOHcG6YbHM47PMo5m41W70whIDb0Vb7
 wmEzCpcn8X8S+vnTMiYjFCDNzCWdIXvkFW2oOckz7+tCEEym4i8YkeBAay96zc3bpSMW
 ExshdBNY6I5fbNj0Js4Y1M73mW8pFxpR64xjz7wiON0LuKyujzQmgpziPysYLqLZ7KBr
 dAGq6VbbwUPGWFEo60OuFVnkPSjnPAf38oQKWhG5gCkH4j11AT7PMR9ebr+PwokOtjzD
 DbBg==
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=QOTuvyksQiIBkfzm4LrHsE59VKvyyyzWoWOeiH690Tg=;
 b=W00gdrtfmZY9hnIGbAm6/1wEhMpIc2vXgyerAkkPbAiwJzp67nv7RiXViAaS1HZnqf
 zdzvmtsf7VLMyooFz+FrO7PHFgrxK9XElycu9ggM8FEFHmBh9vY12o8SLSy5QCXbj5Se
 rDYjwZaJNpgRzy2CcFvHEqpaEyjWXggJ8HWXmJT7WoChHFWnShQJUAld4ENUC9A3FOi6
 2PIIZyV+GeMM2aR4tbwGHkR8JgfxRVVixErJvgtWkZtMbp5pIkzZylcHScHfjdhSF1TL
 v/M6dJCJfNwtB2rg5Y2ZrtGulQjrhHw2Phk54fgkuMGQmxA/XLyjJa8GOeQ4r7dQ7AN5
 O3oA==
X-Gm-Message-State: AOAM530yIE6+EblEvBM+NnSYfROMBK3gC6D+T0FYcvqUiDpKLK8Y4yms
 O58KnWZnpHsPY3kTWVv2ZExyvC6lNBr8JA==
X-Google-Smtp-Source: 
 ABdhPJykqphRpzdgosg0NMhD8aOj+lsJIVpJU2V0CWRv9Adgu51s0fLbkjMN9/ISZ3hUYpYjrkQ5XA==
X-Received: by 2002:a65:6191:: with SMTP id c17mr1012759pgv.153.1626104410141;
 Mon, 12 Jul 2021 08:40:10 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 08/10] accel/tcg: Adjust interface of
 TranslatorOps.breakpoint_check
Date: Mon, 12 Jul 2021 08:40:02 -0700
Message-Id: <20210712154004.1410832-9-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::430;
 envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104873419100001
Content-Type: text/plain; charset="utf-8"

We don't need the whole CPUBreakpoint structure in the check,
only the flags.  Return the instruction length to consolidate
the adjustment of db->pc_next.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/exec/translator.h     | 17 +++++++++------
 accel/tcg/translator.c        | 40 ++++++++++++++++++++++++-----------
 target/alpha/translate.c      | 12 +++--------
 target/arm/translate-a64.c    | 14 ++++--------
 target/arm/translate.c        | 20 +++++++-----------
 target/avr/translate.c        |  6 +++---
 target/cris/translate.c       | 14 ++++--------
 target/hexagon/translate.c    | 13 +++---------
 target/hppa/translate.c       |  7 +++---
 target/i386/tcg/translate.c   | 15 ++++---------
 target/m68k/translate.c       | 14 +++---------
 target/microblaze/translate.c | 14 +++---------
 target/mips/tcg/translate.c   | 14 ++++--------
 target/nios2/translate.c      | 13 +++---------
 target/openrisc/translate.c   | 11 +++-------
 target/ppc/translate.c        | 13 +++---------
 target/riscv/translate.c      | 11 +++-------
 target/rx/translate.c         |  8 +++----
 target/s390x/translate.c      | 12 ++++-------
 target/sh4/translate.c        | 12 ++++-------
 target/sparc/translate.c      |  9 ++++----
 target/tricore/translate.c    | 13 +++---------
 target/xtensa/translate.c     | 12 ++++-------
 23 files changed, 115 insertions(+), 199 deletions(-)

diff --git a/include/exec/translator.h b/include/exec/translator.h
index dd9c06d40d..433b753c5c 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -92,11 +92,15 @@ typedef struct DisasContextBase {
  * @breakpoint_check:
  *      When called, the breakpoint has already been checked to match the =
PC,
  *      but the target may decide the breakpoint missed the address
- *      (e.g., due to conditions encoded in their flags).  Return true to
- *      indicate that the breakpoint did hit, in which case no more breakp=
oints
- *      are checked.  If the breakpoint did hit, emit any code required to
- *      signal the exception, and set db->is_jmp as necessary to terminate
- *      the main loop.
+ *      (e.g., due to conditions encoded in their flags), in which case
+ *      db->is_jmp may be left as DISAS_NEXT or DISAS_TOO_MANY to indicate
+ *      that the insn should be translated.  Anything other than those two
+ *      will be taken to indicate an exception has been raised, but in most
+ *      cases db->is_jmp should be set to DISAS_NORETURN.
+ *
+ *      Return the minimum instruction size that should be applied to the =
TB.
+ *      The size of any TB cannot be zero, as that breaks the math used to
+ *      invalidate TBs.
  *
  * @translate_insn:
  *      Disassemble one instruction and set db->pc_next for the start
@@ -113,8 +117,7 @@ typedef struct TranslatorOps {
     void (*init_disas_context)(DisasContextBase *db, CPUState *cpu);
     void (*tb_start)(DisasContextBase *db, CPUState *cpu);
     void (*insn_start)(DisasContextBase *db, CPUState *cpu);
-    bool (*breakpoint_check)(DisasContextBase *db, CPUState *cpu,
-                             const CPUBreakpoint *bp);
+    int (*breakpoint_check)(DisasContextBase *db, CPUState *cpu, int flags=
);
     void (*translate_insn)(DisasContextBase *db, CPUState *cpu);
     void (*tb_stop)(DisasContextBase *db, CPUState *cpu);
     void (*disas_log)(const DisasContextBase *db, CPUState *cpu);
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index a59eb7c11b..1c44d096d8 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -50,7 +50,6 @@ bool translator_use_goto_tb(DisasContextBase *db, target_=
ulong dest)
 void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
                      CPUState *cpu, TranslationBlock *tb, int max_insns)
 {
-    int bp_insn =3D 0;
     bool plugin_enabled;
=20
     /* Initialize DisasContext */
@@ -91,19 +90,35 @@ void translator_loop(const TranslatorOps *ops, DisasCon=
textBase *db,
             CPUBreakpoint *bp;
             QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
                 if (bp->pc =3D=3D db->pc_next) {
-                    if (ops->breakpoint_check(db, cpu, bp)) {
-                        bp_insn =3D 1;
-                        break;
+                    int len =3D ops->breakpoint_check(db, cpu, bp->flags);
+
+                    /*
+                     * The breakpoint_check hook may use DISAS_TOO_MANY
+                     * to indicate that only one more instruction is to
+                     * be executed.  Otherwise it should use DISAS_NORETURN
+                     * when generating an exception, but may use a
+                     * DISAS_TARGET_* value for Something Else.
+                     */
+                    if (db->is_jmp > DISAS_TOO_MANY) {
+                        /*
+                         * The address covered by the breakpoint must be
+                         * included in [tb->pc, tb->pc + tb->size) in order
+                         * to for it to be properly cleared.  Thus we
+                         * increment the PC here so that the logic setting
+                         * tb->size below does the right thing.
+                         */
+                        tcg_debug_assert(len > 0);
+                        db->pc_next +=3D len;
+
+                        /*
+                         * The breakpoint definitely hit, so decrement the
+                         * number of instructions completed for icount.
+                         */
+                        db->num_insns--;
+                        goto done;
                     }
                 }
             }
-            /* The breakpoint_check hook may use DISAS_TOO_MANY to indicate
-               that only one more instruction is to be executed.  Otherwise
-               it should use DISAS_NORETURN when generating an exception,
-               but may use a DISAS_TARGET_* value for Something Else.  */
-            if (db->is_jmp > DISAS_TOO_MANY) {
-                break;
-            }
         }
=20
         /* Disassemble one instruction.  The translate_insn hook should
@@ -142,9 +157,10 @@ void translator_loop(const TranslatorOps *ops, DisasCo=
ntextBase *db,
         }
     }
=20
+ done:
     /* Emit code to exit the TB, as indicated by db->is_jmp.  */
     ops->tb_stop(db, cpu);
-    gen_tb_end(db->tb, db->num_insns - bp_insn);
+    gen_tb_end(db->tb, db->num_insns);
=20
     if (plugin_enabled) {
         plugin_gen_tb_end(cpu);
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
index 833d3baa7b..07d0197cfb 100644
--- a/target/alpha/translate.c
+++ b/target/alpha/translate.c
@@ -3012,19 +3012,13 @@ static void alpha_tr_insn_start(DisasContextBase *d=
cbase, CPUState *cpu)
     tcg_gen_insn_start(dcbase->pc_next);
 }
=20
-static bool alpha_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cpu,
-                                      const CPUBreakpoint *bp)
+static int alpha_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
pu,
+                                     int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     ctx->base.is_jmp =3D gen_excp(ctx, EXCP_DEBUG, 0);
-
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size below does the right thing.  */
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cp=
u)
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index ca11a5fecd..4efd4e95d6 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -14844,28 +14844,22 @@ static void aarch64_tr_insn_start(DisasContextBas=
e *dcbase, CPUState *cpu)
     dc->insn_start =3D tcg_last_op();
 }
=20
-static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState=
 *cpu,
-                                        const CPUBreakpoint *bp)
+static int aarch64_tr_breakpoint_check(DisasContextBase *dcbase,
+                                       CPUState *cpu, int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
-    if (bp->flags & BP_CPU) {
+    if (bp_flags & BP_CPU) {
         gen_a64_set_pc_im(dc->base.pc_next);
         gen_helper_check_breakpoints(cpu_env);
         /* End the TB early; it likely won't be executed */
         dc->base.is_jmp =3D DISAS_TOO_MANY;
     } else {
         gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG);
-        /* The address covered by the breakpoint must be
-           included in [tb->pc, tb->pc + tb->size) in order
-           to for it to be properly cleared -- thus we
-           increment the PC here so that the logic setting
-           tb->size below does the right thing.  */
-        dc->base.pc_next +=3D 4;
         dc->base.is_jmp =3D DISAS_NORETURN;
     }
=20
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *=
cpu)
diff --git a/target/arm/translate.c b/target/arm/translate.c
index e1a8152598..ebac31c3ac 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -9438,12 +9438,12 @@ static void arm_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cpu)
     dc->insn_start =3D tcg_last_op();
 }
=20
-static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cp=
u,
-                                    const CPUBreakpoint *bp)
+static int arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
+                                   int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
-    if (bp->flags & BP_CPU) {
+    if (bp_flags & BP_CPU) {
         gen_set_condexec(dc);
         gen_set_pc_im(dc, dc->base.pc_next);
         gen_helper_check_breakpoints(cpu_env);
@@ -9451,18 +9451,14 @@ static bool arm_tr_breakpoint_check(DisasContextBas=
e *dcbase, CPUState *cpu,
         dc->base.is_jmp =3D DISAS_TOO_MANY;
     } else {
         gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG);
-        /* The address covered by the breakpoint must be
-           included in [tb->pc, tb->pc + tb->size) in order
-           to for it to be properly cleared -- thus we
-           increment the PC here so that the logic setting
-           tb->size below does the right thing.  */
-        /* TODO: Advance PC by correct instruction length to
-         * avoid disassembler error messages */
-        dc->base.pc_next +=3D 2;
         dc->base.is_jmp =3D DISAS_NORETURN;
     }
=20
-    return true;
+    /*
+     * TODO: Advance PC by correct instruction length to avoid disassembler
+     * error messages.  In the meantime, minimum instruction length.
+     */
+    return 2;
 }
=20
 static bool arm_pre_translate_insn(DisasContext *dc)
diff --git a/target/avr/translate.c b/target/avr/translate.c
index 8237a03c23..73ff467926 100644
--- a/target/avr/translate.c
+++ b/target/avr/translate.c
@@ -2944,13 +2944,13 @@ static void avr_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cs)
     tcg_gen_insn_start(ctx->npc);
 }
=20
-static bool avr_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
-                                    const CPUBreakpoint *bp)
+static int avr_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                   int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     gen_breakpoint(ctx);
-    return true;
+    return 2; /* minimum instruction length */
 }
=20
 static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/cris/translate.c b/target/cris/translate.c
index 9258c13e9f..b590e79433 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -3118,8 +3118,8 @@ static void cris_tr_insn_start(DisasContextBase *dcba=
se, CPUState *cpu)
     tcg_gen_insn_start(dc->delayed_branch =3D=3D 1 ? dc->ppc | 1 : dc->pc);
 }
=20
-static bool cris_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
pu,
-                                     const CPUBreakpoint *bp)
+static int cris_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cp=
u,
+                                    int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
@@ -3127,14 +3127,8 @@ static bool cris_tr_breakpoint_check(DisasContextBas=
e *dcbase, CPUState *cpu,
     tcg_gen_movi_tl(env_pc, dc->pc);
     t_gen_raise_exception(EXCP_DEBUG);
     dc->base.is_jmp =3D DISAS_NORETURN;
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    dc->pc +=3D 2;
-    return true;
+
+    return 2; /* minimum instruction length */
 }
=20
 static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index b23d36adf5..75c0d40a13 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -540,20 +540,13 @@ static void hexagon_tr_insn_start(DisasContextBase *d=
cbase, CPUState *cpu)
     tcg_gen_insn_start(ctx->base.pc_next);
 }
=20
-static bool hexagon_tr_breakpoint_check(DisasContextBase *dcbase, CPUState=
 *cpu,
-                                        const CPUBreakpoint *bp)
+static int hexagon_tr_breakpoint_check(DisasContextBase *dcbase,
+                                       CPUState *cpu, int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     gen_exception_end_tb(ctx, EXCP_DEBUG);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum packet length */
 }
=20
 static bool pkt_crosses_page(CPUHexagonState *env, DisasContext *ctx)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 835120c038..407136f26b 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -4204,14 +4204,13 @@ static void hppa_tr_insn_start(DisasContextBase *dc=
base, CPUState *cs)
     tcg_gen_insn_start(ctx->iaoq_f, ctx->iaoq_b);
 }
=20
-static bool hppa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
s,
-                                      const CPUBreakpoint *bp)
+static int hppa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                    int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     gen_excp(ctx, EXCP_DEBUG);
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 3814ce2a3e..bf5a393b9b 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -8583,23 +8583,16 @@ static void i386_tr_insn_start(DisasContextBase *dc=
base, CPUState *cpu)
     tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
 }
=20
-static bool i386_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
pu,
-                                     const CPUBreakpoint *bp)
+static int i386_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cp=
u,
+                                    int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
     /* If RF is set, suppress an internally generated breakpoint.  */
     int flags =3D dc->base.tb->flags & HF_RF_MASK ? BP_GDB : BP_ANY;
-    if (bp->flags & flags) {
+    if (bp_flags & flags) {
         gen_debug(dc);
-        /* The address covered by the breakpoint must be included in
-           [tb->pc, tb->pc + tb->size) in order to for it to be
-           properly cleared -- thus we increment the PC here so that
-           the generic logic setting tb->size later does the right thing. =
 */
-        dc->base.pc_next +=3D 1;
-        return true;
-    } else {
-        return false;
     }
+    return 1; /* minimum instruction length */
 }
=20
 static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 1fee04b8dd..79c1847d54 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -6208,21 +6208,13 @@ static void m68k_tr_insn_start(DisasContextBase *dc=
base, CPUState *cpu)
     tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
 }
=20
-static bool m68k_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
pu,
-                                     const CPUBreakpoint *bp)
+static int m68k_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cp=
u,
+                                    int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
     gen_exception(dc, dc->base.pc_next, EXCP_DEBUG);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    dc->base.pc_next +=3D 2;
-
-    return true;
+    return 2; /* minimum instruction length */
 }
=20
 static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index c68a84a219..09a364cceb 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -1673,21 +1673,13 @@ static void mb_tr_insn_start(DisasContextBase *dcb,=
 CPUState *cs)
     dc->insn_start =3D tcg_last_op();
 }
=20
-static bool mb_tr_breakpoint_check(DisasContextBase *dcb, CPUState *cs,
-                                   const CPUBreakpoint *bp)
+static int mb_tr_breakpoint_check(DisasContextBase *dcb, CPUState *cs,
+                                  int bp_flags)
 {
     DisasContext *dc =3D container_of(dcb, DisasContext, base);
=20
     gen_raise_exception_sync(dc, EXCP_DEBUG);
-
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    dc->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs)
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 47c967acbf..c7b9d813c2 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -16190,22 +16190,16 @@ static void mips_tr_insn_start(DisasContextBase *=
dcbase, CPUState *cs)
                        ctx->btarget);
 }
=20
-static bool mips_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
s,
-                                     const CPUBreakpoint *bp)
+static int mips_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                    int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     save_cpu_state(ctx, 1);
     ctx->base.is_jmp =3D DISAS_NORETURN;
     gen_helper_raise_exception_debug(cpu_env);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    ctx->base.pc_next +=3D 4;
-    return true;
+
+    return 2; /* minimum instruction length */
 }
=20
 static void mips_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 17742cebc7..1d1c66b88f 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -777,20 +777,13 @@ static void nios2_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cs)
     tcg_gen_insn_start(dcbase->pc_next);
 }
=20
-static bool nios2_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cs,
-                                      const CPUBreakpoint *bp)
+static int nios2_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
s,
+                                     int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
     gen_exception(dc, EXCP_DEBUG);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    dc->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
index 37c3e3e0a3..adcf71645b 100644
--- a/target/openrisc/translate.c
+++ b/target/openrisc/translate.c
@@ -1639,20 +1639,15 @@ static void openrisc_tr_insn_start(DisasContextBase=
 *dcbase, CPUState *cs)
                        | (dc->base.num_insns > 1 ? 2 : 0));
 }
=20
-static bool openrisc_tr_breakpoint_check(DisasContextBase *dcbase, CPUStat=
e *cs,
-                                         const CPUBreakpoint *bp)
+static int openrisc_tr_breakpoint_check(DisasContextBase *dcbase,
+                                        CPUState *cs, int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
     tcg_gen_movi_tl(cpu_pc, dc->base.pc_next);
     gen_exception(dc, EXCP_DEBUG);
     dc->base.is_jmp =3D DISAS_NORETURN;
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size below does the right thing.  */
-    dc->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static void openrisc_tr_translate_insn(DisasContextBase *dcbase, CPUState =
*cs)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 0a55cb7181..5093be0694 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -8565,21 +8565,14 @@ static void ppc_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cs)
     tcg_gen_insn_start(dcbase->pc_next);
 }
=20
-static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
-                                    const CPUBreakpoint *bp)
+static int ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                   int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     gen_update_nip(ctx, ctx->base.pc_next);
     gen_debug_exception(ctx);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be properly
-     * cleared -- thus we increment the PC here so that the logic
-     * setting tb->size below does the right thing.
-     */
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static bool is_prefix_insn(DisasContext *ctx, uint32_t insn)
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index deda0c8a44..8a6bc58572 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -961,20 +961,15 @@ static void riscv_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cpu)
     tcg_gen_insn_start(ctx->base.pc_next);
 }
=20
-static bool riscv_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cpu,
-                                      const CPUBreakpoint *bp)
+static int riscv_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
pu,
+                                     int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
     tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next);
     ctx->base.is_jmp =3D DISAS_NORETURN;
     gen_exception_debug();
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size below does the right thing.  */
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 2; /* minimum instruction length */
 }
=20
 static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cp=
u)
diff --git a/target/rx/translate.c b/target/rx/translate.c
index 23a626438a..5e9950f3ac 100644
--- a/target/rx/translate.c
+++ b/target/rx/translate.c
@@ -2309,8 +2309,8 @@ static void rx_tr_insn_start(DisasContextBase *dcbase=
, CPUState *cs)
     tcg_gen_insn_start(ctx->base.pc_next);
 }
=20
-static bool rx_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
-                                    const CPUBreakpoint *bp)
+static int rx_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                  int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
@@ -2318,8 +2318,8 @@ static bool rx_tr_breakpoint_check(DisasContextBase *=
dcbase, CPUState *cs,
     tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next);
     gen_helper_debug(cpu_env);
     ctx->base.is_jmp =3D DISAS_NORETURN;
-    ctx->base.pc_next +=3D 1;
-    return true;
+
+    return 1; /* minimum instruction length */
 }
=20
 static void rx_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index c8d55d1f83..06f8fa96a6 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -6567,8 +6567,8 @@ static void s390x_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cs)
 {
 }
=20
-static bool s390x_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cs,
-                                      const CPUBreakpoint *bp)
+static int s390x_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
s,
+                                     int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
@@ -6582,12 +6582,8 @@ static bool s390x_tr_breakpoint_check(DisasContextBa=
se *dcbase, CPUState *cs,
=20
     dc->base.is_jmp =3D DISAS_PC_STALE;
     dc->do_debug =3D true;
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size does the right thing.  */
-    dc->base.pc_next +=3D 2;
-    return true;
+
+    return 2; /* minimum instruction length */
 }
=20
 static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 40898e2393..b1e19bf976 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -2289,8 +2289,8 @@ static void sh4_tr_insn_start(DisasContextBase *dcbas=
e, CPUState *cs)
     tcg_gen_insn_start(ctx->base.pc_next, ctx->envflags);
 }
=20
-static bool sh4_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
-                                    const CPUBreakpoint *bp)
+static int sh4_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
+                                   int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
=20
@@ -2298,12 +2298,8 @@ static bool sh4_tr_breakpoint_check(DisasContextBase=
 *dcbase, CPUState *cs,
     gen_save_cpu_state(ctx, true);
     gen_helper_debug(cpu_env);
     ctx->base.is_jmp =3D DISAS_NORETURN;
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size below does the right thing.  */
-    ctx->base.pc_next +=3D 2;
-    return true;
+
+    return 2; /* minimum instruction length */
 }
=20
 static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index e530cb4aa8..d6b554cefe 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -5854,8 +5854,8 @@ static void sparc_tr_insn_start(DisasContextBase *dcb=
ase, CPUState *cs)
     }
 }
=20
-static bool sparc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cs,
-                                      const CPUBreakpoint *bp)
+static int sparc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c=
s,
+                                     int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
@@ -5865,9 +5865,8 @@ static bool sparc_tr_breakpoint_check(DisasContextBas=
e *dcbase, CPUState *cs,
     gen_helper_debug(cpu_env);
     tcg_gen_exit_tb(NULL, 0);
     dc->base.is_jmp =3D DISAS_NORETURN;
-    /* update pc_next so that the current instruction is included in tb->s=
ize */
-    dc->base.pc_next +=3D 4;
-    return true;
+
+    return 4; /* minimum instruction length */
 }
=20
 static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
index 865020754d..8c39134d52 100644
--- a/target/tricore/translate.c
+++ b/target/tricore/translate.c
@@ -8810,19 +8810,12 @@ static void tricore_tr_insn_start(DisasContextBase =
*dcbase, CPUState *cpu)
     tcg_gen_insn_start(ctx->base.pc_next);
 }
=20
-static bool tricore_tr_breakpoint_check(DisasContextBase *dcbase, CPUState=
 *cpu,
-                                      const CPUBreakpoint *bp)
+static int tricore_tr_breakpoint_check(DisasContextBase *dcbase,
+                                       CPUState *cpu, int bp_flags)
 {
     DisasContext *ctx =3D container_of(dcbase, DisasContext, base);
     generate_qemu_excp(ctx, EXCP_DEBUG);
-    /*
-     * The address covered by the breakpoint must be included in
-     * [tb->pc, tb->pc + tb->size) in order to for it to be
-     * properly cleared -- thus we increment the PC here so that
-     * the logic setting tb->size below does the right thing.
-     */
-    ctx->base.pc_next +=3D 4;
-    return true;
+    return 4; /* minimum instruction length */
 }
=20
 static bool insn_crosses_page(CPUTriCoreState *env, DisasContext *ctx)
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 7094cfcf1d..6e7ad266f4 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -1232,20 +1232,16 @@ static void xtensa_tr_insn_start(DisasContextBase *=
dcbase, CPUState *cpu)
     tcg_gen_insn_start(dcbase->pc_next);
 }
=20
-static bool xtensa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState =
*cpu,
-                                       const CPUBreakpoint *bp)
+static int xtensa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *=
cpu,
+                                      int bp_flags)
 {
     DisasContext *dc =3D container_of(dcbase, DisasContext, base);
=20
     tcg_gen_movi_i32(cpu_pc, dc->base.pc_next);
     gen_exception(dc, EXCP_DEBUG);
     dc->base.is_jmp =3D DISAS_NORETURN;
-    /* The address covered by the breakpoint must be included in
-       [tb->pc, tb->pc + tb->size) in order to for it to be
-       properly cleared -- thus we increment the PC here so that
-       the logic setting tb->size below does the right thing.  */
-    dc->base.pc_next +=3D 2;
-    return true;
+
+    return 2; /* minimum instruction length */
 }
=20
 static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *c=
pu)
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 16261047765118.536895969453894;
 Mon, 12 Jul 2021 08:46:16 -0700 (PDT)
Received: from localhost ([::1]:50624 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2y8N-00081u-CF
	for importer@patchew.org; Mon, 12 Jul 2021 11:46:15 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59886)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2h-0003zk-T2
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:24 -0400
Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:42856)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2W-0000wE-GR
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:23 -0400
Received: by mail-pf1-x42b.google.com with SMTP id y4so16728946pfi.9
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:11 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:10 -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=DeiOM3E/by38ksgPe4YGpd7ba5mJVtkTjbeFMUwSxAA=;
 b=Pq3D1OvrKTBqjAD/YmlAA29Ge5Jg9V7ZKn8Ms3UqMLd3d8X/o8FdHrQZLzO4AskQlh
 ZOPPuFNQKU2iM7dMEL6JiFK4NI0wwDoAmfZn3wh0sBuq0RPLJ8KvbB8Il5nRzA4Slwhb
 SRGbkQzSmoxq9qqU1xaCPpD+dVkYdKoKFFV7th4HZLe7J6nuIQLoXZ24DxtVliZ7yoUV
 pd+3kT3NxGCq4bW3zfKa11oG1oh5dXmSdW9SHERrZcmgASz/dCR5msGuiZw4irUrn5Ts
 2kos5J/SUeyUjAvDDDvVWKUvIZYTAHUtvKZp1VcGQh1uaZHYAQl1pIVOVWAJ8VteKid9
 bdwA==
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=DeiOM3E/by38ksgPe4YGpd7ba5mJVtkTjbeFMUwSxAA=;
 b=KRnJ/k5xTGOilebbFUeoP0FBUYswWlgNVjk/omIkq/XwOR+pZ3ncCVrGk804qY9CIU
 wCMeCKhc+xGSGQBFH2MfGunhdwz6c2oKu8YCxOYoi+tiYsuBqJoXqZrTj6gIj/RDxp0K
 yBR4qpEzX572zKErjtyWRwV55VHUe9kX+ykPP99I4ti2foqvjZ+T3O5d5CqrcQirjbTG
 3s6rNbV6DySVhv10fksKUlNTsr5OyIMzCM7cGnU6cK6n4d3iE3jaRzseZRJMb9+Eg/+s
 Vb1ETF1Ws6ubhJ4DlrbpyLdzkSDC7ijNZidCiGUXTSH8Ky2FrbyI3BLy1vmyhxYT75+Y
 5H1Q==
X-Gm-Message-State: AOAM533OBlNcyMVu9rLkJZhdl4Rt1iz9hAUqNMT0uOaDJhqof4KtZRCn
 x0x1mPYd9thHwPzPi1W9kvS3LoJtkU5l2A==
X-Google-Smtp-Source: 
 ABdhPJwUHOLTPlwWnUYch5uK5KJxH9bKd5fSMXhjDHpFfMCRWuFDgm0bANkr8GKf2FEVF/LG27a1rg==
X-Received: by 2002:a63:da04:: with SMTP id c4mr53966446pgh.348.1626104410850;
 Mon, 12 Jul 2021 08:40:10 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 09/10] accel/tcg: Hoist tb_cflags to a local in
 translator_loop
Date: Mon, 12 Jul 2021 08:40:03 -0700
Message-Id: <20210712154004.1410832-10-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::42b;
 envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104778067100001
Content-Type: text/plain; charset="utf-8"

The access internal to tb_cflags() is atomic.
Avoid re-reading it as such for the multiple uses.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 accel/tcg/translator.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 1c44d096d8..449159a27c 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -50,6 +50,7 @@ bool translator_use_goto_tb(DisasContextBase *db, target_=
ulong dest)
 void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
                      CPUState *cpu, TranslationBlock *tb, int max_insns)
 {
+    uint32_t cflags =3D tb_cflags(tb);
     bool plugin_enabled;
=20
     /* Initialize DisasContext */
@@ -72,8 +73,7 @@ void translator_loop(const TranslatorOps *ops, DisasConte=
xtBase *db,
     ops->tb_start(db, cpu);
     tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT);  /* no early exit */
=20
-    plugin_enabled =3D plugin_gen_tb_start(cpu, tb,
-                                         tb_cflags(db->tb) & CF_MEMI_ONLY);
+    plugin_enabled =3D plugin_gen_tb_start(cpu, tb, cflags & CF_MEMI_ONLY);
=20
     while (true) {
         db->num_insns++;
@@ -125,14 +125,13 @@ void translator_loop(const TranslatorOps *ops, DisasC=
ontextBase *db,
            update db->pc_next and db->is_jmp to indicate what should be
            done next -- either exiting this loop or locate the start of
            the next instruction.  */
-        if (db->num_insns =3D=3D db->max_insns
-            && (tb_cflags(db->tb) & CF_LAST_IO)) {
+        if (db->num_insns =3D=3D db->max_insns && (cflags & CF_LAST_IO)) {
             /* Accept I/O on the last instruction.  */
             gen_io_start();
             ops->translate_insn(db, cpu);
         } else {
             /* we should only see CF_MEMI_ONLY for io_recompile */
-            tcg_debug_assert(!(tb_cflags(db->tb) & CF_MEMI_ONLY));
+            tcg_debug_assert(!(cflags & CF_MEMI_ONLY));
             ops->translate_insn(db, cpu);
         }
=20
--=20
2.25.1


From nobody Wed Apr  2 05:09:25 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=fail;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=linaro.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1626104966484856.6912722848626;
 Mon, 12 Jul 2021 08:49:26 -0700 (PDT)
Received: from localhost ([::1]:58376 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1m2yBR-0005Gz-FO
	for importer@patchew.org; Mon, 12 Jul 2021 11:49:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59926)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2k-000411-Et
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:26 -0400
Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:37446)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
 id 1m2y2Y-0000wJ-6R
 for qemu-devel@nongnu.org; Mon, 12 Jul 2021 11:40:26 -0400
Received: by mail-pf1-x42b.google.com with SMTP id 17so16775185pfz.4
 for <qemu-devel@nongnu.org>; Mon, 12 Jul 2021 08:40:12 -0700 (PDT)
Received: from localhost.localdomain ([71.212.149.176])
 by smtp.gmail.com with ESMTPSA id b33sm18247635pgb.92.2021.07.12.08.40.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Jul 2021 08:40:11 -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=GsYTylIZOg07xboTBgz05SQc22Do7qgHV7kQGXX9qk8=;
 b=M8wJR9jum2z+ijrloNAVRevPL7iMHBW6PBvHHer/quN/bQBAKHmIQs/SES1sPESHM6
 PdPdhL6SlEvLCVCzi/WlbU77pyEI625pmcEKHRWjl/ilarOTlSBRXhH7ADPrR94/SlMB
 6egEw5re1Bf+5rN5+nqGIeQimmob9LOB2Fg0JnQX4gpqp08fyRoy6TYpJhJeDVZOsI/A
 v6Z7I6YVb4BbS1OqLMG3fiLCwqltz+sY060UMohmHlk5QfO/NecZklSJ3pTj41bokqLn
 /TV/Q6JsOM6gr/P8YocN36BZ5zeuxBaIi4c3zLmeBQD8cEmB2M9DgAcCcqBakyE7WY6m
 w5uQ==
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=GsYTylIZOg07xboTBgz05SQc22Do7qgHV7kQGXX9qk8=;
 b=S+laTTC7hUt2LcpF6SbUPF+no0hskGmDrCO1/wWnbKIkIgtti0IvPLcDo7f6957em2
 qprfxe56+1QpeFrziKLNuInHQAW37nGVkaGvCFAGw+a9KMKq6HJkazBcNInK4dAEIoDP
 dUaAQaQqrlQJwt7eJTtedE+wrXgIV842qv0+6tcP0ToRO+50YXUi3xxsG76Oe8WYiuak
 U1dkG3cTAs2pMA1Z7Kzhhqgz0/o9/gHB+ahItx5PaUhT4Z1kGV8/lUIKjw6LESOEEMYG
 vUjH0xCqFjFIBSCogkRU8iiS0R0IGOPMsTQ3oQQvwoVxZd+q35V7OthvXc2Caoj5PiBv
 gIBg==
X-Gm-Message-State: AOAM533WcvFF6YjHL3+3lsBZ+dIlxU0TibKYWrs9Mz7iWfq0MQN+2R7V
 dowEe58vMELzt1RVdJM7jN+ozUw/U+1itg==
X-Google-Smtp-Source: 
 ABdhPJw31oE3zhbCA/9dCxagCnfyqFrScskEr8P6jUiqkPZp5evzVKk7jnSm5fwAa35MBMP6uKWzRQ==
X-Received: by 2002:a63:f750:: with SMTP id
 f16mr53105026pgk.292.1626104411377;
 Mon, 12 Jul 2021 08:40:11 -0700 (PDT)
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH v2 10/10] accel/tcg: Encode breakpoint info into tb->cflags
Date: Mon, 12 Jul 2021 08:40:04 -0700
Message-Id: <20210712154004.1410832-11-richard.henderson@linaro.org>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210712154004.1410832-1-richard.henderson@linaro.org>
References: <20210712154004.1410832-1-richard.henderson@linaro.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2607:f8b0:4864:20::42b;
 envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com
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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, f4bug@amsat.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: fail (Header signature does not verify)
X-ZM-MESSAGEID: 1626104967179100001
Content-Type: text/plain; charset="utf-8"

Having this data in cflags means that hashing takes care
of selecting a TB with or without exceptions built in.
Which means that we no longer need to flush all TBs.

This does require that we single-step while we're within a page
that contains a breakpoint, so it's not yet ideal, but should be
an improvement over some corner-case slowdowns.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/404
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/exec/exec-all.h   |  7 ++++
 accel/tcg/cpu-exec.c      | 68 ++++++++++++++++++++++++++++++-
 accel/tcg/translate-all.c |  4 --
 accel/tcg/translator.c    | 85 +++++++++++++++++++++------------------
 cpu.c                     | 24 -----------
 5 files changed, 119 insertions(+), 69 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 6873cce8df..7ab2578f71 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -502,9 +502,16 @@ struct TranslationBlock {
 #define CF_USE_ICOUNT    0x00020000
 #define CF_INVALID       0x00040000 /* TB is stale. Set with @jmp_lock hel=
d */
 #define CF_PARALLEL      0x00080000 /* Generate code for a parallel contex=
t */
+#define CF_BP_MASK       0x00300000 /* See below */
+#define CF_BP_SHIFT      20
 #define CF_CLUSTER_MASK  0xff000000 /* Top 8 bits are cluster ID */
 #define CF_CLUSTER_SHIFT 24
=20
+#define CF_BP_NONE       (0 << CF_BP_SHIFT) /* TB does not interact with B=
Ps */
+#define CF_BP_SSTEP      (1 << CF_BP_SHIFT) /* gdbstub single-step in effe=
ct */
+#define CF_BP_GDB        (2 << CF_BP_SHIFT) /* gdbstub breakpoint at tb->p=
c */
+#define CF_BP_CPU        (3 << CF_BP_SHIFT) /* arch breakpoint at tb->pc */
+
     /* Per-vCPU dynamic tracing state used to generate this TB */
     uint32_t trace_vcpu_dstate;
=20
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 4d043a11aa..179a425ece 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -222,6 +222,65 @@ static inline void log_cpu_exec(target_ulong pc, CPUSt=
ate *cpu,
     }
 }
=20
+static uint32_t cflags_for_breakpoints(CPUState *cpu, target_ulong pc,
+                                       uint32_t cflags)
+{
+    uint32_t bflags =3D 0;
+
+    if (unlikely(cpu->singlestep_enabled)) {
+        bflags =3D CF_BP_SSTEP;
+    } else {
+        bool match_page =3D false;
+        CPUBreakpoint *bp;
+
+        QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
+            /* Note exact pc matches */
+            if (pc =3D=3D bp->pc) {
+                if (bp->flags & BP_GDB) {
+                    bflags =3D CF_BP_GDB;
+                    break;
+                }
+                if (bp->flags & BP_CPU) {
+                    bflags =3D CF_BP_CPU;
+                    break;
+                }
+            }
+            /* Note page matches */
+            if (((pc ^ bp->pc) & TARGET_PAGE_MASK) =3D=3D 0) {
+                match_page =3D true;
+            }
+        }
+
+        if (likely(!bflags)) {
+            if (likely(!match_page)) {
+                return cflags;
+            }
+
+            /*
+             * Within the same page as a breakpoint, single-step,
+             * returning to helper_lookup_tb_ptr after each looking
+             * for the actual breakpoint.
+             *
+             * TODO: Perhaps better to record all of the TBs associated
+             * with a given virtual page that contains a breakpoint, and
+             * then invalidate them when a new overlapping breakpoint is
+             * set on the page.  Non-overlapping TBs would not be
+             * invalidated, nor would any TB need to be invalidated as
+             * breakpoints are removed.
+             */
+            bflags =3D CF_NO_GOTO_TB;
+        }
+    }
+
+    /*
+     * Reduce the TB to one insn.
+     * In the case of a BP hit, we will be raising an exception anyway.
+     * In the case of a page hit, return to helper_lookup_tb_ptr after
+     * every insn to look for the breakpoint.
+     */
+    return (cflags & ~CF_COUNT_MASK) | 1 | bflags;
+}
+
 /**
  * helper_lookup_tb_ptr: quick check for next tb
  * @env: current cpu state
@@ -235,11 +294,13 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env)
     CPUState *cpu =3D env_cpu(env);
     TranslationBlock *tb;
     target_ulong cs_base, pc;
-    uint32_t flags;
+    uint32_t flags, cflags;
=20
     cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
=20
-    tb =3D tb_lookup(cpu, pc, cs_base, flags, curr_cflags(cpu));
+    cflags =3D cflags_for_breakpoints(cpu, pc, curr_cflags(cpu));
+
+    tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
     if (tb =3D=3D NULL) {
         return tcg_code_gen_epilogue;
     }
@@ -346,6 +407,8 @@ void cpu_exec_step_atomic(CPUState *cpu)
         cflags &=3D ~CF_PARALLEL;
         /* After 1 insn, return and release the exclusive lock. */
         cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | 1;
+        /* Raise any post-instruction debug exceptions. */
+        cflags =3D cflags_for_breakpoints(cpu, pc, cflags);
=20
         tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
         if (tb =3D=3D NULL) {
@@ -524,6 +587,7 @@ static inline TranslationBlock *tb_find(CPUState *cpu,
     } else {
         cpu->cflags_next_tb =3D -1;
     }
+    cflags =3D cflags_for_breakpoints(cpu, pc, cflags);
=20
     tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags);
     if (tb =3D=3D NULL) {
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 491c1a56b2..1f98078608 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1432,10 +1432,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
     }
     QEMU_BUILD_BUG_ON(CF_COUNT_MASK + 1 !=3D TCG_MAX_INSNS);
=20
-    if (cpu->singlestep_enabled) {
-        max_insns =3D 1;
-    }
-
  buffer_overflow:
     tb =3D tcg_tb_alloc(tcg_ctx);
     if (unlikely(!tb)) {
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 449159a27c..01b48137da 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -33,13 +33,8 @@ void translator_loop_temp_check(DisasContextBase *db)
=20
 bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
 {
-    /* Suppress goto_tb if requested. */
-    if (tb_cflags(db->tb) & CF_NO_GOTO_TB) {
-        return false;
-    }
-
-    /* Suppress goto_tb in the case of single-steping.  */
-    if (db->singlestep_enabled) {
+    /* Suppress goto_tb if requested, or required by breakpoints. */
+    if (tb_cflags(db->tb) & (CF_NO_GOTO_TB | CF_BP_MASK)) {
         return false;
     }
=20
@@ -51,6 +46,7 @@ void translator_loop(const TranslatorOps *ops, DisasConte=
xtBase *db,
                      CPUState *cpu, TranslationBlock *tb, int max_insns)
 {
     uint32_t cflags =3D tb_cflags(tb);
+    int bp_flags =3D 0;
     bool plugin_enabled;
=20
     /* Initialize DisasContext */
@@ -60,7 +56,23 @@ void translator_loop(const TranslatorOps *ops, DisasCont=
extBase *db,
     db->is_jmp =3D DISAS_NEXT;
     db->num_insns =3D 0;
     db->max_insns =3D max_insns;
-    db->singlestep_enabled =3D cpu->singlestep_enabled;
+    db->singlestep_enabled =3D false;
+
+    switch (cflags & CF_BP_MASK) {
+    case CF_BP_NONE:
+        break;
+    case CF_BP_SSTEP:
+        db->singlestep_enabled =3D true;
+        break;
+    case CF_BP_GDB:
+        bp_flags =3D BP_GDB;
+        break;
+    case CF_BP_CPU:
+        bp_flags =3D BP_CPU;
+        break;
+    default:
+        g_assert_not_reached();
+    }
=20
     ops->init_disas_context(db, cpu);
     tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT);  /* no early exit */
@@ -85,39 +97,34 @@ void translator_loop(const TranslatorOps *ops, DisasCon=
textBase *db,
         }
=20
         /* Pass breakpoint hits to target for further processing */
-        if (!db->singlestep_enabled
-            && unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) {
-            CPUBreakpoint *bp;
-            QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
-                if (bp->pc =3D=3D db->pc_next) {
-                    int len =3D ops->breakpoint_check(db, cpu, bp->flags);
+        if (unlikely(bp_flags)) {
+            int len =3D ops->breakpoint_check(db, cpu, bp_flags);
=20
-                    /*
-                     * The breakpoint_check hook may use DISAS_TOO_MANY
-                     * to indicate that only one more instruction is to
-                     * be executed.  Otherwise it should use DISAS_NORETURN
-                     * when generating an exception, but may use a
-                     * DISAS_TARGET_* value for Something Else.
-                     */
-                    if (db->is_jmp > DISAS_TOO_MANY) {
-                        /*
-                         * The address covered by the breakpoint must be
-                         * included in [tb->pc, tb->pc + tb->size) in order
-                         * to for it to be properly cleared.  Thus we
-                         * increment the PC here so that the logic setting
-                         * tb->size below does the right thing.
-                         */
-                        tcg_debug_assert(len > 0);
-                        db->pc_next +=3D len;
+            /*
+             * When there is a bp hit, we're going to execute a maximum
+             * of one instruction.  The breakpoint_check hook may use
+             * DISAS_NEXT or DISAS_TOO_MANY to indicate that the current
+             * instruction should be translated.  Anything else is taken
+             * to mean that an exception has been raised and that zero
+             * instructions will be executed.
+             */
+            if (db->is_jmp > DISAS_TOO_MANY) {
+                /*
+                 * The address covered by the breakpoint must be
+                 * included in [tb->pc, tb->pc + tb->size) in order
+                 * to for it to be properly cleared.  Thus we
+                 * increment the PC here so that the logic setting
+                 * tb->size below does the right thing.
+                 */
+                tcg_debug_assert(len > 0);
+                db->pc_next +=3D len;
=20
-                        /*
-                         * The breakpoint definitely hit, so decrement the
-                         * number of instructions completed for icount.
-                         */
-                        db->num_insns--;
-                        goto done;
-                    }
-                }
+                /*
+                 * The breakpoint definitely hit, so decrement the
+                 * number of instructions completed for icount.
+                 */
+                db->num_insns--;
+                goto done;
             }
         }
=20
diff --git a/cpu.c b/cpu.c
index 83059537d7..addcb5db9c 100644
--- a/cpu.c
+++ b/cpu.c
@@ -225,11 +225,6 @@ void tb_invalidate_phys_addr(target_ulong addr)
     tb_invalidate_phys_page_range(addr, addr + 1);
     mmap_unlock();
 }
-
-static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
-{
-    tb_invalidate_phys_addr(pc);
-}
 #else
 void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs att=
rs)
 {
@@ -250,17 +245,6 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr =
addr, MemTxAttrs attrs)
     ram_addr =3D memory_region_get_ram_addr(mr) + addr;
     tb_invalidate_phys_page_range(ram_addr, ram_addr + 1);
 }
-
-static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
-{
-    /*
-     * There may not be a virtual to physical translation for the pc
-     * right now, but there may exist cached TB for this pc.
-     * Flush the whole TB cache to force re-translation of such TBs.
-     * This is heavyweight, but we're debugging anyway.
-     */
-    tb_flush(cpu);
-}
 #endif
=20
 /* Add a breakpoint.  */
@@ -281,8 +265,6 @@ int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int =
flags,
         QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);
     }
=20
-    breakpoint_invalidate(cpu, pc);
-
     if (breakpoint) {
         *breakpoint =3D bp;
     }
@@ -310,8 +292,6 @@ void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBre=
akpoint *bp)
 {
     QTAILQ_REMOVE(&cpu->breakpoints, bp, entry);
=20
-    breakpoint_invalidate(cpu, bp->pc);
-
     trace_breakpoint_remove(cpu->cpu_index, bp->pc, bp->flags);
     g_free(bp);
 }
@@ -336,10 +316,6 @@ void cpu_single_step(CPUState *cpu, int enabled)
         cpu->singlestep_enabled =3D enabled;
         if (kvm_enabled()) {
             kvm_update_guest_debug(cpu, 0);
-        } else {
-            /* must flush all the translated code to avoid inconsistencies=
 */
-            /* XXX: only flush what is necessary */
-            tb_flush(cpu);
         }
         trace_breakpoint_singlestep(cpu->cpu_index, enabled);
     }
--=20
2.25.1