From nobody Mon Feb 9 21:11:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505254086400988.0976953379932; Tue, 12 Sep 2017 15:08:06 -0700 (PDT) Received: from localhost ([::1]:38894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drtLh-0007m4-5m for importer@patchew.org; Tue, 12 Sep 2017 18:08:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drtKC-0006n2-IU for qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:06:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drtK9-0004cX-MY for qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:06:32 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:43396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drtK9-0004bm-Bp for qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:06:29 -0400 Received: from correu-2.ac.upc.es (correu-2.ac.upc.es [147.83.30.92]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8CM6PWe023215; Wed, 13 Sep 2017 00:06:25 +0200 Received: from localhost (unknown [31.210.187.58]) by correu-2.ac.upc.es (Postfix) with ESMTPSA id 2E2A544C; Wed, 13 Sep 2017 00:06:20 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 01:06:18 +0300 Message-Id: <150525397866.15988.17518293933244872138.stgit@frigg.lan> X-Mailer: git-send-email 2.14.1 In-Reply-To: <150525010239.15988.8172586618197849619.stgit@frigg.lan> References: <150525010239.15988.8172586618197849619.stgit@frigg.lan> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id v8CM6PWe023215 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v5 16/22] instrument: Add event 'guest_cpu_reset' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , "Emilio G. Cota" , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Llu=C3=ADs Vilanova --- 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); =20 +extern void (*instr_event__guest_cpu_reset)(QICPU vcpu); +static inline void instr_guest_cpu_reset(CPUState *vcpu); + =20 #include "instrument/events.inc.h" =20 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) =3D instr_get_event(guest_cpu_reset); + if (cb) { + QICPU vcpu_ =3D 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); =20 instr_cpu_stop_all_end(&info); cpu_list_unlock(); diff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/contro= l.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)); =20 +/* + * 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 @@ */ =20 #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); } =20 + instr_guest_cpu_reset(cpu); trace_guest_cpu_reset(cpu); } =20 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);