All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Julian Ganz <neither@nut.email>
Cc: qemu-devel@nongnu.org,  Alexandre Iooss <erdnaxe@crans.org>,
	 Mahmoud Mandour <ma.mandourr@gmail.com>,
	 Pierrick Bouvier <pierrick.bouvier@linaro.org>
Subject: Re: [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks
Date: Thu, 09 Jan 2025 13:57:18 +0000	[thread overview]
Message-ID: <87r05c6qf5.fsf@draig.linaro.org> (raw)
In-Reply-To: <e4af8fed4cc5449a7be04fbbf026abf267dc189b.1733063076.git.neither@nut.email> (Julian Ganz's message of "Mon, 2 Dec 2024 20:26:43 +0100")

Julian Ganz <neither@nut.email> writes:

> The plugin API allows registration of callbacks for a variety of VCPU
> related events, such as VCPU reset, idle and resume. In addition to
> those events, we recently defined discontinuity events, which include
> traps.
>
> This change introduces a function to register callbacks for these
> events. We define one distinct plugin event type for each type of
> discontinuity, granting fine control to plugins in term of which events
> they receive.
> ---
>  include/qemu/plugin-event.h |  3 +++
>  include/qemu/qemu-plugin.h  | 15 +++++++++++++++
>  plugins/core.c              | 15 +++++++++++++++
>  3 files changed, 33 insertions(+)
>
> diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h
> index 7056d8427b..1100dae212 100644
> --- a/include/qemu/plugin-event.h
> +++ b/include/qemu/plugin-event.h
> @@ -20,6 +20,9 @@ enum qemu_plugin_event {
>      QEMU_PLUGIN_EV_VCPU_SYSCALL_RET,
>      QEMU_PLUGIN_EV_FLUSH,
>      QEMU_PLUGIN_EV_ATEXIT,
> +    QEMU_PLUGIN_EV_VCPU_INTERRUPT,
> +    QEMU_PLUGIN_EV_VCPU_EXCEPTION,
> +    QEMU_PLUGIN_EV_VCPU_HOSTCALL,
>      QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */
>  };
>  
> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
> index 9c67374b7e..f998a465e5 100644
> --- a/include/qemu/qemu-plugin.h
> +++ b/include/qemu/qemu-plugin.h
> @@ -273,6 +273,21 @@ QEMU_PLUGIN_API
>  void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,
>                                           qemu_plugin_vcpu_simple_cb_t cb);
>  
> +/**
> + * qemu_plugin_register_vcpu_discon_cb() - register a discontinuity callback
> + * @id: plugin ID
> + * @cb: callback function
> + *
> + * The @cb function is called every time a vCPU receives a discontinuity event
> + * of the specified type(s), after the vCPU was prepared to handle the event.
> + * Preparation usually entails updating the PC to some interrupt handler or trap
> + * vector entry.

The "usually" here is a bit of a weasel word. We should be clear what
the contract is with the plugin. Can we say the PC will be updated to
the next instruction that will execute after the callback?

> + */
> +QEMU_PLUGIN_API
> +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id,
> +                                         enum qemu_plugin_discon_type type,
> +                                         qemu_plugin_vcpu_discon_cb_t cb);
> +
>  /** struct qemu_plugin_tb - Opaque handle for a translation block */
>  struct qemu_plugin_tb;
>  /** struct qemu_plugin_insn - Opaque handle for a translated instruction */
> diff --git a/plugins/core.c b/plugins/core.c
> index bb105e8e68..a89a4a0315 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -559,6 +559,21 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,
>      plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb);
>  }
>  
> +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id,
> +                                         enum qemu_plugin_discon_type type,
> +                                         qemu_plugin_vcpu_discon_cb_t cb)
> +{
> +    if (type & QEMU_PLUGIN_DISCON_INTERRUPT) {
> +        plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb);
> +    }
> +    if (type & QEMU_PLUGIN_DISCON_EXCEPTION) {
> +        plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb);
> +    }
> +    if (type & QEMU_PLUGIN_DISCON_HOSTCALL) {
> +        plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb);
> +    }
> +}
> +
>  void qemu_plugin_register_flush_cb(qemu_plugin_id_t id,
>                                     qemu_plugin_simple_cb_t cb)
>  {

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  parent reply	other threads:[~2025-01-09 13:57 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 19:26 [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities Julian Ganz
2024-12-03  8:45   ` Julian Ganz
2024-12-04 22:41     ` Pierrick Bouvier
2024-12-05 12:40       ` Julian Ganz
2024-12-05 17:56         ` Pierrick Bouvier
2024-12-05 21:50           ` Julian Ganz
2024-12-05 22:14             ` Julian Ganz
2024-12-05 23:03             ` Pierrick Bouvier
2024-12-06  8:58               ` Julian Ganz
2024-12-06 18:59                 ` Pierrick Bouvier
2024-12-07 13:38                   ` Julian Ganz
2024-12-09 18:52                     ` Pierrick Bouvier
2024-12-04 22:45   ` Pierrick Bouvier
2024-12-05 12:44     ` Julian Ganz
2024-12-05 17:35       ` Pierrick Bouvier
2024-12-05 21:25         ` Julian Ganz
2025-01-09 13:52     ` Alex Bennée
2025-01-09 22:28       ` Pierrick Bouvier
2025-01-10 11:43       ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks Julian Ganz
2024-12-04 22:45   ` Pierrick Bouvier
2025-01-09 13:57   ` Alex Bennée [this message]
2025-01-10 11:40     ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 03/11] plugins: add hooks for new discontinuity related callbacks Julian Ganz
2024-12-04 22:47   ` Pierrick Bouvier
2025-01-09 13:58   ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 04/11] contrib/plugins: add plugin showcasing new dicontinuity related API Julian Ganz
2024-12-04 23:14   ` Pierrick Bouvier
2024-12-05 13:00     ` Julian Ganz
2024-12-05 17:23       ` Pierrick Bouvier
2025-01-09 14:04   ` Alex Bennée
2025-01-09 22:10     ` Pierrick Bouvier
2025-01-10 11:49     ` Julian Ganz
2025-01-10 15:15       ` Alex Bennée
2025-01-10 21:02         ` Pierrick Bouvier
2025-01-11 12:15           ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 05/11] target/alpha: call plugin trap callbacks Julian Ganz
2024-12-04 22:48   ` Pierrick Bouvier
2024-12-02 19:26 ` [RFC PATCH v3 06/11] target/arm: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 07/11] target/avr: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 08/11] target/mips: " Julian Ganz
2025-01-09 13:43   ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 09/11] target/riscv: " Julian Ganz
2024-12-03  4:39   ` Alistair Francis
2024-12-02 19:41 ` [RFC PATCH v3 10/11] target/sparc: " Julian Ganz
2025-01-09 13:46   ` Alex Bennée
2024-12-02 19:41 ` [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc Julian Ganz
2024-12-04 23:33   ` Pierrick Bouvier
2024-12-05 13:10     ` Julian Ganz
2024-12-05 17:30       ` Pierrick Bouvier
2024-12-05 21:22         ` Julian Ganz
2024-12-05 22:28           ` Pierrick Bouvier
2024-12-06  8:42             ` Julian Ganz
2024-12-06 19:02               ` Pierrick Bouvier
2024-12-06 19:42                 ` Richard Henderson
2024-12-06 20:40                   ` Pierrick Bouvier
2024-12-06 22:56                     ` Richard Henderson
2024-12-07 13:47                       ` Julian Ganz
2024-12-07 13:41                   ` Julian Ganz
2024-12-20 11:47     ` Julian Ganz
2024-12-20 21:17       ` Pierrick Bouvier
2024-12-20 21:46         ` Pierrick Bouvier
2025-01-09 16:35         ` Alex Bennée
2025-01-09 16:33       ` Alex Bennée
2025-01-09 22:27         ` Pierrick Bouvier
2025-01-10 11:58         ` Julian Ganz
2024-12-03  8:36 ` [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-04 22:51   ` Pierrick Bouvier
2025-01-09 16:43 ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r05c6qf5.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=neither@nut.email \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.