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_syscall_filter_cb
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-21-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
This commit is contained in:
@@ -863,6 +863,7 @@ typedef void
|
||||
* @a7: the 7th syscall argument
|
||||
* @a8: the 8th syscall argument
|
||||
* @sysret: reference of the syscall return value, must set this if filtered
|
||||
* @userdata: user data for callback
|
||||
*
|
||||
* Returns true if you want to filter this syscall (i.e. stop it being
|
||||
* handled further), otherwise returns false.
|
||||
@@ -872,7 +873,8 @@ typedef bool
|
||||
int64_t num, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5,
|
||||
uint64_t a6, uint64_t a7, uint64_t a8,
|
||||
uint64_t *sysret);
|
||||
uint64_t *sysret,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* typedef qemu_plugin_vcpu_syscall_ret_cb_t - vCPU syscall return callback
|
||||
@@ -906,6 +908,7 @@ void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
|
||||
* callback
|
||||
* @id: plugin id
|
||||
* @cb: callback of type qemu_plugin_vcpu_syscall_filter_cb_t
|
||||
* @userdata: user data for callback
|
||||
*
|
||||
* This registers a callback for every syscall executed by the guest. The @cb
|
||||
* function is executed before a syscall is handled by the host. If the
|
||||
@@ -916,7 +919,8 @@ void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
|
||||
QEMU_PLUGIN_API
|
||||
void
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id,
|
||||
qemu_plugin_vcpu_syscall_filter_cb_t cb);
|
||||
qemu_plugin_vcpu_syscall_filter_cb_t cb,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_vcpu_syscall_ret_cb() - register a syscall entry
|
||||
|
||||
@@ -217,9 +217,10 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id,
|
||||
|
||||
void
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id,
|
||||
qemu_plugin_vcpu_syscall_filter_cb_t cb)
|
||||
qemu_plugin_vcpu_syscall_filter_cb_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, cb);
|
||||
plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, cb, userdata);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -591,7 +591,7 @@ qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1,
|
||||
qemu_plugin_vcpu_syscall_filter_cb_t func = cb->f.vcpu_syscall_filter;
|
||||
|
||||
if (func(cpu->cpu_index, num, a1, a2, a3, a4,
|
||||
a5, a6, a7, a8, sysret)) {
|
||||
a5, a6, a7, a8, sysret, cb->udata)) {
|
||||
filtered = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
|
||||
int64_t num, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5,
|
||||
uint64_t a6, uint64_t a7, uint64_t a8,
|
||||
uint64_t *sysret)
|
||||
uint64_t *sysret, void *userdata)
|
||||
{
|
||||
if (num == MAGIC_SYSCALL) {
|
||||
if (a1 == SETPC) {
|
||||
@@ -99,7 +99,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
|
||||
int argc, char **argv)
|
||||
{
|
||||
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter, NULL);
|
||||
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
|
||||
int64_t num, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5,
|
||||
uint64_t a6, uint64_t a7, uint64_t a8,
|
||||
uint64_t *sysret)
|
||||
uint64_t *sysret, void *userdata)
|
||||
{
|
||||
/* Special syscall to test the filter functionality. */
|
||||
if (num == 4096 && a1 == 0x66CCFF) {
|
||||
@@ -274,7 +274,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
|
||||
|
||||
qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall, NULL);
|
||||
qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret);
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
|
||||
qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter, NULL);
|
||||
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user