Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BDC35CA5FE0 for ; Fri, 2 Oct 2026 17:53:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xChRw-0005Ur-3q; Fri, 02 Oct 2026 13:53:44 -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 1xChQT-0004Kd-6w for qemu-riscv@nongnu.org; Fri, 02 Oct 2026 13:52:06 -0400 Received: from mail-dl2-x0d.google.com ([2607:f8b0:4864:38::d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xChQP-0007T8-E5 for qemu-riscv@nongnu.org; Fri, 02 Oct 2026 13:52:04 -0400 Received: by mail-dl2-x0d.google.com with SMTP id a92af1059eb24-148b5c829e8so6498134c88.0 for ; Fri, 02 Oct 2026 10:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790963520; x=1791568320; 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=y/3BzewNHHqU34EleAU1q6MHo4NgKn6+G6D1GFCx46I=; b=IBzgNP/n57TiHf1rc7QhfcafTlQlny5MRPMI61AiGOZr9YeOXDif9f65f19rZd6SNj i8zk3VsSg8TIRD6ATit3D715/OApLTl8g9uFUnOR4ZVsRxR0pmoX+pizi8MNHjz3FUl8 XPp2PQ9/k4i/xPFIzD/jGVMw4pJ/OyNWSBe++ucRW/KASv+FUOWDUL0qZ+mryfEcceqP C3S2xknrpmwlZ708JFltW2px7bMHFjYuQBfgH6ne07QBGpRnk+J3vwbj2qL+Cj5s8TVA pmuJ/5/sVNAWpNAvNVt1Tgma897or3AZnybPldQpruKGqiIYiaGBQDiwBMnoHW9jz5GG OydA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790963520; x=1791568320; 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=y/3BzewNHHqU34EleAU1q6MHo4NgKn6+G6D1GFCx46I=; b=S9fbSa67DDeNHn16EcW/Nwkb/qQDJIKNonm/D2v9IIYqr1h6n0Qb8di/eqB8/K5BGy rFx2NcG0SIl6MUydvkzh88iti7+N2DZFcQvWbXRaYeDqxwoR0aVQND9ndq+PCCJrCH8A MOfTIdMJqKxz5faJ9y/Wy1rumLoTVcske/ZPW3wubYJ/4onVn47SsoZi5iUkHzF76Yu1 fRqiBpaXh95x8k7BzLmy6L0m7qJjEJvIb1S8L/N2AyplG3OxiETj8Ii5bR+tTPTbvk9g 19xLY44MUN3+QU+IyIuEn3dlk/KIVibBxWgVylmtimr6qJxVwBcow+GIiDBBwtXEWWd4 FRsw== X-Forwarded-Encrypted: i=1; AKwUvBxb5f20xdGUsOxPdrU4DGQdqXrcRwyW1A30DdIXKHTvUs7ONGoqER5JP56qFEQFNI3qFG12VA+VpxQm@nongnu.org X-Gm-Message-State: AFuF++nag2Sv40/QYeV7qHMTnENNmyZKxIxKrPFIp4wnTyJbAIV5xWln qxkMpf0L/PSMsqAlgbc+c/QhUoi8wIKH0MnqgfDkZ4qMyD+Z+2WXR2mx X-Gm-Gg: AYBFou1lafdmUdK/w3VG3M1jc4upi/3ExOlr130hlKDJVZnX4+GrUnmGzy9gwGGCrNR dzTAyUvYbBcJNdWP0NdNhuZ4zQuX990sQgQ+/FecBqKqHT5QN3sLyNOop4GZXCli3mB+LlvrEXO gRZbeTEADZP5U477yXA0HrD54Pb/k3le7ofzAn4TuK2YSkI97jThPZbr0qDu5xs9LAdvtTHLxNL 9MtafHAT9laQTQnoQjUHvrLm5Ugsj74zWTfLvDxP0tayXZFvurj1fcMjiDFUxLuMFMLAsj1UVIE WrS2V84GJ0v6sdZ4Yp8cRg5Lfgf9zTv2IlmOwqNpv+zbMwq1JKPJnRDoJ0My/iT8HbzY9mfswtK ReJTBIKuag27xHaMM22JJnSANC2oKxvTvQ8Js2Wv/BShMyJv9CqJmEt3TwelbEeLyJTSbciPLRE 0muqrR0exS7z0BhcSwsbtQTEUu4slhoijbDWPvB8NPR7VAbfsDJaS0hjpRfVYtdsUVzmlEQjO1j Jhj1fylGdcNZSsS7Ngy1SBeMDxmzzM= X-Received: by 2002:a05:7022:eb47:20b0:14d:baf5:c419 with SMTP id a92af1059eb24-14f58de5556mr3709348c88.6.1790963520018; Fri, 02 Oct 2026 10:52:00 -0700 (PDT) Received: from WIN-BH9M8FJACR9 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-34f14f9f2afsm18027361eec.18.2026.10.02.10.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 10:51:59 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Max Filippov , Stafford Horne , Brian Cain , Eric Farman , Song Gao <17746591750@163.com>, qemu-riscv@nongnu.org, Pierrick Bouvier , Aleksandar Rikalo , qemu-s390x@nongnu.org, Palmer Dabbelt , Alistair Francis , Philippe Mathieu-Daude , Mark Cave-Ayland , Michael Rolnik , Harsh Prateek Bora , Nicholas Piggin , Cornelia Huck , Helge Deller , Chinmay Rath , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Peter Maydell , Chao Liu , Aurelien Jarno , Richard Henderson , David Hildenbrand , "Edgar E. Iglesias" , Daniel Henrique Barboza , Weiwei Li , Yoshinori Sato , Artyom Tarasenko , Matthew Rosato , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , Glenn Miles , Ilya Leoshkevich Subject: [PATCH v3 09/27] target/rx: convert raises to raise_excp Date: Sat, 3 Oct 2026 01:50:17 +0800 Message-ID: <20261002175037.1747-10-luoyonggang@gmail.com> X-Mailer: git-send-email 2.52.0.windows.1 In-Reply-To: <20261002175037.1747-1-luoyonggang@gmail.com> References: <20261002175037.1747-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:38::d; envelope-from=luoyonggang@gmail.com; helo=mail-dl2-x0d.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@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-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Translate privilege and illegal instructions through the shared exception helpers, and use them for BRK, INT, FPSW, and WAIT paths where applicable. Remove the redundant RX exception helpers. Signed-off-by: Yonggang Luo --- target/rx/helper.h | 4 ---- target/rx/op_helper.c | 39 ++------------------------------------- target/rx/translate.c | 9 ++++++--- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/target/rx/helper.h b/target/rx/helper.h index f3897ce7619..c6a85e968d9 100644 --- a/target/rx/helper.h +++ b/target/rx/helper.h @@ -1,8 +1,4 @@ -DEF_HELPER_1(raise_illegal_instruction, noreturn, env) -DEF_HELPER_1(raise_access_fault, noreturn, env) -DEF_HELPER_1(raise_privilege_violation, noreturn, env) DEF_HELPER_1(wait, noreturn, env) -DEF_HELPER_2(trap, noreturn, env, i32) DEF_HELPER_3(fadd, f32, env, f32, f32) DEF_HELPER_3(fsub, f32, env, f32, f32) DEF_HELPER_3(fmul, f32, env, f32, f32) diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c index d4e9ac2f192..ccd20c43a62 100644 --- a/target/rx/op_helper.c +++ b/target/rx/op_helper.c @@ -25,10 +25,6 @@ #include "fpu/softfloat.h" #include "tcg/debug-assert.h" -static inline G_NORETURN -void raise_exception(CPURXState *env, int index, - uintptr_t retaddr); - static void _set_psw(CPURXState *env, uint32_t psw, uint32_t rte) { uint32_t prev_u; @@ -115,7 +111,7 @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr) enable = FIELD_EX32(env->fpsw, FPSW, ENABLE); enable |= 1 << 5; /* CE always enabled */ if (cause & enable) { - raise_exception(env, RX_EXCP_ACCESS, retaddr); + cpu_raise_excp_restore(env_cpu(env), RX_EXCP_ACCESS, retaddr); } } } @@ -419,32 +415,6 @@ uint32_t helper_divu(CPURXState *env, uint32_t num, uint32_t den) return ret; } -/* exception */ -static inline G_NORETURN -void raise_exception(CPURXState *env, int index, - uintptr_t retaddr) -{ - CPUState *cs = env_cpu(env); - - cs->exception_index = index; - cpu_loop_exit_restore(cs, retaddr); -} - -G_NORETURN void helper_raise_privilege_violation(CPURXState *env) -{ - raise_exception(env, RX_EXCP_PRIVILEGE_VIOLATION, GETPC()); -} - -G_NORETURN void helper_raise_access_fault(CPURXState *env) -{ - raise_exception(env, RX_EXCP_ACCESS, GETPC()); -} - -G_NORETURN void helper_raise_illegal_instruction(CPURXState *env) -{ - raise_exception(env, RX_EXCP_ILLEGAL_INSTRUCTION, GETPC()); -} - G_NORETURN void helper_wait(CPURXState *env) { CPUState *cs = env_cpu(env); @@ -452,10 +422,5 @@ G_NORETURN void helper_wait(CPURXState *env) cs->halted = 1; env->in_sleep = 1; env->psw_i = 1; - raise_exception(env, EXCP_HLT, 0); -} - -G_NORETURN void helper_trap(CPURXState *env, uint32_t vec) -{ - raise_exception(env, RX_EXCP_TRAP_BASE + vec, 0); + cpu_raise_excp(env_cpu(env), EXCP_HLT); } diff --git a/target/rx/translate.c b/target/rx/translate.c index 1bacc7adf92..e6541ad0ab8 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -245,7 +245,8 @@ static int is_privileged(DisasContext *ctx, int is_exception) { if (FIELD_EX32(ctx->tb_flags, PSW, PM)) { if (is_exception) { - gen_helper_raise_privilege_violation(tcg_env); + gen_helper_raise_excp_restore( + tcg_env, tcg_constant_i32(RX_EXCP_PRIVILEGE_VIOLATION)); } return 0; } else { @@ -2173,7 +2174,8 @@ static bool trans_RTE(DisasContext *ctx, arg_RTE *a) static bool do_trap(DisasContext *ctx, uint8_t vec) { tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next); - gen_helper_trap(tcg_env, tcg_constant_i32(vec)); + gen_helper_raise_excp( + tcg_env, tcg_constant_i32(RX_EXCP_TRAP_BASE + vec)); ctx->base.is_jmp = DISAS_NORETURN; return true; } @@ -2227,7 +2229,8 @@ static void rx_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) ctx->pc = ctx->base.pc_next; insn = decode_load(ctx); if (!decode(ctx, insn)) { - gen_helper_raise_illegal_instruction(tcg_env); + gen_helper_raise_excp_restore( + tcg_env, tcg_constant_i32(RX_EXCP_ILLEGAL_INSTRUCTION)); } } -- 2.52.0.windows.1