qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Julian Ganz <neither@nut.email>
To: qemu-devel@nongnu.org
Cc: Julian Ganz <neither@nut.email>
Subject: [RFC PATCH v2 0/7] tcg-plugins: add hooks for interrupts, exceptions and traps
Date: Sat, 19 Oct 2024 18:39:33 +0200	[thread overview]
Message-ID: <cover.1729355735.git.neither@nut.email> (raw)
In-Reply-To: <20231021122502.26746-1-neither@nut.email>

Some analysis greatly benefits, or depends on, information about
interrupts. For example, we may need to handle the execution of a new
translation block differently if it is not the result of normal program
flow but of an interrupt.

Even with the existing interfaces, it is more or less possible to
discern these situations, e.g. as done by the cflow plugin. However,
this process poses a considerable overhead to the core analysis one may
intend to perform.

These changes introduce a generic and easy-to-use interface for plugin
authors in the form of callbacks for different types of traps. Patch 1
defines the callback registration functions and supplies a somewhat
narrow definition of the event the callbacks are called. Patch 2 adds
some hooks for triggering the callbacks. Patch 3 adds an example plugin
showcasing the new API. The remaining patches call the hooks for a
selection of architectures, mapping architecture specific events to the
three categories defined in patch 1. Future non-RFC patchsets will call
these hooks for all architectures (that have some concept of trap or
interrupt).

Sidenote: I'm likely doing something wrong for one architecture or
the other. For example, with the old version Alex Bennée suggested
registering a helper function with arm_register_el_change_hook() for
arm, which is not what I ended up doing. And for AVR my approach to just
assume only (asynchroneous) interrupts exist is also likely too naïve.

Since v1:
  - Split the one callback into multiple callbacks
  - Added a target-agnostic definition of the relevant event(s)
  - Call hooks from architecture-code rather than accel/tcg/cpu-exec.c
  - Added a plugin showcasing API usage

Julian Ganz (7):
  plugins: add API for registering trap related callbacks
  plugins: add hooks for new trap related callbacks
  contrib/plugins: add plugin showcasing new trap related API
  target/arm: call plugin trap callbacks
  target/avr: call plugin trap callbacks
  target/riscv: call plugin trap callbacks
  target/sparc: call plugin trap callbacks

 contrib/plugins/Makefile     |  1 +
 contrib/plugins/traps.c      | 89 ++++++++++++++++++++++++++++++++++++
 include/qemu/plugin-event.h  |  3 ++
 include/qemu/plugin.h        | 12 +++++
 include/qemu/qemu-plugin.h   | 45 ++++++++++++++++++
 plugins/core.c               | 42 +++++++++++++++++
 plugins/qemu-plugins.symbols |  3 ++
 target/arm/helper.c          | 23 ++++++++++
 target/avr/helper.c          |  3 ++
 target/riscv/cpu_helper.c    |  8 ++++
 target/sparc/int32_helper.c  |  7 +++
 target/sparc/int64_helper.c  | 10 ++++
 12 files changed, 246 insertions(+)
 create mode 100644 contrib/plugins/traps.c

-- 
2.45.2



  parent reply	other threads:[~2024-10-19 16:41 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-21 12:24 [PATCH] tcg-plugins: add a hook for interrupts, exceptions and traps Julian Ganz
2023-10-23 13:08 ` Alex Bennée
2023-10-23 18:45   ` Julian Ganz
2024-10-19 16:39 ` Julian Ganz [this message]
2024-10-19 16:39   ` [RFC PATCH v2 1/7] plugins: add API for registering trap related callbacks Julian Ganz
2024-10-19 16:39   ` [RFC PATCH v2 2/7] plugins: add hooks for new " Julian Ganz
2024-10-19 16:39   ` [RFC PATCH v2 3/7] contrib/plugins: add plugin showcasing new trap related API Julian Ganz
2024-10-21 18:06     ` Pierrick Bouvier
2024-10-21 18:07     ` Pierrick Bouvier
2024-10-21 20:22       ` Julian Ganz
2024-10-19 16:39   ` [RFC PATCH v2 4/7] target/arm: call plugin trap callbacks Julian Ganz
2024-10-21 12:58     ` Peter Maydell
2024-10-21 16:25       ` Julian Ganz
2024-10-19 16:39   ` [RFC PATCH v2 5/7] target/avr: " Julian Ganz
2024-10-19 17:29     ` Michael Rolnik
2024-10-19 16:39   ` [RFC PATCH v2 6/7] target/riscv: " Julian Ganz
2024-10-19 16:39   ` [RFC PATCH v2 7/7] target/sparc: " Julian Ganz
2024-10-20 19:37   ` [RFC PATCH v2 0/7] tcg-plugins: add hooks for interrupts, exceptions and traps Alex Bennée
2024-10-21 18:00   ` Pierrick Bouvier
2024-10-21 18:47     ` Alex Bennée
2024-10-21 20:45       ` Pierrick Bouvier
2024-10-21 21:02     ` Julian Ganz
2024-10-21 21:59       ` Pierrick Bouvier
2024-10-22  8:21         ` Julian Ganz
2024-10-22  8:58           ` Alex Bennée
2024-10-22 20:12             ` Julian Ganz
2024-10-22 21:15           ` Pierrick Bouvier
2024-10-23 12:56             ` Julian Ganz
2024-10-23 13:57               ` Alex Bennée
2024-10-23 15:21                 ` Pierrick Bouvier
2024-10-23 15:16               ` Pierrick Bouvier
2024-10-23 16:12                 ` Julian Ganz
2024-10-23 16:39                   ` Pierrick Bouvier
2024-10-23 17:12                     ` Julian Ganz
2024-10-23 17:53                       ` Pierrick Bouvier

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=cover.1729355735.git.neither@nut.email \
    --to=neither@nut.email \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).