diff mbox series

[v2,12/14] plugins: register inline op with a qemu_plugin_u64_t

Message ID 20240118032400.3762658-13-pierrick.bouvier@linaro.org
State New
Headers show
Series TCG Plugin inline operation enhancement | expand

Commit Message

Pierrick Bouvier Jan. 18, 2024, 3:23 a.m. UTC
Now inline previous API was removed, we can cleanup code path
associated.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 accel/tcg/plugin-gen.c |  7 ++-----
 include/qemu/plugin.h  |  1 -
 plugins/api.c          | 12 +++---------
 plugins/core.c         | 17 ++++++-----------
 plugins/plugin.h       |  3 +--
 5 files changed, 12 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 1a2375d7779..5e4938805e8 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -439,11 +439,8 @@  static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb,
                                TCGOp *begin_op, TCGOp *op,
                                int *unused)
 {
-    char *ptr = cb->userp;
-    if (!cb->inline_direct_ptr) {
-        /* dereference userp once to get access to memory location */
-        ptr = *(char **)cb->userp;
-    }
+    /* always dereference userp for inline operations */
+    char *ptr = *(char **)cb->userp;
     op = copy_ld_i32(&begin_op, op);
     op = copy_mul_i32(&begin_op, op, cb->inline_element_size);
     op = copy_ext_i32_ptr(&begin_op, op);
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 5f340192e56..b63631207cd 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -88,7 +88,6 @@  struct qemu_plugin_dyn_cb {
     void *userp;
     size_t inline_offset;
     size_t inline_element_size;
-    bool inline_direct_ptr;
     enum plugin_dyn_cb_subtype type;
     /* @rw applies to mem callbacks only (both regular and inline) */
     enum qemu_plugin_mem_rw rw;
diff --git a/plugins/api.c b/plugins/api.c
index 29915d3c142..d12fed6118e 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -109,9 +109,7 @@  void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
 {
     if (!tb->mem_only) {
         plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE],
-                                  0, op, entry.score->data,
-                                  entry.offset, entry.score->element_size,
-                                  false, imm);
+                                  0, op, entry, imm);
     }
 }
 
@@ -138,9 +136,7 @@  void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
 {
     if (!insn->mem_only) {
         plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE],
-                                  0, op, entry.score->data,
-                                  entry.offset, entry.score->element_size,
-                                  false, imm);
+                                  0, op, entry, imm);
     }
 }
 
@@ -167,9 +163,7 @@  void qemu_plugin_register_vcpu_mem_inline_per_vcpu(
     uint64_t imm)
 {
     plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE],
-                              rw, op, entry.score->data,
-                              entry.offset, entry.score->element_size,
-                              false, imm);
+                              rw, op, entry, imm);
 }
 
 void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id,
diff --git a/plugins/core.c b/plugins/core.c
index 0286a127810..46175d557f7 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -347,17 +347,15 @@  static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr)
 void plugin_register_inline_op(GArray **arr,
                                enum qemu_plugin_mem_rw rw,
                                enum qemu_plugin_op op,
-                               void *ptr, size_t offset, size_t element_size,
-                               bool direct_ptr,
+                               qemu_plugin_u64_t entry,
                                uint64_t imm)
 {
     struct qemu_plugin_dyn_cb *dyn_cb;
 
     dyn_cb = plugin_get_dyn_cb(arr);
-    dyn_cb->userp = ptr;
-    dyn_cb->inline_element_size = element_size;
-    dyn_cb->inline_offset = offset;
-    dyn_cb->inline_direct_ptr = direct_ptr;
+    dyn_cb->userp = entry.score->data;
+    dyn_cb->inline_element_size = entry.score->element_size;
+    dyn_cb->inline_offset = entry.offset;
     dyn_cb->type = PLUGIN_CB_INLINE;
     dyn_cb->rw = rw;
     dyn_cb->inline_insn.op = op;
@@ -504,11 +502,8 @@  void qemu_plugin_flush_cb(void)
 
 void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index)
 {
-    char *ptr = cb->userp;
-    if (!cb->inline_direct_ptr) {
-        ptr = *(char **) cb->userp;
-    }
-    ptr += cb->inline_offset;
+    /* always dereference userp for inline operations */
+    char *ptr = (*(char **) cb->userp) + cb->inline_offset;
     uint64_t *val = (uint64_t *)(ptr + cpu_index * cb->inline_element_size);
 
     switch (cb->inline_insn.op) {
diff --git a/plugins/plugin.h b/plugins/plugin.h
index 99829c40886..4c8f2ca3728 100644
--- a/plugins/plugin.h
+++ b/plugins/plugin.h
@@ -71,8 +71,7 @@  struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id);
 void plugin_register_inline_op(GArray **arr,
                                enum qemu_plugin_mem_rw rw,
                                enum qemu_plugin_op op,
-                               void *ptr, size_t offset, size_t element_size,
-                               bool direct_ptr,
+                               qemu_plugin_u64_t entry,
                                uint64_t imm);
 
 void plugin_reset_uninstall(qemu_plugin_id_t id,