summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJulian Ganz <neither@nut.email>2025-10-27 11:03:16 +0000
committerAlex Bennée <alex.bennee@linaro.org>2025-10-29 14:12:43 +0000
commita1688bc86ce93ac0e006673766cd123eed43c02c (patch)
tree5cae40d8ea3b8c224dd7e1c9cf24a68b7e1d04b4 /plugins
parentaac73d85d2d6f556dbcee6041a2898cb0ef9b0e6 (diff)
downloadqemu-a1688bc86ce93ac0e006673766cd123eed43c02c.tar.gz
qemu-a1688bc86ce93ac0e006673766cd123eed43c02c.zip
plugins: add hooks for new discontinuity related callbacks
The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition, we recently introduced API for registering callbacks for discontinuity events, specifically for interrupts, exceptions and host calls. This change introduces the corresponding hooks called from target specific code inside qemu. Signed-off-by: Julian Ganz <neither@nut.email> Message-ID: <20251027110344.2289945-10-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/core.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/core.c b/plugins/core.c
index 40d001d39a..35a252d272 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -111,6 +111,30 @@ static void plugin_vcpu_cb__simple(CPUState *cpu, enum qemu_plugin_event ev)
* have type information
*/
QEMU_DISABLE_CFI
+static void plugin_vcpu_cb__discon(CPUState *cpu,
+ enum qemu_plugin_event ev,
+ enum qemu_plugin_discon_type type,
+ uint64_t from)
+{
+ struct qemu_plugin_cb *cb, *next;
+ uint64_t to = cpu->cc->get_pc(cpu);
+
+ if (cpu->cpu_index < plugin.num_vcpus) {
+ /* 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);
+ }
+ }
+}
+
+/*
+ * Disable CFI checks.
+ * The callback function has been loaded from an external library so we do not
+ * have type information
+ */
+QEMU_DISABLE_CFI
static void plugin_cb__simple(enum qemu_plugin_event ev)
{
struct qemu_plugin_cb *cb, *next;
@@ -557,6 +581,24 @@ void qemu_plugin_vcpu_resume_cb(CPUState *cpu)
}
}
+void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t from)
+{
+ plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_INTERRUPT,
+ QEMU_PLUGIN_DISCON_INTERRUPT, from);
+}
+
+void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from)
+{
+ plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_EXCEPTION,
+ QEMU_PLUGIN_DISCON_EXCEPTION, from);
+}
+
+void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from)
+{
+ plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_HOSTCALL,
+ QEMU_PLUGIN_DISCON_HOSTCALL, from);
+}
+
void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id,
qemu_plugin_vcpu_simple_cb_t cb)
{