From nobody Sun Dec 14 06:35:30 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1753604258; cv=none; d=zohomail.com; s=zohoarc; b=aFJT5kbO+cZ3N6Oip/eC+X42JAIvIeQvhQ7EK6kfCOvHFQsfuqv0hDQSx8cVbEJFGma3ONdTCzBOd7IgYcULAjIsmElPgil8rd5QQZJJusQV6JY2MTasyVCuIibZ1ZGWshFfzHPFDcj8pV+leqM8U0Tr+EJnbwlYsSZn+n5HHj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604258; 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=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=Fa/+wMc6hDqxteDMOsMc2VdLuf1jSw8JW9vhf33EzjajIXfeVUb/RSRzfXOw4DDJhhgSHa9+CH8YklprrjK9PIxo61ckElGAiqlCqoP5dSGsBXH1CuDIMUi0eM/EHm4xfTUzb1XYF28r0edIK6+50txMjzsTI6RH/Plg6iwMs3c= 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 1753604258988467.20784288038215; Sun, 27 Jul 2025 01:17:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPm-0003wa-LU; Sun, 27 Jul 2025 04:07:27 -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 1ufwPO-0001ov-UQ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:03 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPM-0004ki-TT for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:02 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2350b1b9129so23722765ad.0 for ; Sun, 27 Jul 2025 01:07:00 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603619; x=1754208419; 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=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=rYMRsGyWEpPMC4XMooCswj/1+kIt7klBQYVBamYDf9FzpN9jyneWoxvd8/cLuHaiPo NSKJORIeEz41EuTWNunTpWYXxfAmdCD5gXTkCCClhUOPG2MvkUi3RN5GH1qqmP1iEVM7 V2zHJ1WXkwPoOHQ8QnZXhCaGaNuuwFzVQ27LoLwWG1LfWBhfasbK1hIG+U0EqxZphth0 V3M/lcux1qIbEkOVTlRprEDBDx7efajnJ4onH5OruKsFQKXrd0f33sFsTB2I9j/4C9tA Pt+Mtu7Q/IroIGtfGFc8e411f4Y76Llk1mQM7Do/sshSniutzU/ASN4kLPFwiLuPgr8D 57ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603619; x=1754208419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=eSgHfkV2bt4py+/3eMtHRxpRHscEX3fdZ64XZ+wlwRThwPUMmn86o0zsSaT2H0RwcO kICbABjzH850ImU78QATdi7zpAQcBWLwYzCs09u/dF5vKw+qmG2k97ie/UbEVuzqQlyV 4XYDJPZsa4rsHch69oQ7gmmgalc5cPtVyCeujzQBV7X8z4dOUalqL4sKvL7EJmYFaBdV zsu/KMgqx0VcmKN4DHCljmqury57cxGjA553UX5WV/RTtg21ThfRjpWaZjskfF19W0kq zOcibyGJ3NlWl61sw9XT56FuGEnpSX3X9i7aBA4tPvImVnVM16dgnbExTSE6gnImU/Jn aoaA== X-Gm-Message-State: AOJu0YxQZDW04rAKJyn0vCUfH6KU6n/gB5pMHyMjjf47OJ6TvpqMyFIN TqZ1gYnItfxDaZEJSiWGtTv3XYVBRSmvEsElvtPOO5Y9h8XgnCg2s3+WIc06ix62AeXLZAIa7Ty g2ZsC X-Gm-Gg: ASbGncsKJHeKnP9u/06G7LBKQK4fvHS+jmAzL7c+IOkRwk49ce1g0EyqQhL5Wrbuu/X q5KeS6SbrvyZcYbOyPO8XJzr//GyHrDWq2iGg4AuFiMtlD60bZHQpQdptGH+YEBLE3XGlXX+ikq uFHO5vHVEZp4vmCldKTTx2o6hPmnXvtm/A8y2q5QN3aEfpEvtRok2wIeLzhx9F0E4XrTCfNy03X jDhp1P42WhCPapi47d0FbTx9uD3GHaDRfw8GOWwzBlPJi3iQZlcoMdkv7doFFH2c7YnjlTWE03Q NfDrq6yXzxaaJeB6qRexGHJasXLaoSLMP+JDVMoT8ZTqmoVvCu/FSYET+PJy95rX7NPqktYM73r XhN/NN0qexADN8kXwMvmysdw5PZnuUDZaL6MRy1QKzbbxfr6PKl11fHB7m6gr29LBkzCqnHBhSa BuYPTICr96XA== X-Google-Smtp-Source: AGHT+IHfTSQ9wxp+4X1iKjflsCFlCHe/KKq9Gu7Meweg8oD37rB/f0IOs+R+RL1AYj4sJfR08BwFGA== X-Received: by 2002:a17:903:198d:b0:237:cadf:9aac with SMTP id d9443c01a7336-23fb30b2b1emr140422835ad.29.1753603619447; Sun, 27 Jul 2025 01:06:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 51/82] target/arm: Introduce delay_exception{_el} Date: Sat, 26 Jul 2025 22:02:23 -1000 Message-ID: <20250727080254.83840-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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=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: 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 @linaro.org) X-ZM-MESSAGEID: 1753604260388116600 Content-Type: text/plain; charset="utf-8" Add infrastructure to raise an exception out of line. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate.h | 20 +++++++++++++ target/arm/tcg/translate-a64.c | 2 ++ target/arm/tcg/translate.c | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 1479f5bf74..a40cbd4479 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -21,9 +21,25 @@ typedef struct DisasLabel { target_ulong pc_save; } DisasLabel; =20 +/* + * Emit an exception call out of line. + */ +typedef struct DisasDelayException { + struct DisasDelayException *next; + TCGLabel *lab; + target_long pc_curr; + target_long pc_save; + int condexec_mask; + int condexec_cond; + uint32_t excp; + uint32_t syn; + uint32_t target_el; +} DisasDelayException; + typedef struct DisasContext { DisasContextBase base; const ARMISARegisters *isar; + DisasDelayException *delay_excp_list; =20 /* The address of the current instruction being translated. */ target_ulong pc_curr; @@ -365,6 +381,10 @@ void gen_exception_insn_el(DisasContext *s, target_lon= g pc_diff, int excp, uint32_t syn, uint32_t target_el); void gen_exception_insn(DisasContext *s, target_long pc_diff, int excp, uint32_t syn); +TCGLabel *delay_exception_el(DisasContext *s, int excp, + uint32_t syn, uint32_t target_el); +TCGLabel *delay_exception(DisasContext *s, int excp, uint32_t syn); +void emit_delayed_exceptions(DisasContext *s); =20 /* Return state of Alternate Half-precision flag, caller frees result */ static inline TCGv_i32 get_ahp_flag(void) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index eaeafdf138..d803c10ac7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -10411,6 +10411,8 @@ static void aarch64_tr_tb_stop(DisasContextBase *dc= base, CPUState *cpu) break; } } + + emit_delayed_exceptions(dc); } =20 const TranslatorOps aarch64_translator_ops =3D { diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index f7d6d8ce19..c4dd3a747c 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -1090,6 +1090,57 @@ void gen_exception_insn(DisasContext *s, target_long= pc_diff, s->base.is_jmp =3D DISAS_NORETURN; } =20 +TCGLabel *delay_exception_el(DisasContext *s, int excp, + uint32_t syn, uint32_t target_el) +{ + /* Use tcg_malloc for automatic release on longjmp out of translation.= */ + DisasDelayException *e =3D tcg_malloc(sizeof(DisasDelayException)); + + memset(e, 0, sizeof(*e)); + + /* Save enough of the current state to satisfy gen_exception_insn. */ + e->pc_curr =3D s->pc_curr; + e->pc_save =3D s->pc_save; + if (!s->aarch64) { + e->condexec_cond =3D s->condexec_cond; + e->condexec_mask =3D s->condexec_mask; + } + + e->excp =3D excp; + e->syn =3D syn; + e->target_el =3D target_el; + + e->next =3D s->delay_excp_list; + s->delay_excp_list =3D e; + + e->lab =3D gen_new_label(); + return e->lab; +} + +TCGLabel *delay_exception(DisasContext *s, int excp, uint32_t syn) +{ + return delay_exception_el(s, excp, syn, 0); +} + +void emit_delayed_exceptions(DisasContext *s) +{ + for (DisasDelayException *e =3D s->delay_excp_list; e ; e =3D e->next)= { + gen_set_label(e->lab); + + /* Restore the insn state to satisfy gen_exception_insn. */ + s->pc_curr =3D e->pc_curr; + s->pc_save =3D e->pc_save; + s->condexec_cond =3D e->condexec_cond; + s->condexec_mask =3D e->condexec_mask; + + if (e->target_el) { + gen_exception_insn_el(s, 0, e->excp, e->syn, e->target_el); + } else { + gen_exception_insn(s, 0, e->excp, e->syn); + } + } +} + static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) { gen_set_condexec(s); @@ -8107,6 +8158,8 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, = CPUState *cpu) gen_goto_tb(dc, 1, curr_insn_len(dc)); } } + + emit_delayed_exceptions(dc); } =20 static const TranslatorOps arm_translator_ops =3D { --=20 2.43.0