[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 16/22] instrument: Add event 'guest_cpu_reset'
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v5 16/22] instrument: Add event 'guest_cpu_reset' |
Date: |
Wed, 13 Sep 2017 01:06:18 +0300 |
User-agent: |
StGit/0.18 |
Signed-off-by: Lluís Vilanova <address@hidden>
---
instrument/control.c | 9 +++++++++
instrument/events.h | 3 +++
instrument/events.inc.h | 11 +++++++++++
instrument/load.c | 1 +
instrument/qemu-instr/control.h | 9 +++++++++
qom/cpu.c | 2 ++
stubs/instrument.c | 1 +
7 files changed, 36 insertions(+)
diff --git a/instrument/control.c b/instrument/control.c
index 0be8065409..401189db2e 100644
--- a/instrument/control.c
+++ b/instrument/control.c
@@ -133,3 +133,12 @@ SYM_PUBLIC void qi_event_set_guest_cpu_exit(void
(*fn)(QICPU vcpu))
ERROR_IF(!instr_get_state(), "called outside instrumentation");
instr_set_event(guest_cpu_exit, fn);
}
+
+
+void (*instr_event__guest_cpu_reset)(QICPU vcpu);
+
+SYM_PUBLIC void qi_event_set_guest_cpu_reset(void (*fn)(QICPU vcpu))
+{
+ ERROR_IF(!instr_get_state(), "called outside instrumentation");
+ instr_set_event(guest_cpu_reset, fn);
+}
diff --git a/instrument/events.h b/instrument/events.h
index c743cb8180..4a0560490a 100644
--- a/instrument/events.h
+++ b/instrument/events.h
@@ -39,6 +39,9 @@ static inline void instr_guest_cpu_enter(CPUState *vcpu);
extern void (*instr_event__guest_cpu_exit)(QICPU vcpu);
static inline void instr_guest_cpu_exit(CPUState *vcpu);
+extern void (*instr_event__guest_cpu_reset)(QICPU vcpu);
+static inline void instr_guest_cpu_reset(CPUState *vcpu);
+
#include "instrument/events.inc.h"
diff --git a/instrument/events.inc.h b/instrument/events.inc.h
index c88df7e42f..a126ba5ae6 100644
--- a/instrument/events.inc.h
+++ b/instrument/events.inc.h
@@ -31,3 +31,14 @@ static inline void instr_guest_cpu_exit(CPUState *vcpu)
instr_set_state(INSTR_STATE_DISABLE);
}
}
+
+static inline void instr_guest_cpu_reset(CPUState *vcpu)
+{
+ void (*cb)(QICPU vcpu) = instr_get_event(guest_cpu_reset);
+ if (cb) {
+ QICPU vcpu_ = instr_cpu_to_qicpu(vcpu);
+ instr_set_state(INSTR_STATE_ENABLE);
+ (*cb)(vcpu_);
+ instr_set_state(INSTR_STATE_DISABLE);
+ }
+}
diff --git a/instrument/load.c b/instrument/load.c
index 6808d361b5..8c15a73a8c 100644
--- a/instrument/load.c
+++ b/instrument/load.c
@@ -161,6 +161,7 @@ InstrUnloadError instr_unload(const char *id)
instr_set_event(fini_fn, NULL);
instr_set_event(guest_cpu_enter, NULL);
instr_set_event(guest_cpu_exit, NULL);
+ instr_set_event(guest_cpu_reset, NULL);
instr_cpu_stop_all_end(&info);
cpu_list_unlock();
diff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/control.h
index 107ee8afe0..322009100d 100644
--- a/instrument/qemu-instr/control.h
+++ b/instrument/qemu-instr/control.h
@@ -96,6 +96,15 @@ void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu));
*/
void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu));
+/*
+ * Reset the state of a virtual (guest) CPU.
+ *
+ * Mode: user, softmmu
+ * Targets: all
+ * Time: exec
+ */
+void qi_event_set_guest_cpu_reset(void (*fn)(QICPU vcpu));
+
#ifdef __cplusplus
}
#endif
diff --git a/qom/cpu.c b/qom/cpu.c
index dc5392dbeb..6336d63f66 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include "instrument/events.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "qom/cpu.h"
@@ -275,6 +276,7 @@ void cpu_reset(CPUState *cpu)
(*klass->reset)(cpu);
}
+ instr_guest_cpu_reset(cpu);
trace_guest_cpu_reset(cpu);
}
diff --git a/stubs/instrument.c b/stubs/instrument.c
index c4b1c791d9..dda2ae88c5 100644
--- a/stubs/instrument.c
+++ b/stubs/instrument.c
@@ -48,3 +48,4 @@ void qmp_instr_unload(const char *id, Error **errp)
__thread InstrState instr_cur_state;
void (*instr_event__guest_cpu_enter)(QICPU *vcpu);
void (*instr_event__guest_cpu_exit)(QICPU *vcpu);
+void (*instr_event__guest_cpu_reset)(QICPU *vcpu);
- [Qemu-devel] [PATCH v5 06/22] instrument: [softmmu] Add command line library loader, (continued)
- [Qemu-devel] [PATCH v5 06/22] instrument: [softmmu] Add command line library loader, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 07/22] instrument: [qapi] Add library loader, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 08/22] instrument: [hmp] Add library loader, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 09/22] instrument: Add basic control interface, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 10/22] instrument: Add support for tracing events, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 11/22] instrument: Track vCPUs, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 12/22] instrument: Add event 'guest_cpu_enter', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 13/22] instrument: Support synchronous modification of vCPU state, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 14/22] exec: Add function to synchronously flush TB on a stopped vCPU, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 15/22] instrument: Add event 'guest_cpu_exit', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 16/22] instrument: Add event 'guest_cpu_reset',
Lluís Vilanova <=
- [Qemu-devel] [PATCH v5 17/22] trace: Introduce a proper structure to describe memory accesses, Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 18/22] instrument: Add event 'guest_mem_before_trans', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 19/22] instrument: Add event 'guest_mem_before_exec', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 20/22] instrument: Add event 'guest_user_syscall', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 21/22] instrument: Add event 'guest_user_syscall_ret', Lluís Vilanova, 2017/09/12
- [Qemu-devel] [PATCH v5 22/22] instrument: Add API to manipulate guest memory, Lluís Vilanova, 2017/09/12
- Re: [Qemu-devel] [PATCH v5 00/22] instrument: Add basic event instrumentation, no-reply, 2017/09/12
- Re: [Qemu-devel] [PATCH v5 00/22] instrument: Add basic event instrumentation, no-reply, 2017/09/12