[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 20/54] cpu: hook plugin vcpu events
From: |
Alex Bennée |
Subject: |
[PATCH v6 20/54] cpu: hook plugin vcpu events |
Date: |
Thu, 17 Oct 2019 14:15:41 +0100 |
From: "Emilio G. Cota" <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
---
cpus.c | 10 ++++++++++
exec.c | 2 ++
hw/core/cpu.c | 2 ++
3 files changed, 14 insertions(+)
diff --git a/cpus.c b/cpus.c
index 367f0657c5..cdd2798c0a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -45,6 +45,7 @@
#include "exec/exec-all.h"
#include "qemu/thread.h"
+#include "qemu/plugin.h"
#include "sysemu/cpus.h"
#include "sysemu/qtest.h"
#include "qemu/main-loop.h"
@@ -1254,9 +1255,18 @@ static void qemu_tcg_rr_wait_io_event(void)
static void qemu_wait_io_event(CPUState *cpu)
{
+ bool slept = false;
+
while (cpu_thread_is_idle(cpu)) {
+ if (!slept) {
+ slept = true;
+ qemu_plugin_vcpu_idle_cb(cpu);
+ }
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
}
+ if (slept) {
+ qemu_plugin_vcpu_resume_cb(cpu);
+ }
#ifdef _WIN32
/* Eat dummy APC queued by qemu_cpu_kick_thread. */
diff --git a/exec.c b/exec.c
index fb0943cfed..1feda0ca76 100644
--- a/exec.c
+++ b/exec.c
@@ -975,6 +975,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
}
tlb_init(cpu);
+ qemu_plugin_vcpu_init_hook(cpu);
+
#ifndef CONFIG_USER_ONLY
if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu);
diff --git a/hw/core/cpu.c b/hw/core/cpu.c
index 73b1ee34d0..db1a03c6bb 100644
--- a/hw/core/cpu.c
+++ b/hw/core/cpu.c
@@ -32,6 +32,7 @@
#include "hw/boards.h"
#include "hw/qdev-properties.h"
#include "trace-root.h"
+#include "qemu/plugin.h"
CPUInterruptHandler cpu_interrupt_handler;
@@ -352,6 +353,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Error
**errp)
CPUState *cpu = CPU(dev);
/* NOTE: latest generic point before the cpu is fully unrealized */
trace_fini_vcpu(cpu);
+ qemu_plugin_vcpu_exit_hook(cpu);
cpu_exec_unrealizefn(cpu);
}
--
2.20.1
- [PATCH v6 34/54] translator: inject instrumentation from plugins, (continued)
- [PATCH v6 34/54] translator: inject instrumentation from plugins, Alex Bennée, 2019/10/17
- [PATCH v6 26/54] target/i386: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 15/54] tcg: let plugins instrument virtual memory accesses, Alex Bennée, 2019/10/17
- [PATCH v6 14/54] atomic_template: add inline trace/plugin helpers, Alex Bennée, 2019/10/17
- [PATCH v6 18/54] *-user: notify plugin of exit, Alex Bennée, 2019/10/17
- [PATCH v6 36/54] plugin: add API symbols to qemu-plugins.symbols, Alex Bennée, 2019/10/17
- [PATCH v6 25/54] target/sh4: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 33/54] target/openrisc: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 54/54] scripts/checkpatch.pl: don't complain about (foo, /* empty */), Alex Bennée, 2019/10/17
- [PATCH v6 20/54] cpu: hook plugin vcpu events,
Alex Bennée <=
- [PATCH v6 44/54] tests/tcg: set QEMU_OPTS for all cris runs, Alex Bennée, 2019/10/17
- [PATCH v6 22/54] translator: add translator_ld{ub,sw,uw,l,q}, Alex Bennée, 2019/10/17
- [PATCH v6 32/54] target/xtensa: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 30/54] target/riscv: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 40/54] vl: support -plugin option, Alex Bennée, 2019/10/17
- [PATCH v6 51/54] accel/stubs: reduce headers from tcg-stub, Alex Bennée, 2019/10/17
- [PATCH v6 52/54] include/exec: wrap cpu_ldst.h in CONFIG_TCG, Alex Bennée, 2019/10/17
- [PATCH v6 31/54] target/sparc: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 53/54] .travis.yml: add --enable-plugins tests, Alex Bennée, 2019/10/17
- [PATCH v6 41/54] linux-user: support -plugin option, Alex Bennée, 2019/10/17