On 9/17/26 14:42, Yonggang Luo wrote:
Add TCG raise_excp (env, exception, restore) that exits with GETPC()
or 0 via cpu_loop_exit_excp.
Signed-off-by: Yonggang Luo <[email protected]>
---
accel/tcg/tcg-runtime.c | 6 ++++++
accel/tcg/tcg-runtime.h | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 7c0aab98a80..ae93765b09e 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -130,6 +130,12 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg)
return ctpop64(arg);
}
+void HELPER(raise_excp)(CPUArchState *env, uint32_t exception,
+ uint32_t restore)
+{
+ cpu_loop_exit_excp(env_cpu(env), exception, restore ? GETPC() : 0);
+}
+
void HELPER(exit_atomic)(CPUArchState *env)
{
cpu_loop_exit_atomic(env_cpu(env), GETPC());
diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h
index 0b832176b33..036a33d566b 100644
--- a/accel/tcg/tcg-runtime.h
+++ b/accel/tcg/tcg-runtime.h
@@ -22,6 +22,17 @@ DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64)
DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env)
+/**
+ * raise_excp:
+ * @arg1: env -- CPU env
+ * @arg2: exception -- EXCP_* or target trap number
+ * @arg3: restore -- 0 skip unwind, 1 use GETPC()
+ *
+ * Shared TCG exception raise. Translate calls gen_helper_raise_excp.
+ * Exits via cpu_loop_exit_excp.
+ */
+DEF_HELPER_FLAGS_3(raise_excp, TCG_CALL_NO_WG, noreturn, env, i32, i32)
+
DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env)
#ifndef IN_HELPER_PROTO
(1) Put the comment before the implementation, not the header.
That avoids whatever you're concerned about vs patch 2.
(2) Don't pass an extra argument that changes behavior like this.
Better to have two separate functions, each doing one thing.
(3) Maybe better to place the functions in cpu-exec-common.c, so that
the compiler can see all the definitions at once.
r~