mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-22 23:48:36 -07:00
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>
This commit is contained in:
parent
a1c9bf2514
commit
7de77d3788
7 changed files with 213 additions and 0 deletions
|
|
@ -262,6 +262,29 @@ enum qemu_plugin_mem_rw {
|
|||
QEMU_PLUGIN_MEM_RW,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum qemu_plugin_cond - condition to enable callback
|
||||
*
|
||||
* @QEMU_PLUGIN_COND_NEVER: false
|
||||
* @QEMU_PLUGIN_COND_ALWAYS: true
|
||||
* @QEMU_PLUGIN_COND_EQ: is equal?
|
||||
* @QEMU_PLUGIN_COND_NE: is not equal?
|
||||
* @QEMU_PLUGIN_COND_LT: is less than?
|
||||
* @QEMU_PLUGIN_COND_LE: is less than or equal?
|
||||
* @QEMU_PLUGIN_COND_GT: is greater than?
|
||||
* @QEMU_PLUGIN_COND_GE: is greater than or equal?
|
||||
*/
|
||||
enum qemu_plugin_cond {
|
||||
QEMU_PLUGIN_COND_NEVER,
|
||||
QEMU_PLUGIN_COND_ALWAYS,
|
||||
QEMU_PLUGIN_COND_EQ,
|
||||
QEMU_PLUGIN_COND_NE,
|
||||
QEMU_PLUGIN_COND_LT,
|
||||
QEMU_PLUGIN_COND_LE,
|
||||
QEMU_PLUGIN_COND_GT,
|
||||
QEMU_PLUGIN_COND_GE,
|
||||
};
|
||||
|
||||
/**
|
||||
* typedef qemu_plugin_vcpu_tb_trans_cb_t - translation callback
|
||||
* @id: unique plugin id
|
||||
|
|
@ -301,6 +324,32 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb,
|
|||
enum qemu_plugin_cb_flags flags,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_vcpu_tb_exec_cond_cb() - register conditional callback
|
||||
* @tb: the opaque qemu_plugin_tb handle for the translation
|
||||
* @cb: callback function
|
||||
* @cond: condition to enable callback
|
||||
* @entry: first operand for condition
|
||||
* @imm: second operand for condition
|
||||
* @flags: does the plugin read or write the CPU's registers?
|
||||
* @userdata: any plugin data to pass to the @cb?
|
||||
*
|
||||
* The @cb function is called when a translated unit executes if
|
||||
* entry @cond imm is true.
|
||||
* If condition is QEMU_PLUGIN_COND_ALWAYS, condition is never interpreted and
|
||||
* this function is equivalent to qemu_plugin_register_vcpu_tb_exec_cb.
|
||||
* If condition QEMU_PLUGIN_COND_NEVER, condition is never interpreted and
|
||||
* callback is never installed.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_register_vcpu_tb_exec_cond_cb(struct qemu_plugin_tb *tb,
|
||||
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 *userdata);
|
||||
|
||||
/**
|
||||
* enum qemu_plugin_op - describes an inline op
|
||||
*
|
||||
|
|
@ -344,6 +393,33 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn,
|
|||
enum qemu_plugin_cb_flags flags,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_vcpu_insn_exec_cond_cb() - conditional insn execution cb
|
||||
* @insn: the opaque qemu_plugin_insn handle for an instruction
|
||||
* @cb: callback function
|
||||
* @flags: does the plugin read or write the CPU's registers?
|
||||
* @cond: condition to enable callback
|
||||
* @entry: first operand for condition
|
||||
* @imm: second operand for condition
|
||||
* @userdata: any plugin data to pass to the @cb?
|
||||
*
|
||||
* The @cb function is called when an instruction executes if
|
||||
* entry @cond imm is true.
|
||||
* If condition is QEMU_PLUGIN_COND_ALWAYS, condition is never interpreted and
|
||||
* this function is equivalent to qemu_plugin_register_vcpu_insn_exec_cb.
|
||||
* If condition QEMU_PLUGIN_COND_NEVER, condition is never interpreted and
|
||||
* callback is never installed.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_register_vcpu_insn_exec_cond_cb(
|
||||
struct qemu_plugin_insn *insn,
|
||||
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 *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op
|
||||
* @insn: the opaque qemu_plugin_insn handle for an instruction
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue