aboutsummaryrefslogtreecommitdiff
path: root/plugins/core.c
diff options
context:
space:
mode:
authorPierrick Bouvier <pierrick.bouvier@linaro.org>2024-05-14 18:42:49 +0100
committerAlex Bennée <alex.bennee@linaro.org>2024-05-16 08:55:02 +0100
commit7de77d37880d7267a491cb32a1b2232017d1e545 (patch)
tree70d92e3875ebf046b953d163b1999310a30865b6 /plugins/core.c
parenta1c9bf2514d82b757288ee61584e667ddcb19a4f (diff)
plugins: conditional callbacks
Extend plugins API to support callback called with a given criteria (evaluated inline). Added functions: - qemu_plugin_register_vcpu_tb_exec_cond_cb - qemu_plugin_register_vcpu_insn_exec_cond_cb They expect as parameter a condition, a qemu_plugin_u64_t (op1) and an immediate (op2). Callback is called if op1 |cond| op2 is true. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Message-Id: <20240502211522.346467-6-pierrick.bouvier@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> [AJB: fix re-base conflict with tb_is_mem_only()] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240514174253.694591-8-alex.bennee@linaro.org>
Diffstat (limited to 'plugins/core.c')
-rw-r--r--plugins/core.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/core.c b/plugins/core.c
index 848d482fc4..332474a5bc 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -371,6 +371,38 @@ void plugin_register_dyn_cb__udata(GArray **arr,
dyn_cb->regular.info = &info[flags];
}
+void plugin_register_dyn_cond_cb__udata(GArray **arr,
+ qemu_plugin_vcpu_udata_cb_t cb,
+ enum qemu_plugin_cb_flags flags,
+ enum qemu_plugin_cond cond,
+ qemu_plugin_u64 entry,
+ uint64_t imm,
+ void *udata)
+{
+ static TCGHelperInfo info[3] = {
+ [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG,
+ [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG,
+ /*
+ * Match qemu_plugin_vcpu_udata_cb_t:
+ * void (*)(uint32_t, void *)
+ */
+ [0 ... 2].typemask = (dh_typemask(void, 0) |
+ dh_typemask(i32, 1) |
+ dh_typemask(ptr, 2))
+ };
+
+ struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr);
+ dyn_cb->userp = udata;
+ dyn_cb->type = PLUGIN_CB_COND;
+ dyn_cb->cond.f.vcpu_udata = cb;
+ dyn_cb->cond.cond = cond;
+ dyn_cb->cond.entry = entry;
+ dyn_cb->cond.imm = imm;
+
+ assert((unsigned)flags < ARRAY_SIZE(info));
+ dyn_cb->cond.info = &info[flags];
+}
+
void plugin_register_vcpu_mem_cb(GArray **arr,
void *cb,
enum qemu_plugin_cb_flags flags,