mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
plugins: add inline operation per vcpu
Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Those functions takes a qemu_plugin_u64 as input. This allows to have a thread-safe and type-safe version of inline operations. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Message-Id: <20240304130036.124418-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240305121005.3528075-18-alex.bennee@linaro.org>
This commit is contained in:
parent
62f92b8d97
commit
0bcebaba45
7 changed files with 126 additions and 2 deletions
|
@ -332,6 +332,23 @@ void plugin_register_inline_op(GArray **arr,
|
|||
dyn_cb->inline_insn.imm = imm;
|
||||
}
|
||||
|
||||
void plugin_register_inline_op_on_entry(GArray **arr,
|
||||
enum qemu_plugin_mem_rw rw,
|
||||
enum qemu_plugin_op op,
|
||||
qemu_plugin_u64 entry,
|
||||
uint64_t imm)
|
||||
{
|
||||
struct qemu_plugin_dyn_cb *dyn_cb;
|
||||
|
||||
dyn_cb = plugin_get_dyn_cb(arr);
|
||||
dyn_cb->userp = NULL;
|
||||
dyn_cb->type = PLUGIN_CB_INLINE;
|
||||
dyn_cb->rw = rw;
|
||||
dyn_cb->inline_insn.entry = entry;
|
||||
dyn_cb->inline_insn.op = op;
|
||||
dyn_cb->inline_insn.imm = imm;
|
||||
}
|
||||
|
||||
void plugin_register_dyn_cb__udata(GArray **arr,
|
||||
qemu_plugin_vcpu_udata_cb_t cb,
|
||||
enum qemu_plugin_cb_flags flags,
|
||||
|
@ -480,6 +497,12 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index)
|
|||
char *ptr = cb->userp;
|
||||
size_t elem_size = 0;
|
||||
size_t offset = 0;
|
||||
if (!ptr) {
|
||||
/* use inline entry */
|
||||
ptr = cb->inline_insn.entry.score->data->data;
|
||||
elem_size = g_array_get_element_size(cb->inline_insn.entry.score->data);
|
||||
offset = cb->inline_insn.entry.offset;
|
||||
}
|
||||
uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size);
|
||||
|
||||
switch (cb->inline_insn.op) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue