From nobody Mon Nov 23 04:52:33 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1792036338; cv=none; d=zohomail.com; s=zohoarc; b=kM/jaS4WJNiawQAK27surN3YWtsT03AQ6sHq2XCIyfNtg/qhNhf0PnHoe5gRDrZgGomYzf3e++0yyVx3A7HEmXsNDcG7X+VtOF4EwbXrN+XCRJsL6Ae6TDoV0ARSNUq6jyqNSrx88cptlOHHLqf4ibt96TKSex4bvtPoEOQqC8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792036338; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From: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=q7ErHNQ55SvaVVFHHdyUJJkJSySnIe6JlKODfOwTt7U=; b=KNr6o4D9PegXr3ckXK2o8jPgQGblp8u0vGYtNJxgSW1ZMExmC4VJ32QM+luUoOdVk2Fv8NHMUvMhjsePKbxZhYFkdrCawv7FAJhOW/1ECZqMHlAdUs8dGUnFz0nkY5MAitQme7JiNB5GHia3BcAPvljPQiO2WZzyD3mOv1hsFHk= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179203633837079.8227946271802; Wed, 14 Oct 2026 20:52:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xHCV9-0001RV-PU; Wed, 14 Oct 2026 23:51:31 -0400 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 1xHCV6-0001R0-NI for qemu-devel@nongnu.org; Wed, 14 Oct 2026 23:51:29 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xHCV1-0000wL-HX for qemu-devel@nongnu.org; Wed, 14 Oct 2026 23:51:28 -0400 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69F1PnAo3468853 for ; Thu, 15 Oct 2026 03:51:20 GMT Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hadd7a763-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 15 Oct 2026 03:51:20 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-30bcb065bfdso8798508eec.0 for ; Wed, 14 Oct 2026 20:51:20 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-35b690af3easm27743555eec.1.2026.10.14.20.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2026 20:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=q7ErHNQ55SvaVVFHHdyUJJ kJSySnIe6JlKODfOwTt7U=; b=WxagqiAvfGnyiinxEhTLa78dgje/UwD4sKdeU/ xfF6vC9fLRDhcAq7q/+yQl2wns8U5hneq9zR33mw+DyjKCaJD0vFQuQfCRwo40Mx RxmH+OvXwMCIGE5AwlsbArJizUu6t132Isq84VOtHJdarXDoyIvw7v6vPjYiukbj cPN+UcMTvuQJfILv1r4mXbffe1mtUW3LXvkt2mpL6Q/TiokdB5WZdjtFlMWIjV4H LasDjUA34zmWhplBkrOnGnhTGTax3TUKNOgbXiE///QH+AcIy+0PxjAlpf1wAjBC Tt9ETr4EAjJhnEroXRubj24+9TRnyKtN5XVDLvAH16kufzpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1792036280; x=1792641080; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=q7ErHNQ55SvaVVFHHdyUJJkJSySnIe6JlKODfOwTt7U=; b=FdZY31M971CZBLEl0UCqNTLqfhQbr7njCylVc1p9GUGOJzFoPxSGJvbyRaf5EaxQai UbXJZMePBSYRTJxxJGjiodhiyAP0xgVH2LRyNQrNvGHaSf7XBjdcpO70kcLT+uBL7Jmg nLOPJnePPRrGpRT6bmLdY4blBqhMvtVqZLxBRgg7y0/l3oug4s2Ms+C9254uqW9Hz74i VS7hjmeeKK4iHNhV4J+Nfj59EeQwwRwTLomfqnsvq0enLh5Rg16JLmijDCdStrgGA4M7 sLeZWbPESeH6gSp6bibolbH2wZH+Gcf8tTO/eSW17706K7Rm79N7fxbpJHENh9t286JL 1iTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792036280; x=1792641080; h=content-transfer-encoding:content-type:mime-version: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=q7ErHNQ55SvaVVFHHd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9mr7229065eec.3.1792036279563; Wed, 14 Oct 2026 20:51:19 -0700 (PDT) X-Received: by 2002:a05:7300:f14b:b0:35d:19d7:84c with SMTP id 5a478bee46e88-35d19d710b9mr7229034eec.3.1792036278809; Wed, 14 Oct 2026 20:51:18 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier Subject: [PATCH] target/hexagon: implement SSR.SS single-step Date: Wed, 14 Oct 2026 20:51:17 -0700 Message-Id: <20261015035117.4130988-1-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=BaVNQbt2 c=1 sm=1 tr=0 ts=6ad04db8 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=OGF-xHlx4W3PsM0MTRkA:9 a=QEXdDO2ut3YA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-GUID: 1qAEntBD9jb3Voq4qg8GlMpOiY_rGdJ0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE1MDAxNSBTYWx0ZWRfX9enWaxYKe223 udkzhTvGNJvsCNqxFQGKhXiGjP9t3lKJORkJBPOIlrGnkP1HU6zVWXTlhTWzRmQ/RiBkSqDOrB4 +YfDwJIZApq+OwmzOwB7oqormMS1eQ+WgdLjX+z4tbderLCYBPAgyq9PjQHxX1CwT47qakEkZoK MgemRDCIRLJzv1SLfolp6ToarZU7pvSs9Pda2MEoZKEP3LoOiXAY0Gpw9kO32/wtSo0vznQbZLl M75xziYE/c7syHAaI8+F7T1toG6vb2z6yihsJpQ3yeZU58dK9s/mX5WWVZFxYbWIAXbAw3Ib8TE 6eQtzRlpkPww3ZdSNEKVOKPMtWax3NSjMxxY3v7D9fRlaFy7UIMjCu/tJpvi4uvA77qtqZLlswR K2kI0piN+WHqnk4ieVDDixzDAHVGDcZg/QYur4sthdtUnQ/8hLetarTd05vXKZKbyuNyp+Vwpyc qJDtABsUWHfdhd9x1TQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE1MDAxNSBTYWx0ZWRfXzw6snj21Kntz CiyGA5KZGNkz0K2pK2qxm2SO00IMw+aPkk4t1iAWoAUIl16GevAa45amS54QBOlEw0oPLHEEI8F jIlMSh2TqdubSOTCN/sXhXwxDDLLgX8= X-Proofpoint-ORIG-GUID: 1qAEntBD9jb3Voq4qg8GlMpOiY_rGdJ0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-13_01,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610150015 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.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-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: 1792036340452158500 SSR.SS enables a single-step debug event after each packet executed in user or guest mode. Carry the state in a new SS_ACTIVE TB flag. When it is set, translate one packet per TB and raise HEX_EVENT_DEBUG w/PC at the next packet (which becomes ELR). Signed-off-by: Brian Cain Reviewed-by: Pierrick Bouvier --- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 1 + target/hexagon/cpu.c | 4 ++ target/hexagon/hexswi.c | 1 - target/hexagon/translate.c | 49 +++++++++++++++++++++++ tests/functional/hexagon/test_systests.py | 3 ++ 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 65fd2b29830..9feaaf790da 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -228,6 +228,7 @@ FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1) FIELD(TB_FLAGS, MMU_INDEX, 1, 3) FIELD(TB_FLAGS, PCYCLE_ENABLED, 4, 1) FIELD(TB_FLAGS, HVX_COPROC_ENABLED, 5, 1) +FIELD(TB_FLAGS, SS_ACTIVE, 6, 1) =20 G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env, uint32_t exception, diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h index 2d1ed5208b7..0e5419899fb 100644 --- a/target/hexagon/translate.h +++ b/target/hexagon/translate.h @@ -45,6 +45,7 @@ typedef struct DisasContext { DECLARE_BITMAP(gpr_uncond, TOTAL_PER_THREAD_REGS); bool implicit_usr_write; #ifndef CONFIG_USER_ONLY + bool ss_active; int greg_log[GREG_WRITES_MAX]; int greg_log_idx; DECLARE_BITMAP(gregs_written, NUM_GREGS); diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 6550e7fa800..9a25ed2d655 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -353,6 +353,10 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState= *cs) hex_flags =3D FIELD_DP32(hex_flags, TB_FLAGS, HVX_COPROC_ENABLED, cpu->hvx_ctx[0] && GET_SSR_FIELD(SSR_XE, env->t_sreg[HEX_SREG_SSR]= )); + /* Single-step applies only to user and guest mode packets */ + hex_flags =3D FIELD_DP32(hex_flags, TB_FLAGS, SS_ACTIVE, + GET_SSR_FIELD(SSR_SS, env->t_sreg[HEX_SREG_SSR]= ) && + get_cpu_mode(env) !=3D HEX_CPU_MODE_MONITOR); #else hex_flags =3D FIELD_DP32(hex_flags, TB_FLAGS, MMU_INDEX, MMU_USER_IDX); #endif diff --git a/target/hexagon/hexswi.c b/target/hexagon/hexswi.c index ef1d558dfc4..c4ea249155b 100644 --- a/target/hexagon/hexswi.c +++ b/target/hexagon/hexswi.c @@ -868,7 +868,6 @@ void hexagon_cpu_do_interrupt(CPUState *cs) case HEX_EVENT_DEBUG: hexagon_ssr_set_cause(env, env->cause_code); set_addresses(env, 0, cs->exception_index); - qemu_log_mask(LOG_UNIMP, "single-step exception is not handled\n"); break; =20 case HEX_EVENT_PRECISE: diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index cd1abdf1461..df28ea92dc1 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -189,10 +189,47 @@ static void gen_goto_tb(DisasContext *ctx, unsigned t= b_slot_idx, } } =20 +#ifndef CONFIG_USER_ONLY +/* + * Raise the single-step debug event once the packet has retired. PC + * already holds the address of the next packet, which becomes ELR. + */ +static void gen_singlestep_exception(DisasContext *ctx) +{ + tcg_gen_movi_i32(hex_cause_code, HEX_CAUSE_DEBUG_SINGLESTEP); + gen_helper_raise_exception(tcg_env, tcg_constant_i32(HEX_EVENT_DEBUG), + hex_gpr[HEX_REG_PC]); + ctx->base.is_jmp =3D DISAS_NORETURN; +} + +static void gen_end_tb_singlestep(DisasContext *ctx) +{ + TCGv pc =3D hex_gpr[HEX_REG_PC]; + + if (ctx->branch_cond =3D=3D TCG_COND_ALWAYS) { + tcg_gen_movi_tl(pc, ctx->branch_dest); + } else if (ctx->branch_cond !=3D TCG_COND_NEVER) { + tcg_gen_movcond_tl(ctx->branch_cond, pc, ctx->branch_taken, + tcg_constant_tl(1), tcg_constant_tl(ctx->next_P= C), + tcg_constant_tl(ctx->branch_dest)); + } else if (!ctx->pkt.pkt_has_cof) { + tcg_gen_movi_tl(pc, ctx->next_PC); + } + gen_singlestep_exception(ctx); +} +#endif + static void gen_end_tb(DisasContext *ctx) { gen_exec_counters(ctx); =20 +#ifndef CONFIG_USER_ONLY + if (ctx->ss_active) { + gen_end_tb_singlestep(ctx); + return; + } +#endif + if (ctx->branch_cond !=3D TCG_COND_NEVER) { if (ctx->branch_cond !=3D TCG_COND_ALWAYS) { TCGLabel *skip =3D gen_new_label(); @@ -1340,6 +1377,12 @@ static void hexagon_tr_init_disas_context(DisasConte= xtBase *dcbase, ctx->hvx_coproc_enabled =3D FIELD_EX32(hex_flags, TB_FLAGS, HVX_COPROC_ENABLED); ctx->hvx_check_emitted =3D false; + ctx->ss_active =3D FIELD_EX32(hex_flags, TB_FLAGS, SS_ACTIVE); + if (ctx->ss_active) { + /* Step one packet, and let endloop0 branch within the packet */ + ctx->base.max_insns =3D 1; + ctx->is_tight_loop =3D false; + } #endif } =20 @@ -1407,6 +1450,12 @@ static void hexagon_tr_tb_stop(DisasContextBase *dcb= ase, CPUState *cpu) case DISAS_TOO_MANY: gen_exec_counters(ctx); tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->base.pc_next); +#ifndef CONFIG_USER_ONLY + if (ctx->ss_active) { + gen_singlestep_exception(ctx); + break; + } +#endif tcg_gen_exit_tb(NULL, 0); break; case DISAS_NORETURN: diff --git a/tests/functional/hexagon/test_systests.py b/tests/functional/h= exagon/test_systests.py index 20c58f84f67..4c822f9addc 100755 --- a/tests/functional/hexagon/test_systests.py +++ b/tests/functional/hexagon/test_systests.py @@ -108,5 +108,8 @@ def test_hvx_multi(self): def test_standalone_vec(self): self.run_exit_zero("standalone_vec") =20 + def test_single_step(self): + self.run_exit_zero("single_step") + if __name__ =3D=3D "__main__": QemuSystemTest.main() --=20 2.34.1