From nobody Mon Nov 23 04:36:07 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1794559797; cv=none; d=zohomail.com; s=zohoarc; b=N7LDQErMT7nHnxPKG4gM0lakKIAO+3QKt0hM6EzofUW0rI2C9u+1HFiU13iKgEe3tk3tStjTd0QAWVAFOZJTnP6yKKKTwfTUpVx3TNd3cY7c3SafVTD9iphmsbaQN5jBerZfio2D2HfctbxZsbkKJy9R98PSAlmxB746UTkM+wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794559797; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oN6mXz/c7yix4xzGlnsgM4bOUuCxsp4u/erF+z45B48=; b=oCLyyK0idD4tR6+vdG3HM/kf1SRXNZrDc27RIxx1UgMARYRtm6ldHB5jY/GAQ+i9yC6rplJnWHlJHjbDuTXQOeEZMvbaANmXQsmeVk3gaQQlxCqgmdjns4nobi4mcdRHH6PXBKDcpkME+FC+fp06iTaOSQ6D7GVxyshe1zPMjss= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794559797966422.15917689933246; Fri, 13 Nov 2026 00:49:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRmx5-0004WT-GX; Fri, 13 Nov 2026 03:48:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xRmvh-000308-4D for qemu-devel@nongnu.org; Fri, 13 Nov 2026 03:46:47 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xRmvf-0007VF-A4 for qemu-devel@nongnu.org; Fri, 13 Nov 2026 03:46:40 -0500 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AD8V1Sq3826891 for ; Fri, 13 Nov 2026 08:46:38 GMT Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hwv37gs1d-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 13 Nov 2026 08:46:38 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-3724667bc16so422203eec.1 for ; Fri, 13 Nov 2026 00:46:38 -0800 (PST) Received: from hu-himchau-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-379559189e8sm5689242eec.11.2026.11.13.00.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 00:46:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=oN6mXz/c7yi x4xzGlnsgM4bOUuCxsp4u/erF+z45B48=; b=IYzlf946wIX84WC3YFUI73FNB6f RN4SVqhOC5lgAQdJHN1ULUr/UrM91DQ/Ju/IXXRsJAyutySgp6x+D6cXgHCHKUfs 3ZEF7dquMUe10HBJEc0R/Cle0KtwgFyl2EOQcupTHrCuaJ65fdpfU4nYHAa/5lsy GpoI5CaSi7OFklAKdhpIIjLrVkLpV4ENAI+BujEm0LdvfozK3YfUqLcqdRIt7SKD otiJ6oVR0z7EgWrxQ0oz0JARtXOjCmkz7l1WOQzJVkbrgL7M08VreQxS5uzIdaRk rJGuvZqT+w0SNHck4kyZCbWVCOcjxV+siTM1XvNPXbEpGRPgLMQ0cyzB9/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1794559597; x=1795164397; 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:content-type; bh=oN6mXz/c7yix4xzGlnsgM4bOUuCxsp4u/erF+z45B48=; b=fgPeIHsM1BQeEcv86sSiCp5l/8gTyzKKlLZV/oj96ws/Nec7MZD6flIDDULUwt+QqY Fm6EDxxiqFr4Pia/UZct0BwAktpTeXwjE23CHrRdUmuNUj3jke5u7ariv3t02Do/LtK2 8K7nzgMAy17dmng4FuuBn6RZhkehQxyqVB6qsMQgWRhktwle8Ly9opLxD4/2mc1PztLH djXhwqirUhtVAvtJf//10JaoJ/5ZoWD9AYIWhm1DeR4iJPE/x/jlUqlbsBD5Ui7Rni9i cIGQaQ5bxOrSxDhZkTcMzlBADsRq88jTX6g21wIEJyW3nQTrGMTAVWEoN2SpPdFQUCYq OZyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794559597; x=1795164397; 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:content-type; bh=oN6mXz/c7yix4xzGlnsgM4bOUuCxsp4u/erF+z45B48=; b=i5VZeNCT5fH4TKnIqzt234l39wFfD7UmoA91mapn/G1lZJlDVfjQ8W7+chyrIc9j3K /rxA9ElsmoJp1k1Bs1JQwor71VtdnP+FvyAAK0zN0EXtmezYwJSaibtrFFLsWhjh4VCP RMlPU5KOyn1cymZyj+VMGOIb25t5qpFTQvGQ6cdIAFiCk2382yHxc/ftEcWqNaBtEERE co6sQDscucq8Qfnx5SZoMiMpHrqcqblRhL4C0n+QkjzddJA8s/C75wmQ3XY9nAIPlSOe lwWlQi6VUho+3JWYNUVVXwmEBTks7SrtL2DsElu7AFfkNvbKh7FiIpRQARCKb/zHMMar 807w== X-Gm-Message-State: APuU4Z82RzKutxsLL2Pm1E2WgWCGOrw6UyHydS63+UBc4ZxmKZbf30AO 3jqtuqc9/u/RKNXpNFpaJhWyY+KdZEOSwGDfDJNfHPLFh8bPxgF0AVOMA7mzmfECJfMo4qSSVX0 kkebse1kPQay3mYmpY9vh+zTnZv+Zr95p8dCkckwaiC3B1GcJQbfocuhsMXcNRFo35g== X-Gm-Gg: AYBFou2g3eIleKKr4rUtzYjMo06U3kyoGaWEf2+l4Ds7mBh+xf3nGhRACdKF2eEqrf4 ZVxNpti6xbSiQfrc5BmF9gIjH2qxnPJ71Jvj/WV0G1/h6KAWsEcjZ8BtPnugidPseFqL5ExmHPu XeqwnuDvLlaIuCd71yrYYb94ClLC9B2Go8JD+h7lDinrWKajXUAUXk8lxT4jqEu0obu/j1s+fp5 x/bd2lGI2rM2GjIFC5RwAU3arIsQbatYOb4G5P1xFUXao0rrPOt3F4GWQTbPoLc9mltDbHLY4rF fTOfRKX9d/IVLTob+1ZHVg7SjFDGK7Kw6E5NRAlhaD735uWQ2k8HZE6dt+p3PBRN5fa5e1ijqjq /1D5B3aFM58FnmOLfMPVy1MpIfAz6NC6sDdqLYxkovRSfdAiPBiwSvtoDEf4v2chS1JeyJuiw7k tqpKcLnzEfR0u3qfTaJKt2rC1XOUzchdCbO1Etde/TtMSxVw36EI9TuUayUEzQP2zoGufAnKQ2 X-Received: by 2002:a05:693c:41dc:20b0:36c:a1bc:6102 with SMTP id 5a478bee46e88-37960385e62mr1635992eec.0.1794559597204; Fri, 13 Nov 2026 00:46:37 -0800 (PST) X-Received: by 2002:a05:693c:41dc:20b0:36c:a1bc:6102 with SMTP id 5a478bee46e88-37960385e62mr1635972eec.0.1794559596686; Fri, 13 Nov 2026 00:46:36 -0800 (PST) From: Himanshu Chauhan To: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-riscv@nongnu.org Cc: Himanshu Chauhan Subject: [PATCH v3 1/2] target/riscv: Keep tdata CSRs available for disabled slots Date: Fri, 13 Nov 2026 14:16:21 +0530 Message-ID: <20261113084622.738278-2-himanshu.chauhan@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261113084622.738278-1-himanshu.chauhan@oss.qualcomm.com> References: <20261113084622.738278-1-himanshu.chauhan@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYxMTEzMDAzNCBTYWx0ZWRfX4y7GOadqfz8z tvptIENw2uBkBBxxr5x6V4LLHmI5Jo4f9ixjdpiqmOA3A/2hmMb67fDEMSw4m2kMPD/DP4TfiNR NvX2X54mD+FrOe3xVTziVsz5cRhwoW8= X-Proofpoint-ORIG-GUID: luh694NahCH69Q1I6uN1g0EikHUnG2-v X-Proofpoint-GUID: luh694NahCH69Q1I6uN1g0EikHUnG2-v X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTEzMDAzNCBTYWx0ZWRfXyxVOrlWAfOI/ WUyNSTO6Dmxrp5oeNBGxEX881G5XREDJEcgHipC4Lh4iwsTUI44eH9ZYq2XYz72kcK4sd40n/QO QkV00OzAp74JieD3CEetOEYDi+lCC0rP6qnE/XlYnUy3HuIq5HoiJFjf2K8Qyfh3pUGYv4Z2/y8 9dpXeDqBjECdp5zGyZfgIc0wlgu2cfjuWLzupBpgQsGIr9P7MuMPoScfEfwGtOLsc/SjTAMUTFi hnShBxcvkSgX1C2kmYdoWOBiS1nYPh9QNir8zZXx+ustsfw9BRRVI2Tg7FMXNszG33LPc9xiwJx kGpN+tDSdt7IHhDExoBMUZG4hEUqpxl3r+1p4h9EPThyhnYfE/9/NgWQf0wEcLSFisd+2DTVahU dFHizyblChKFSpg0JdqCgqczUd8oflz750u/wa9hBKdFeGNZgOhfLrugjfQ/u78Jyyjv/Tk5SjV t+ncW9/sScsyRY5tbfA== X-Authority-Analysis: v=2.4 cv=ZeeIpcVA c=1 sm=1 tr=0 ts=6af6ce6e cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=Dl6hwa1UTsAzBJgR6sYA:9 a=6Ab_bkdmUrQuMsNx7PHu:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-13_03,2026-11-11_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611130034 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=himanshu.chauhan@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 @qualcomm.com) X-ZM-MESSAGEID: 1794559798612158500 Content-Type: text/plain; charset="utf-8" The tdata CSRs belong to an implemented trigger slot, not only to the trigger type currently selected in tdata1. Writing zero to tdata1 disables the trigger by selecting type zero, but it does not remove the slot. Keep tdata access tied to the selected slot being present and let type-zero slots accept those writes while clearing any active breakpoint state. Fixes: 95799e36c15a ("target/riscv: Add initial support for the Sdtrig exte= nsion") Signed-off-by: Himanshu Chauhan --- target/riscv/tcg/debug.c | 50 ++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/target/riscv/tcg/debug.c b/target/riscv/tcg/debug.c index 8b58cbd07a..2067657c81 100644 --- a/target/riscv/tcg/debug.c +++ b/target/riscv/tcg/debug.c @@ -53,20 +53,6 @@ * 1 | 2 | tdata1, tdata2 | Address / Data Match */ =20 -/* tdata availability of a trigger */ -typedef bool tdata_avail[TDATA_NUM]; - -static tdata_avail tdata_mapping[TRIGGER_TYPE_NUM] =3D { - [TRIGGER_TYPE_NO_EXIST] =3D { false, false, false }, - [TRIGGER_TYPE_AD_MATCH] =3D { true, true, true }, - [TRIGGER_TYPE_INST_CNT] =3D { true, false, true }, - [TRIGGER_TYPE_INT] =3D { true, true, true }, - [TRIGGER_TYPE_EXCP] =3D { true, true, true }, - [TRIGGER_TYPE_AD_MATCH6] =3D { true, true, true }, - [TRIGGER_TYPE_EXT_SRC] =3D { true, false, false }, - [TRIGGER_TYPE_UNAVAIL] =3D { true, true, true } -}; - /* only breakpoint size 1/2/4/8 supported */ static int access_size[SIZE_NUM] =3D { [SIZE_ANY] =3D 0, @@ -165,13 +151,17 @@ static inline target_ulong build_tdata1(CPURISCVState= *env, =20 bool tdata_available(CPURISCVState *env, int tdata_index) { - int trigger_type =3D get_trigger_type(env, env->trigger_cur); - if (unlikely(tdata_index >=3D TDATA_NUM)) { return false; } =20 - return tdata_mapping[trigger_type][tdata_index]; + /* + * tdata CSRs belong to the trigger slot, not to the currently selected + * trigger type. A type-zero trigger is disabled, but the slot still + * exists, so software must still be able to write tdata2/tdata3 before + * selecting a supported trigger type. + */ + return env->trigger_cur < env->num_triggers; } =20 target_ulong tselect_csr_read(CPURISCVState *env) @@ -729,6 +719,30 @@ static void type6_reg_write(CPURISCVState *env, target= _ulong index, } } =20 +static void no_trigger_reg_write(CPURISCVState *env, target_ulong index, + int tdata_index, target_ulong val) +{ + /* + * OpenSBI programs DBTR slots by first writing type zero to tdata1, t= hen + * writing tdata2/tdata3, and finally writing the desired trigger type. + */ + switch (tdata_index) { + case TDATA1: + type2_breakpoint_remove(env, index); + env->tdata1[index] =3D 0; + env->itrigger_enabled =3D riscv_itrigger_enabled(env); + break; + case TDATA2: + env->tdata2[index] =3D val; + break; + case TDATA3: + env->tdata3[index] =3D textra_validate(env, val); + break; + default: + g_assert_not_reached(); + } +} + /* icount trigger type */ static inline int itrigger_get_count(CPURISCVState *env, int index) @@ -995,6 +1009,8 @@ void tdata_csr_write(CPURISCVState *env, int tdata_ind= ex, target_ulong val) trigger_type); break; case TRIGGER_TYPE_NO_EXIST: + no_trigger_reg_write(env, env->trigger_cur, tdata_index, val); + break; case TRIGGER_TYPE_UNAVAIL: qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exit\n", trigger_type); --=20 2.43.0 From nobody Mon Nov 23 04:36:07 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1794559816; cv=none; d=zohomail.com; s=zohoarc; b=H1lMNwslb2yXoqvX3dQMYuu1IfuYMwtayQGsoItZ3/dNzmxGiMM6c+xGip4c9hv/TI3Imh+IqEupsU5+ntPm3VRFER4kezk2axN4qSGJoJo8/k3kzT5v8pCHZbgkQF7RojH6v5OUMTd8Y4avoPJAs/SrCpUJtlG4jik59F4CC5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794559816; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0RzR1pxJS8ndYfZXJ6e+dMQ1yaqrJS/JgCUH4n/9grs=; b=AveD7rXEe6q9d3xKlNxZBP0s4aLZbZ8hDVdJd3uV6YhgtnAWTZfk+2xaiNUPNtzWsGJI38Hnhe63JJTw31EFHwomhFsG4cdGaPytJACWZob0ywUHmeSPQ9Hlw8/H9/U7yRuc5E1uESgCVtui8iusDG/BpoE+3mqwFsM//1oVyw8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794559816201898.377722679535; Fri, 13 Nov 2026 00:50:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRmx4-0004Od-8Q; Fri, 13 Nov 2026 03:48:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xRmvp-000326-Lb for qemu-devel@nongnu.org; Fri, 13 Nov 2026 03:46:51 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xRmvm-0007WZ-PQ for qemu-devel@nongnu.org; Fri, 13 Nov 2026 03:46:49 -0500 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AD8V7uS619141 for ; Fri, 13 Nov 2026 08:46:45 GMT Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hwbs0492k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 13 Nov 2026 08:46:45 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-341eff9e381so1183385eec.1 for ; Fri, 13 Nov 2026 00:46:45 -0800 (PST) Received: from hu-himchau-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-379559189e8sm5689242eec.11.2026.11.13.00.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 00:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=0RzR1pxJS8n dYfZXJ6e+dMQ1yaqrJS/JgCUH4n/9grs=; b=nHj2NdZQfLibkIfT+7rzaGnNDfY KkIIVF2sXBndrwW1NLmVfm3eZ+gBC+NJl4Zt3lX8rgI3UKM8EQ2Tpp9NQ3bGQiRt AEzjnJBEOObZqFu18DvJeElkVnDGjSs49gHPeDWTbg6YACv8Wy/XhYfT2PkL0eF1 2ple0hVZg4rqnxkdBwaVwf+yUPF9K3gyCgoQzdN+NdBzfB7yGSxoAWcYFAGddx08 YPbVXc+NuJQa4sPYfZJ1WCCV7zwqNkclLLTXMpmb7utQkttTAItqclwVgfUujx4Q JwMzbQh29D/80FcfBb3/2waGY4PDo1wIm503x0ufZ4v5CEN12eyzwnBLA8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1794559604; x=1795164404; 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:content-type; bh=0RzR1pxJS8ndYfZXJ6e+dMQ1yaqrJS/JgCUH4n/9grs=; b=gl9AumJKo22oXuyN47kGSFarFrVpyVjYmlO7yHh6aZ4bXkIpKz3H4e5uNMa8hnZDqO lal1IW79lU5xMKivNsPlDoOfxZPjXK+LkJgerqoUteci7GvDh71e99atT41ReRplkbpD o1l9ETCBO0KwDiOfS+jPWrdxASp0ltdnOIdRfPU9lk2lYSiWqDkJ8NRoq2fwsrjxS+9K QDyZaLTY19M7Fcy8IlxXAD4W8mu1ftSbER9z7t1MWeHooqZH2hYcVgsrFoVymXX9e3g7 NWmiRpkG9buR5Cac4FG0VkJenQ5h8qIbQSFl0ts3a+AylgLkrGicSKH3ptJaJ5VSSig9 XOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794559604; x=1795164404; 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:content-type; bh=0RzR1pxJS8ndYfZXJ6e+dMQ1yaqrJS/JgCUH4n/9grs=; b=B5KW5F9qA9GIcXglTC1M03tl9CTTkMkh1AuTHRQcoX83jY1P14LGEW8udOgRvBzVLw skFgKOkMhMnTde6HBSSPJVe5fMhP7Ye+PpiPL96RyJCPRK3XB78Vu2y31Trnip9wQiPL 77kLpNAMhyNv+nKqGhWhcBsasoR8v2q4b/wsFZhixgviTH3dz35wpnZuVJxptm2OIoKk LZCMtOGspsXDDuKu5oNA9/YvYKUXZU5HmEx45YXSEaHJpDQyF4OvXDnV/zPixLziHqHb icBV3TZKxuwppGRzZQsRESdoZNZbWVx/PgjI+RlLB2UgzQGLhQziOrCaL4/2oEHGy7p6 r1QA== X-Gm-Message-State: APuU4Z+Mdnvhwfg8bp+RDcATCsGG9p2ae7Wv/fxThOR59QekWGk369iN 9ZnOinb03kbsSPQ9Ek4hpFhX5Sv0G74etTJGkjf1TwRA42w05kjZ5XeyWvXfOaHBaDzILrvoey6 rBXhZrM04q7bHniE6AeAoX6RAWQOmWkt6WvKG5/xRmSBZFbC2nNDaBMFkRLu18NKsRQ== X-Gm-Gg: AYBFou3ID7LQHmAnAZ0qA3++4aUk2PX54NGChMcYQjlF8WFW0xQAMcb53JlTUqYFbG6 dDFwCaIvcqzhv0vdpCpZ0FyWH0koCrFFGwA1oo7KpkffMKgcXyHSt7P2c2AsPNxnetZprbhd9IH 9XCl7ZTkz495PdJhOc98z9IQvKowHwVS6kOd2EYX6MLLHUrOF7xSTjywgUFre3h6zhPLn4qPgrk rFyFvxcCC8tLhJR9TTVC9qO+vcQjKafZgcq5MOBMGtO/Yqq7tcfeiYWReT8BKLdVC6r9vxpOqsC QCyvfUtGgSuMe8HWPK+2w1PlEclZuj7NVUrufppqV9usA3TE0XmPKCO2LEsU3YViN1jm4m4e/0G dnN5mBnT2BhLpydwKohFpwKf1qZo2SgMjQHPLR29nF97MPonBFSWkZcBYk8Zas4X3qaP1qwDJ/X SPQ2EUOWZ9Q6zM/MxYcMT0dwvGl7558YN3urJqp18oksvkfIg5+wh1kWHcD9L2JVkClqoJPfEw X-Received: by 2002:a05:7300:d406:b0:35f:2bc:82d3 with SMTP id 5a478bee46e88-379662913ddmr1345869eec.15.1794559604234; Fri, 13 Nov 2026 00:46:44 -0800 (PST) X-Received: by 2002:a05:7300:d406:b0:35f:2bc:82d3 with SMTP id 5a478bee46e88-379662913ddmr1345844eec.15.1794559603551; Fri, 13 Nov 2026 00:46:43 -0800 (PST) From: Himanshu Chauhan To: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-riscv@nongnu.org Cc: Himanshu Chauhan Subject: [PATCH v3 2/2] target/riscv: Fix icount trigger exception PC Date: Fri, 13 Nov 2026 14:16:22 +0530 Message-ID: <20261113084622.738278-3-himanshu.chauhan@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261113084622.738278-1-himanshu.chauhan@oss.qualcomm.com> References: <20261113084622.738278-1-himanshu.chauhan@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTEzMDAzNCBTYWx0ZWRfXwX4noC2IHfdU GztUWqPbkhASGNszn0PZAshrB0OTjH1WgneDkUZCMjDKxzwYVEJv9MKdCAG7HkPqvxiV9ov1Ka/ 4PWAir8V7sdyWIBMeBD41eSlewcX5mC5JV45WMGPnbFqbRMt8rnut8EpJkZqojP8r9ZUYQWINI7 gFbPZfgDFeSmvXXh7+L9ze2YxQOselKxozPZy42s24TqbQSE+tcQ85ze2/AbrJJDFNj1ZNAFsio MBvJppnDRS0N5foN6pQBElSRUAbIOizDPUilyAwhnV+5FeIVlYfbLemMGH+eqbPJ8JaFa+133hg lwuVxNI/24qoJRWLe7C3mDScOtdvHVx9W1L5YfFdd90wG13k8WVEzS33sU+1NlMF/E0mHSezx+Q beIBhkeqjsgSshxnc1uBmK5j3u3GqKon+F1oHdM1DOqaob1GDBbXH2+upBiqvuMzSmIV74M2qWe ICqK/KbLZxvDqR39AGg== X-Authority-Analysis: v=2.4 cv=AsF7T+9P c=1 sm=1 tr=0 ts=6af6ce75 cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=ZnDpHCPyknFz56Ji1pYA:9 a=6Ab_bkdmUrQuMsNx7PHu:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTEzMDAzNCBTYWx0ZWRfX8F6y+OlFI16T GRBRPocmLdtHREfaMWqPRKlDpWglPgEiSyS808lJHP/czdA/n8P4jiADNDd5lr21PKG4buwp3Li oyg4VNcjVMwoG0pnpuNs0lug0vPxcUw= X-Proofpoint-GUID: QKGKFLeoqHwfSxYwyzZGxEPD_yFD3NUG X-Proofpoint-ORIG-GUID: QKGKFLeoqHwfSxYwyzZGxEPD_yFD3NUG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-13_03,2026-11-11_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611130034 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=himanshu.chauhan@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @qualcomm.com) X-ZM-MESSAGEID: 1794559816821158500 Content-Type: text/plain; charset="utf-8" Per the Sdtrig specification, on a breakpoint exception with icount, xepc must contain the virtual address of the next instruction to execute so program flow is preserved. A one-instruction trigger must therefore fire only after the counted instruction retires, and xepc must contain the architectural successor PC: the branch target for a taken branch, or the fallthrough PC otherwise. QEMU previously disabled the translated-block trigger flag when icount was enabled and relied on timer and privilege-change callbacks to update the count. That allowed the trigger to fire outside instruction retirement before the guest PC advanced, causing Linux to observe the old PC and re-enter the same breakpoint while single-stepping with icount. Fix this by publishing the icount trigger flag in translated blocks even with icount enabled. The translated helper now decrements the trigger count after the instruction has committed its successor PC and raises the trigger action only then. Privilege-mode changes, context CSR writes and migration post-load refresh the cached enabled state because icount trigger matching depends on the current mode and context. Remove the old itrigger timers because instruction counting is now tied to translated instruction retirement instead of virtual-time callbacks. Fixes: 5a4ae64cac49 ("target/riscv: Add itrigger support when icount is ena= bled") Signed-off-by: Himanshu Chauhan --- target/riscv/cpu.h | 5 +- target/riscv/machine.c | 5 +- target/riscv/tcg/cpu_helper.c | 10 +-- target/riscv/tcg/csr.c | 3 + target/riscv/tcg/debug.c | 121 +++++----------------------------- target/riscv/tcg/tcg-cpu.c | 7 +- 6 files changed, 33 insertions(+), 118 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 49a1186bdb..3109d71470 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -484,8 +484,7 @@ struct CPUArchState { uint8_t trigger_cur; /* * num_triggers is the length of tdata1, tdata2, tdata3, - * cpu_breakpoint, cpu_watchpoint and itrigger_timer - * arrays. + * cpu_breakpoint and cpu_watchpoint arrays. */ uint32_t num_triggers; uint64_t *tdata1; @@ -493,8 +492,6 @@ struct CPUArchState { uint64_t *tdata3; struct CPUBreakpoint **cpu_breakpoint; struct CPUWatchpoint **cpu_watchpoint; - QEMUTimer **itrigger_timer; - int64_t last_icount; bool itrigger_enabled; =20 /* machine specific rdtime callback */ diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 0de06e9588..74176e7c6e 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -22,7 +22,6 @@ #include "system/kvm.h" #include "system/tcg.h" #include "migration/cpu.h" -#include "exec/icount.h" #include "target/riscv/tcg/debug.h" #ifdef CONFIG_KVM #include "kvm/kvm_riscv.h" @@ -339,9 +338,7 @@ static int debug_post_load(void *opaque, int version_id) RISCVCPU *cpu =3D opaque; CPURISCVState *env =3D &cpu->env; =20 - if (icount_enabled()) { - env->itrigger_enabled =3D riscv_itrigger_enabled(env); - } + env->itrigger_enabled =3D riscv_itrigger_enabled(env); =20 return 0; } diff --git a/target/riscv/tcg/cpu_helper.c b/target/riscv/tcg/cpu_helper.c index 58e98e975c..0375b930be 100644 --- a/target/riscv/tcg/cpu_helper.c +++ b/target/riscv/tcg/cpu_helper.c @@ -940,10 +940,6 @@ void riscv_cpu_set_mode(CPURISCVState *env, privilege_= mode_t newpriv, g_assert(newpriv <=3D PRV_M && newpriv !=3D PRV_RESERVED); =20 if (newpriv !=3D env->priv || env->virt_enabled !=3D virt_en) { - if (icount_enabled()) { - riscv_itrigger_update_priv(env); - } - riscv_pmu_update_fixed_ctrs(env, newpriv, virt_en); } =20 @@ -982,6 +978,12 @@ void riscv_cpu_set_mode(CPURISCVState *env, privilege_= mode_t newpriv, riscv_cpu_interrupt(env); } } + + /* + * Icount triggers are scoped by U/S/M and VU/VS mode bits. Refresh t= he + * cached translated-block flag after privilege or virtualization chan= ges. + */ + riscv_itrigger_update_priv(env); } =20 /* diff --git a/target/riscv/tcg/csr.c b/target/riscv/tcg/csr.c index af444e3e6f..7c05c866fd 100644 --- a/target/riscv/tcg/csr.c +++ b/target/riscv/tcg/csr.c @@ -5732,6 +5732,9 @@ static RISCVException write_mcontext(CPURISCVState *e= nv, int csrno, } =20 env->mcontext =3D val & mask; +#if !defined(CONFIG_USER_ONLY) + env->itrigger_enabled =3D riscv_itrigger_enabled(env); +#endif return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/tcg/debug.c b/target/riscv/tcg/debug.c index 2067657c81..a84d8eb4cf 100644 --- a/target/riscv/tcg/debug.c +++ b/target/riscv/tcg/debug.c @@ -32,8 +32,6 @@ #include "trace.h" #include "exec/helper-proto.h" #include "exec/watchpoint.h" -#include "system/cpu-timers.h" -#include "exec/icount.h" #include "accel/tcg/cpu-loop.h" =20 /* @@ -768,21 +766,6 @@ itrigger_set_pending(CPURISCVState *env, int index, in= t val) ITRIGGER_PENDING, val); } =20 -static bool check_itrigger_priv(CPURISCVState *env, int index) -{ - target_ulong tdata1 =3D env->tdata1[index]; - if (env->virt_enabled) { - /* check VU/VS bit against current privilege level */ - return (get_field(tdata1, ITRIGGER_VS) =3D=3D env->priv) || - (get_field(tdata1, ITRIGGER_VU) =3D=3D env->priv); - } else { - /* check U/S/M bit against current privilege level */ - return (get_field(tdata1, ITRIGGER_M) =3D=3D env->priv) || - (get_field(tdata1, ITRIGGER_S) =3D=3D env->priv) || - (get_field(tdata1, ITRIGGER_U) =3D=3D env->priv); - } -} - bool riscv_itrigger_enabled(CPURISCVState *env) { int count; @@ -790,7 +773,7 @@ bool riscv_itrigger_enabled(CPURISCVState *env) if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { continue; } - if (check_itrigger_priv(env, i)) { + if (!trigger_common_match(env, TRIGGER_TYPE_INST_CNT, i)) { continue; } count =3D itrigger_get_count(env, i); @@ -817,7 +800,12 @@ void HELPER(itrigger_match)(CPURISCVState *env) if (!count) { continue; } - itrigger_set_count(env, i, count--); + /* + * This helper is emitted at TB exit after one guest instruction a= nd + * after the translator has committed env->pc to the successor PC. + */ + count--; + itrigger_set_count(env, i, count); if (!count) { /* * From the 1.0 spec: "When pending is set, the trigger @@ -832,6 +820,9 @@ void HELPER(itrigger_match)(CPURISCVState *env) * * Note that itrigger_set_pending() is a no-op if we're * running debug 0.13. + * + * Software writes still validate pending as a read-only field; + * QEMU only toggles it internally around the trigger action. */ itrigger_set_pending(env, i, 1); =20 @@ -844,53 +835,13 @@ void HELPER(itrigger_match)(CPURISCVState *env) =20 static void riscv_itrigger_update_count(CPURISCVState *env) { - int count, executed; /* - * Record last icount, so that we can evaluate the executed instructio= ns - * since last privilege mode change or timer expire. + * Icount triggers are matched from translated code after an instructi= on + * has committed its successor PC. Timer and privilege-change callbac= ks + * therefore must not decrement count or fire the action here; they on= ly + * refresh the cached TB flag state. */ - int64_t last_icount =3D env->last_icount, current_icount; - current_icount =3D env->last_icount =3D icount_get_raw(); - - for (int i =3D 0; i < env->num_triggers; i++) { - if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { - continue; - } - count =3D itrigger_get_count(env, i); - if (!count) { - continue; - } - /* - * Only when privilege is changed or itrigger timer expires, - * the count field in itrigger tdata1 register is updated. - * And the count field in itrigger only contains remaining value. - */ - if (check_itrigger_priv(env, i)) { - /* - * If itrigger enabled in this privilege mode, the number of - * executed instructions since last privilege change - * should be reduced from current itrigger count. - */ - executed =3D current_icount - last_icount; - itrigger_set_count(env, i, count - executed); - if (count =3D=3D executed) { - do_trigger_action(env, i); - } - } else { - /* - * If itrigger is not enabled in this privilege mode, - * the number of executed instructions will be discard and - * the count field in itrigger will not change. - */ - timer_mod(env->itrigger_timer[i], - current_icount + count); - } - } -} - -static void riscv_itrigger_timer_cb(void *opaque) -{ - riscv_itrigger_update_count((CPURISCVState *)opaque); + env->itrigger_enabled =3D riscv_itrigger_enabled(env); } =20 void riscv_itrigger_update_priv(CPURISCVState *env) @@ -925,18 +876,10 @@ static void itrigger_reg_write(CPURISCVState *env, ta= rget_ulong index, =20 switch (tdata_index) { case TDATA1: - /* set timer for icount */ new_val =3D itrigger_validate(env, val); if (new_val !=3D env->tdata1[index]) { env->tdata1[index] =3D new_val; - if (icount_enabled()) { - env->last_icount =3D icount_get_raw(); - /* set the count to timer */ - timer_mod(env->itrigger_timer[index], - env->last_icount + itrigger_get_count(env, index= )); - } else { - env->itrigger_enabled =3D riscv_itrigger_enabled(env); - } + env->itrigger_enabled =3D riscv_itrigger_enabled(env); } break; case TDATA2: @@ -945,33 +888,17 @@ static void itrigger_reg_write(CPURISCVState *env, ta= rget_ulong index, break; case TDATA3: env->tdata3[index] =3D textra_validate(env, val); + env->itrigger_enabled =3D riscv_itrigger_enabled(env); break; default: g_assert_not_reached(); } } =20 -static int itrigger_get_adjust_count(CPURISCVState *env) -{ - int count =3D itrigger_get_count(env, env->trigger_cur), executed; - if ((count !=3D 0) && check_itrigger_priv(env, env->trigger_cur)) { - executed =3D icount_get_raw() - env->last_icount; - count +=3D executed; - } - return count; -} - target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index) { - int trigger_type; switch (tdata_index) { case TDATA1: - trigger_type =3D extract_trigger_type(env, - env->tdata1[env->trigger_cur]); - if ((trigger_type =3D=3D TRIGGER_TYPE_INST_CNT) && icount_enabled(= )) { - return deposit64(env->tdata1[env->trigger_cur], 10, 14, - itrigger_get_adjust_count(env)); - } return env->tdata1[env->trigger_cur]; case TDATA2: return env->tdata2[env->trigger_cur]; @@ -1163,8 +1090,6 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, C= PUWatchpoint *wp) =20 void riscv_trigger_realize(CPURISCVState *env) { - int i; - if (env->num_triggers > RV_MAX_TRIGGERS) { error_report( "Invalid configuration: 'num-triggers' must be less than %= u", @@ -1177,12 +1102,6 @@ void riscv_trigger_realize(CPURISCVState *env) env->tdata3 =3D g_new0(uint64_t, env->num_triggers); env->cpu_breakpoint =3D g_new0(struct CPUBreakpoint *, env->num_trigge= rs); env->cpu_watchpoint =3D g_new0(struct CPUWatchpoint *, env->num_trigge= rs); - env->itrigger_timer =3D g_new0(QEMUTimer *, env->num_triggers); - - for (i =3D 0; i < env->num_triggers; i++) { - env->itrigger_timer[i] =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, - riscv_itrigger_timer_cb, env= ); - } } =20 void riscv_trigger_unrealize(CPURISCVState *env) @@ -1193,11 +1112,6 @@ void riscv_trigger_unrealize(CPURISCVState *env) =20 g_free(env->cpu_breakpoint); g_free(env->cpu_watchpoint); - - for (int i =3D 0; i < env->num_triggers; i++) { - timer_free(env->itrigger_timer[i]); - } - g_free(env->itrigger_timer); } =20 void riscv_trigger_reset_hold(CPURISCVState *env) @@ -1225,7 +1139,6 @@ void riscv_trigger_reset_hold(CPURISCVState *env) env->tdata3[i] =3D 0; env->cpu_breakpoint[i] =3D NULL; env->cpu_watchpoint[i] =3D NULL; - timer_del(env->itrigger_timer[i]); } =20 env->mcontext =3D 0; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 5834ec1524..027fe5b46a 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -181,8 +181,11 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *= cs) ? EXT_STATUS_DIRTY : EXT_STATUS_DISABLED; } =20 - if ((cpu->cfg.debug || cpu->cfg.ext_sdtrig) - && !icount_enabled()) { + /* + * Publish itrigger state even when QEMU icount is enabled. The helper + * runs from translated code after committing the guest successor PC. + */ + if (cpu->cfg.debug || cpu->cfg.ext_sdtrig) { flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enab= led); } #endif --=20 2.43.0