From nobody Sat Apr 11 23:04:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1772954434; cv=none; d=zohomail.com; s=zohoarc; b=LQzGNxS32Dr04NJM7kdy+Ph+GhH9qqdr83KzKIwcTFe+qbci8iP1Cr+0R42OpHofRl+HPxtl/ZVSShjEK/x7mP4/EdwY4fadAN7O73N5fL7nBs5P1HLuaz59a6qz1gOQTGcm2p9Cjk46ZNJypcgqmE1+uIBBnfgRVi+q4RXIwn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772954434; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MZ70pDkBubnfAy6PbUsKzZ+QirfaHkd5aNPfsmS2uPM=; b=Z8UZAtYV4D/O+kAsxlNvxOiXEet3RrU1gEusyBaLhYWUIdi5rMLVF7PKWP6mfY3Zve6DW1zLg7R0bwTmyPlURDwI9RqHDvJ5WLW8HvaJK38w3Ea0LufrUZIKsR41tMSipc5YVbTdYSXiut/gnWbjgQdxgXol4oS35VwW3Di+y/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772954434129810.9388274061573; Sat, 7 Mar 2026 23:20:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vz8Qj-0000Be-4O; Sun, 08 Mar 2026 03:20:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vz8Qc-0008Oq-Tm for qemu-devel@nongnu.org; Sun, 08 Mar 2026 03:19:54 -0400 Received: from mail-dy1-x1343.google.com ([2607:f8b0:4864:20::1343]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vz8Qb-00023E-GD for qemu-devel@nongnu.org; Sun, 08 Mar 2026 03:19:54 -0400 Received: by mail-dy1-x1343.google.com with SMTP id 5a478bee46e88-2b4520f6b32so12156008eec.0 for ; Sat, 07 Mar 2026 23:19:52 -0800 (PST) Received: from ZEVORN-PC.bbrouter ([38.95.120.198]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2be4f984ceasm6014081eec.32.2026.03.07.23.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 23:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772954392; x=1773559192; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MZ70pDkBubnfAy6PbUsKzZ+QirfaHkd5aNPfsmS2uPM=; b=E3FjLXyavPZBtw4OQLpiUCx6U2KojuU3CuuainUOODTnP8hGOUQHib00TwN6uVauuT qYno1PYhLsJhKI9bGCFk1VP27n4Dpv/g8tshIEaLNH1srNo+Za2yPzPzdIXuFxR52Ft3 z5XM9IrUU+RFH/71gKZqJXNOuZSN6iFrQgf5ECaRITyAEpFsrtNz+YUDEmbvvHG7xHrg IJ9dyhop6jFQmeM4LEF/GWxNZtbs9ejShRFVITNIgMrPcoP7a1oYLBIyykb1/6p10EFo RtiAKG8CUQBMsalJmIwOFynsLfGQUGRDkEWgYAdjs9PhxVvpiuDBwUB0CL1OwGsG97vn I5kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772954392; x=1773559192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MZ70pDkBubnfAy6PbUsKzZ+QirfaHkd5aNPfsmS2uPM=; b=bVGyiB9CUoQeNCSe1wfRhnQC1zvna+Q/ij8qDiS1p0k93ivSFwteuVKbywC3nsw3IU 0YogDUdUjHnhtqwDZspOS+KdeDE1FVFwpOHGNnkeDiWhXVWDGcHg/BHEYvU/4UFnsomI uLqSgKG0Wtonmvw9nYjgOvdx1z1tx3vtFzqiEZDIYrxbf39MTZABaDpCMszvM398ReFH e56gHEE4I75P4uqPRzu3/IL172Sr0zAVMDOjOei0V/BLN8+bnwu7EH14pABh9rwtPKaL /0IQiAx0p3Z8RvuGOTEiEfbBlf5OxXWyHMUVPpCYkkESR+Fu7I5r5lJCt7l/n9lPQblg AgFA== X-Forwarded-Encrypted: i=1; AJvYcCWogCEmUZ+qWdlELU+4fMPJrCd9ZKEdLpqbbYL/y18S0vPXcFFx8VnfegZxrxJ1W7sLpOUL3TMxgSZ0@nongnu.org X-Gm-Message-State: AOJu0Yx1xBfF14Gfrjjc3XSZsYeVMg1n40Q9MM0ml7xrQlh4mnbyWdJM /i97IZLIDOYAG6/lEZVuBHI2IfJhO03pxJEXF8qEILev+0sd3aEsrhKu X-Gm-Gg: ATEYQzxrSqvt4FJx8Ru2G0aRkMK0gQ5fr+MbUoKu/MlYuMrHtfkBwRqWOeBzoWSAYSZ YWQ8UNjW5N7EQY/MMQ0GuZcVSvoXYjGjddvHeDIfFagVGiEo4YVWIhX+iUw5L+Y361rsvzd3qZg 32MGvXIhXABF0W6Jn3qTm0S6aTLRB2CBJYn4ifgAKs2ur9odkTlG8dd5Idj9DV4Fxgvr4J1ZRz3 mqDtcfs1/8XJqETuyxNR+KICWJTCqs8RhPjyjKbV+HaL6ZNkE530gTQy6GHZhybKqg1m0F0OXik op6hedLnvHlp9WQ0kH4q4cmbsgnp5zawcr2Z2LxIfMOB32Q4qfF7/D5UGNfNPOJb/NADI7iGLJg TPWHY0t1w707LWg043NUzDeK+j1FrI7Z/Nfw3jOGHoKZGFyEieKh6DfDdaAKag4pVGpGjWs9vhZ Ghcnsxm7lUi9V5k7wtGtomFl8n17TCGiCNcFoyp2PAv/W2alKq/Dgpl8UfwNHN6j+yAaqGcDLDu NBDow865TOYA6bzMkRYh+rUguY= X-Received: by 2002:a05:7300:3b24:b0:2be:2a16:4a54 with SMTP id 5a478bee46e88-2be4e03edd3mr2825263eec.25.1772954391584; Sat, 07 Mar 2026 23:19:51 -0800 (PST) From: Chao Liu To: Paolo Bonzini , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Fabiano Rosas , Laurent Vivier Cc: tangtao1634@phytium.com.cn, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v1 14/28] target/riscv: stop consuming itrigger counts in Debug Mode Date: Sun, 8 Mar 2026 15:17:17 +0800 Message-ID: <378f3cac42ed118add63c496d52ea54b426ff284.1772936778.git.chao.liu.zevorn@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: 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::1343; envelope-from=chao.liu.zevorn@gmail.com; helo=mail-dy1-x1343.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, FREEMAIL_FROM=0.001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1772954435364154100 Content-Type: text/plain; charset="utf-8" Do not decrement instruction-count triggers while the hart is already in Debug Mode, and store the decremented count before testing whether it reached zero. This matches the architectural rule that triggers do not fire in Debug Mode and avoids losing a count update when the trigger transitions to its firing state. Signed-off-by: Chao Liu --- target/riscv/debug.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 4dbcf289f2..ae9b1cd42a 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -837,6 +837,11 @@ bool riscv_itrigger_enabled(CPURISCVState *env) void helper_itrigger_match(CPURISCVState *env) { int count; + + if (env->debug_mode) { + return; + } + for (int i =3D 0; i < RV_MAX_TRIGGERS; i++) { if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { continue; @@ -848,7 +853,9 @@ void helper_itrigger_match(CPURISCVState *env) if (!count) { continue; } - itrigger_set_count(env, i, count--); + + count--; + itrigger_set_count(env, i, count); if (!count) { env->itrigger_enabled =3D riscv_itrigger_enabled(env); do_trigger_action(env, i); --=20 2.53.0