From nobody Sat Apr 11 19:55:59 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=1775675121; cv=none; d=zohomail.com; s=zohoarc; b=nMBwCSb++gq/WENdBtnI3bUSK06LQE+hd9x07hcpZjL4BqV2P0VBurRYsieXWKj7SOBsVwrKqHsXGeJ1Nio3OlOq0Mpr/N/RaiQWphcaSkkz4AknazWEQt55iELCDUH1ali3dV0q9Y6QCSdRiEoZx5YjlJ8HMM89HNRVlnk3Baw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775675121; h=Content-Type: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=sW27XZh/polIRJ6zGlVRtPePAkF7zmzsx2Pd7RqkvxI=; b=OoYbT+3Sp2kmcuaMss01q3XrATFEgxgqcj5n6LaJVnJYj4LHODlLGkD6BIsKf1ys9YYCy4KhKEyWV0Jg9Wmd5pAbH8KFIFT1VuraC3B9NHFeHw7KERLxmHOyOZxFi4ybzCMlvyo+m1AtU0QyPR0CHDdaqXV1/bewFL9Q0ypQKBU= 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 lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775675121148635.9094592819628; Wed, 8 Apr 2026 12:05:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYD6-0001aR-Jg; Wed, 08 Apr 2026 15:05:09 -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 1wAYCb-0001Rk-RY for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:04:37 -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 1wAKP7-0005cO-37 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 00:20:38 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 637J857s3362755 for ; Wed, 8 Apr 2026 04:20:35 GMT Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dd7tkheyt-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 08 Apr 2026 04:20:35 +0000 (GMT) Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-12c21dbc9c1so1093532c88.0 for ; Tue, 07 Apr 2026 21:20:35 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c14a371b1sm6480362c88.13.2026.04.07.21.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 21:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= sW27XZh/polIRJ6zGlVRtPePAkF7zmzsx2Pd7RqkvxI=; b=OTU2X7M6vdsdAb4p NpF5DjBsV9BchO9kVrXnjwdB6jOruQREy3OxsQ5aA05RufiRAtZrDWlNPeihdesz TQAbHmmaGORU0ioZQd1q4nMoJHyHfsMoj4FaZ1P/Y0lu/Vn0GbWDSiMGhpLcx5gN uneKnPDh6SKH+FR7NGiQevLj70Zj4mw4RjqcGChIMEbLzrgTtVns2TDZGE0Yben6 lQpKm9GXChAlXeW2/XmiHQ8tqSe9/WyGU/I4jHJfSnP0mow/7U+7LTfHTvdmTthc eDwhzgiSEjH7Fwt3pFAYYCyeZWOAHBuE0v2kCgP2SjEtcsDiVtX4Y373kBkTeqCD cZ+Lwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775622035; x=1776226835; 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=sW27XZh/polIRJ6zGlVRtPePAkF7zmzsx2Pd7RqkvxI=; b=VJFjKyqb7Y/W+nDYdPKw9wOkUzqKkdEATzRCpdFblJYA8tVmbQk8mC7O3DkEEtQdnz jVDcpzX7+E4C6POw4PZPrC2NWTvZfpnpAUlGOTVGJGbqxbPCQM9WLMhII+KxfU/X+p3f 2tZZhLLXdDXarhd9bidSxS+vtD+s7598gyh/c0fdWhCd/qjs7oDomEVyyckrN3NjVgwE SzkQMTOcyW3DUbq0GEVgoX7p/Feo83/Z3rrQBLukmd1lcHIVL3DIgur47p1jOjeioi9D sUBUsPj8SScl6D+EPjlqla3QvEqn0UBB98/b7JrmKOUl0oNCL+gxnHvr9H7XqbWtWVcu hAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775622035; x=1776226835; 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=sW27XZh/polIRJ6zGlVRtPePAkF7zmzsx2Pd7RqkvxI=; b=G1tuLrTR5V2+E7GPRITmLE7GVFUPLkJWkTta5U9pn8v8dhKnF2t0iF1MyZOiuihAtk QF6wUI9tt5CwOju+rB/doyb56PfTfVb/BPY67c9uJLPrkgvVsBWcL/ZkV2pgZHRGMXoH exPN6I+caOYWcPgT75dNKJfWzmLaEcyYgLl2oQpkjaVRftszeQuESLtl2FNKgUHETm2r UJpE55PSYCBVaR67jHGjladRaWzxCuOU3Knfnzwk9dMi9LuhjALdbL3X10xPAb7RPoEN pelfvpLcldPnSlDUFLYt4kzHM6CkZ0oGaUTYN+/F1d4oKHQHxFTRMb6AYv63HiBZANKX sCiw== X-Gm-Message-State: AOJu0YzLMAMPwS4VcH9IIaZcqSVGA+6n04GJWC8rOv7QxxrvXPMIHqnN NWYSMfGhSTHTfp28hLTZ6T1n2QVH6PgzBVjCHnq2S1+p77/5y0tCPjk3RthftvSEKUz/k06vnGW 7APw7wfoZLbNqG0iGZZjzhY5Drw3hdqaR85B5G6rtLaiQ8kgCfC/MCbPb+tus0Q3Bdg== X-Gm-Gg: AeBDiesmie3hZvctH+XRW8+pOUvZttaUMnBChiiwEg8Imchcm+FEvVuRWBq14iaFytF meuixtQWm4AuZpvA6MogWZKxLJtLjbxBCCHj8Cw9skD7WSGJsKvGTCDMSz3eMzjzi9LRNl/0vA5 cgM0u9tvn2joKFoZjppDMVpuFTfCu84w1JZ9L0GACqJygTEI0nt0eZzh7QLYFymwgol6Acg+Qbb kenzcOfoo41wKSWiqieEXYYeb4FZPIkiakQuxWw9C7t3IPKFELus3FL0t3da1vsEW0b2HnFevvE IG13TtLNo+zoliRRS/CZv7HH8H6AoRkGMyVogoOWc/VAkUJnhehNMkc40q1/OPQlYG42vZiAasY l1i7MCLWORVdun7Pq9C3x0xcdFR7BvqyDxQEBdMt4EZg9p7QEeV9E4raywdsppzGh2tAYOA== X-Received: by 2002:a05:7022:6997:b0:128:d7a7:526b with SMTP id a92af1059eb24-12bfb745137mr11122791c88.22.1775622034686; Tue, 07 Apr 2026 21:20:34 -0700 (PDT) X-Received: by 2002:a05:7022:6997:b0:128:d7a7:526b with SMTP id a92af1059eb24-12bfb745137mr11122773c88.22.1775622034098; Tue, 07 Apr 2026 21:20:34 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, ltaylorsimpson@gmail.com, matheus.bernardino@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, quic_mburton@quicinc.com, sid.manning@oss.qualcomm.com, ale@rev.ng, anjo@rev.ng, Brian Cain Subject: [PATCH v4 25/28] target/hexagon: Add PC to raise_exception, use fTRAP() helper Date: Tue, 7 Apr 2026 21:19:50 -0700 Message-Id: <20260408041953.1899532-26-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260408041953.1899532-1-brian.cain@oss.qualcomm.com> References: <20260408041953.1899532-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=drPrzVg4 c=1 sm=1 tr=0 ts=69d5d793 cx=c_pps a=SvEPeNj+VMjHSW//kvnxuw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=COk6AnOGAAAA:8 a=pGLkceISAAAA:8 a=EUspDBNiAAAA:8 a=4FQt9sIIQT5CW9ciUtIA:9 a=QEXdDO2ut3YA:10 a=Kq8ClHjjuc5pcCNDwlU0:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: T-_7nGHyZGK8A0L1vZyMuks5KqE9m3HX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA4MDAzNiBTYWx0ZWRfX/gXQ7huijtTv zZy8i12L9AGR/sMVodYIhsr6PXhcSLeMJlAKImgUW8Rjh/qA2XvnNcoe2dpoCmf5vTMfZLCDiGd b6F1/kVBqtkC9xRg3IDUuVxYSLn9+7bTytLu5mYI8dFFYJrK+re/1IJmqiS7F7QxCSTfQgJ3WCT 8SwfB08TJdlo1nw/qLlzC91ap+5Y/EmA4bqyCdfqcmXspxBCvvUJ+BPMXoh8AtRKKHERjjvpq6D v504xWj0km+Y0qkp8PWOWWDsRIxnRssRGq0nZkGD+k9PTf0p7OxgJa7M4HQ2/hT/nAu8yEWFhVV R/GLI0S/avjNS7WyDaBWhJDIDTfSdurPxZHwPwWgEnjhNeydWIU+RYuUqkZhNQ0iJpcMttK1DCU OlhWQgukptvlq7fUo+8pPsBkclIkhTp0+KWsWNpa4wxBekN0Lmkp/Ueh3FR6fHKko0CwadcRK4R TydSlu1WW9CVsGQ5BBQ== X-Proofpoint-GUID: T-_7nGHyZGK8A0L1vZyMuks5KqE9m3HX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-08_02,2026-04-07_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604080036 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=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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1775675123914158500 From: Brian Cain Add PC to raise_exception helper Replace the fGEN_TCG_J2_trap0 macro override with the fTRAP()-generated system helper instead. Reviewed-by: Taylor Simpson Signed-off-by: Brian Cain --- target/hexagon/gen_tcg.h | 7 ------- target/hexagon/helper.h | 2 +- target/hexagon/op_helper.c | 10 ++++------ target/hexagon/translate.c | 21 ++++++++++++++++----- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index 86d74ed259c..a28af0c245b 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -1349,13 +1349,6 @@ #define fGEN_TCG_S2_storew_rl_st_vi(SHORTCODE) SHORTCODE #define fGEN_TCG_S4_stored_rl_st_vi(SHORTCODE) SHORTCODE =20 -#define fGEN_TCG_J2_trap0(SHORTCODE) \ - do { \ - uiV =3D uiV; \ - tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->pkt->pc); \ - TCGv excp =3D tcg_constant_tl(HEX_EVENT_TRAP0); \ - gen_helper_raise_exception(tcg_env, excp); \ - } while (0) #endif =20 #define fGEN_TCG_A2_nop(SHORTCODE) do { } while (0) diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h index 17e74b12f3c..a89758b5df5 100644 --- a/target/hexagon/helper.h +++ b/target/hexagon/helper.h @@ -18,7 +18,7 @@ #include "internal.h" #include "helper_protos_generated.h.inc" =20 -DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32) +DEF_HELPER_FLAGS_3(raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32= , i32) DEF_HELPER_2(commit_store, void, env, int) DEF_HELPER_3(gather_store, void, env, i32, int) DEF_HELPER_1(commit_hvx_stores, void, env) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index aeea4715372..c4ad6015689 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -65,15 +65,13 @@ G_NORETURN void hexagon_raise_exception_err(CPUHexagonS= tate *env, uint32_t exception, uintptr_t pc) { - CPUState *cs =3D env_cpu(env); - qemu_log_mask(CPU_LOG_INT, "%s: %d\n", __func__, exception); - cs->exception_index =3D exception; - cpu_loop_exit_restore(cs, pc); + do_raise_exception(env, exception, pc, 0); } =20 -G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t exc= p) +G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t exc= p, + uint32_t PC) { - hexagon_raise_exception_err(env, excp, 0); + hexagon_raise_exception_err(env, excp, PC); } =20 void log_store32(CPUHexagonState *env, target_ulong addr, diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 38721d74007..ae980c087f0 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -126,12 +126,19 @@ intptr_t ctx_tmp_vreg_off(DisasContext *ctx, int regn= um, return offset; } =20 -static void gen_exception_raw(int excp) +static void gen_exception(int excp, uint32_t PC) { - gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp), + tcg_constant_i32(PC)); } =20 #ifndef CONFIG_USER_ONLY +static inline void gen_precise_exception(int excp, uint32_t PC) +{ + tcg_gen_movi_i32(hex_cause_code, excp); + gen_exception(HEX_EVENT_PRECISE, PC); +} + static void gen_pcycle_counters(DisasContext *ctx) { if (ctx->pcycle_enabled) { @@ -140,6 +147,7 @@ static void gen_pcycle_counters(DisasContext *ctx) } #endif =20 + static void gen_exec_counters(DisasContext *ctx) { tcg_gen_addi_tl(hex_gpr[HEX_REG_QEMU_PKT_CNT], @@ -213,8 +221,11 @@ static void gen_end_tb(DisasContext *ctx) void hex_gen_exception_end_tb(DisasContext *ctx, int excp) { gen_exec_counters(ctx); - tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->next_PC); - gen_exception_raw(excp); +#ifdef CONFIG_USER_ONLY + gen_exception(excp, ctx->pkt->pc); +#else + gen_precise_exception(excp, ctx->pkt->pc); +#endif ctx->base.is_jmp =3D DISAS_NORETURN; } =20 @@ -228,7 +239,7 @@ static void gen_exception_decode_fail(DisasContext *ctx= , int nwords, int excp) =20 gen_exec_counters(ctx); tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], fail_pc); - gen_exception_raw(excp); + gen_exception(excp, fail_pc); ctx->base.is_jmp =3D DISAS_NORETURN; ctx->base.pc_next =3D fail_pc; } --=20 2.34.1