[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/35] tcg: exclude non-memory effecting helpers from instrumentat
From: |
Alex Bennée |
Subject: |
[PULL 33/35] tcg: exclude non-memory effecting helpers from instrumentation |
Date: |
Thu, 26 Jan 2023 11:22:48 +0000 |
From: Emilio Cota <cota@braap.org>
There are actually a whole bunch of helpers that don't affect memory
that we shouldn't instrument. They are helpfully identified by the
TCG_CALL_NO_SIDE_EFFECTS flag which marks out lookup_tb_ptr as well as
a lot of the maths helpers. To avoid the string compare we introduce a
new flag for plugin internals so we skip that too.
Related: #1381
Signed-off-by: Emilio Cota <cota@braap.org>
Message-Id: <20230108164731.61469-4-cota@braap.org>
[AJB: updated to skip all no SE plugins, add flag for plugin helper]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230124180127.1881110-34-alex.bennee@linaro.org>
diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h
index 9829abe4a9..8e685e0654 100644
--- a/accel/tcg/plugin-helpers.h
+++ b/accel/tcg/plugin-helpers.h
@@ -1,4 +1,4 @@
#ifdef CONFIG_PLUGIN
-DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb, TCG_CALL_NO_RWG, void, i32, ptr)
-DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG, void, i32, i32, i64,
ptr)
+DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN,
void, i32, ptr)
+DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN,
void, i32, i32, i64, ptr)
#endif
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 6f497172f8..8dc291d030 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -405,6 +405,8 @@ typedef TCGv_ptr TCGv_env;
#define TCG_CALL_NO_SIDE_EFFECTS 0x0004
/* Helper is G_NORETURN. */
#define TCG_CALL_NO_RETURN 0x0008
+/* Helper is part of Plugins. */
+#define TCG_CALL_PLUGIN 0x0010
/* convenience version of most used call flags */
#define TCG_CALL_NO_RWG TCG_CALL_NO_READ_GLOBALS
diff --git a/tcg/tcg.c b/tcg/tcg.c
index d502327be2..fd557d55d3 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1674,8 +1674,10 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs,
TCGTemp **args)
op = tcg_op_alloc(INDEX_op_call, total_args);
#ifdef CONFIG_PLUGIN
- /* detect non-plugin helpers */
- if (tcg_ctx->plugin_insn && unlikely(strncmp(info->name, "plugin_", 7))) {
+ /* Flag helpers that may affect guest state */
+ if (tcg_ctx->plugin_insn &&
+ !(info->flags & TCG_CALL_PLUGIN) &&
+ !(info->flags & TCG_CALL_NO_SIDE_EFFECTS)) {
tcg_ctx->plugin_insn->calls_helpers = true;
}
#endif
--
2.34.1
- [PULL 26/35] cpu: free cpu->tb_jmp_cache with RCU, (continued)
- [PULL 26/35] cpu: free cpu->tb_jmp_cache with RCU, Alex Bennée, 2023/01/26
- [PULL 34/35] cpu-exec: assert that plugin_mem_cbs is NULL after execution, Alex Bennée, 2023/01/26
- [PULL 32/35] translator: always pair plugin_gen_insn_{start, end} calls, Alex Bennée, 2023/01/26
- [PULL 31/35] plugins: fix optimization in plugin_gen_disable_mem_helpers, Alex Bennée, 2023/01/26
- [PULL 24/35] semihosting: add O_BINARY flag in host_open for NT compatibility, Alex Bennée, 2023/01/26
- [PULL 23/35] semihosting: Write back semihosting data before completion callback, Alex Bennée, 2023/01/26
- [PULL 19/35] docs: add hotlinks to about preface text, Alex Bennée, 2023/01/26
- [PULL 35/35] plugins: Iterate on cb_lists in qemu_plugin_user_exit, Alex Bennée, 2023/01/26
- [PULL 27/35] util/qht: add missing atomic_set(hashes[i]), Alex Bennée, 2023/01/26
- [PULL 21/35] semihosting: add semihosting section to the docs, Alex Bennée, 2023/01/26
- [PULL 33/35] tcg: exclude non-memory effecting helpers from instrumentation,
Alex Bennée <=
- [PULL 22/35] docs: add an introduction to the system docs, Alex Bennée, 2023/01/26
- [PULL 25/35] tests/tcg: add memory-sve test for aarch64, Alex Bennée, 2023/01/26