mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
plugins: add userdata to qemu_plugin_register_vcpu_discon_cb
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-14-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
This commit is contained in:
@@ -25,7 +25,7 @@ static struct qemu_plugin_scoreboard *traps;
|
||||
|
||||
static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index,
|
||||
enum qemu_plugin_discon_type type, uint64_t from_pc,
|
||||
uint64_t to_pc)
|
||||
uint64_t to_pc, void *userdata)
|
||||
{
|
||||
TrapCounters *rec = qemu_plugin_scoreboard_find(traps, vcpu_index);
|
||||
switch (type) {
|
||||
@@ -75,7 +75,8 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
|
||||
traps = qemu_plugin_scoreboard_new(sizeof(TrapCounters));
|
||||
|
||||
qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL,
|
||||
vcpu_discon);
|
||||
vcpu_discon,
|
||||
NULL);
|
||||
|
||||
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
|
||||
|
||||
|
||||
@@ -186,6 +186,7 @@ enum qemu_plugin_discon_type {
|
||||
* @from_pc: the source of the discontinuity, e.g. the PC before the
|
||||
* transition
|
||||
* @to_pc: the PC pointing to the next instruction to be executed
|
||||
* @userdata: any plugin data to pass to the @cb
|
||||
*
|
||||
* The exact semantics of @from_pc depends on the @type of discontinuity. For
|
||||
* interrupts, @from_pc will point to the next instruction which would have
|
||||
@@ -198,7 +199,8 @@ enum qemu_plugin_discon_type {
|
||||
typedef void (*qemu_plugin_vcpu_discon_cb_t)(qemu_plugin_id_t id,
|
||||
unsigned int vcpu_index,
|
||||
enum qemu_plugin_discon_type type,
|
||||
uint64_t from_pc, uint64_t to_pc);
|
||||
uint64_t from_pc, uint64_t to_pc,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_uninstall() - Uninstall a plugin
|
||||
@@ -293,6 +295,7 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,
|
||||
* @id: plugin ID
|
||||
* @type: types of discontinuities for which to call the callback
|
||||
* @cb: callback function
|
||||
* @userdata: any plugin data to pass to the @cb
|
||||
*
|
||||
* The @cb function is called every time a vCPU receives a discontinuity event
|
||||
* of the specified type(s), after the vCPU was prepared to handle the event.
|
||||
@@ -302,7 +305,8 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id,
|
||||
enum qemu_plugin_discon_type type,
|
||||
qemu_plugin_vcpu_discon_cb_t cb);
|
||||
qemu_plugin_vcpu_discon_cb_t cb,
|
||||
void *userdata);
|
||||
|
||||
/** struct qemu_plugin_tb - Opaque handle for a translation block */
|
||||
struct qemu_plugin_tb;
|
||||
|
||||
@@ -122,8 +122,7 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
|
||||
/* iterate safely; plugins might uninstall themselves at any time */
|
||||
QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
|
||||
qemu_plugin_vcpu_discon_cb_t func = cb->f.vcpu_discon;
|
||||
|
||||
func(cb->ctx->id, cpu->cpu_index, type, from, to);
|
||||
func(cb->ctx->id, cpu->cpu_index, type, from, to, cb->udata);
|
||||
}
|
||||
}
|
||||
qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
|
||||
@@ -656,16 +655,17 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,
|
||||
|
||||
void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id,
|
||||
enum qemu_plugin_discon_type type,
|
||||
qemu_plugin_vcpu_discon_cb_t cb)
|
||||
qemu_plugin_vcpu_discon_cb_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
if (type & QEMU_PLUGIN_DISCON_INTERRUPT) {
|
||||
plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb);
|
||||
plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb, userdata);
|
||||
}
|
||||
if (type & QEMU_PLUGIN_DISCON_EXCEPTION) {
|
||||
plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb);
|
||||
plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb, userdata);
|
||||
}
|
||||
if (type & QEMU_PLUGIN_DISCON_HOSTCALL) {
|
||||
plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb);
|
||||
plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb, userdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ static void report_mismatch(const char *pc_name, unsigned int vcpu_index,
|
||||
|
||||
static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index,
|
||||
enum qemu_plugin_discon_type type, uint64_t from_pc,
|
||||
uint64_t to_pc)
|
||||
uint64_t to_pc, void *userdata)
|
||||
{
|
||||
struct cpu_state *state = qemu_plugin_scoreboard_find(states, vcpu_index);
|
||||
|
||||
@@ -214,7 +214,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
|
||||
has_from);
|
||||
|
||||
qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL,
|
||||
vcpu_discon);
|
||||
vcpu_discon, NULL);
|
||||
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user