qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities
@ 2024-12-02 19:26 Julian Ganz
  2024-12-02 19:26 ` [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities Julian Ganz
                   ` (12 more replies)
  0 siblings, 13 replies; 70+ messages in thread
From: Julian Ganz @ 2024-12-02 19:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Julian Ganz

Some analysis greatly benefits, or depends on, information about
certain types of dicontinuities such as 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 a callback for discontinuities. Patch 1 defines
an enumeration of some trap-related discontinuities including somewhat
narrow definitions of the discontinuity evetns and a callback type.
Patch 2 defines the callback registration function. Patch 3 adds some
hooks for triggering the callbacks. Patch 4 adds an example plugin
showcasing the new API. Patches 5 through 6 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). Finally, patch 11 supplies a test plugin asserting that the
next PC provided to the plugin points to the next instruction executed.

Sidenote: I'm likely doing something wrong for one architecture or
the other. These patches are untested for most of them.

Since v2 (tcg-plugins: add hooks for interrupts, exceptions and traps):
  - Switched from traps as core concept to more generic discontinuities
  - Switched from semihosting to hostcall as term for emulated traps
  - Added enumeration of events and dedicated callback type
  - Make callback receive event type as well as origin and target PC
    (as requested by Pierrick Bouvier)
  - Combined registration functions for different traps into a single
    one for all types of discontinuities (as requested by Pierrick
    Bouvier)
  - Migrated records in example plugin from fully pre-allocated to a
    scoreboard (as suggested by Pierrick Bouvier)
  - Handle PSCI calls as hostcall (as pointed out by Peter Maydell)
  - Added hooks for ARM Cortex M arches (as pointed out by Peter
    Maydell)
  - Added hooks for Alpha targets
  - Added hooks for MIPS targets
  - Added a plugin for testing some of the interface behaviour

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 (11):
  plugins: add types for callbacks related to certain discontinuities
  plugins: add API for registering discontinuity callbacks
  plugins: add hooks for new discontinuity related callbacks
  contrib/plugins: add plugin showcasing new dicontinuity related API
  target/alpha: call plugin trap callbacks
  target/arm: call plugin trap callbacks
  target/avr: call plugin trap callbacks
  target/mips: call plugin trap callbacks
  target/riscv: call plugin trap callbacks
  target/sparc: call plugin trap callbacks
  tests: add plugin asserting correctness of discon event's to_pc

 contrib/plugins/meson.build         |  3 +-
 contrib/plugins/traps.c             | 96 +++++++++++++++++++++++++++++
 include/qemu/plugin-event.h         |  3 +
 include/qemu/plugin.h               | 13 ++++
 include/qemu/qemu-plugin.h          | 58 +++++++++++++++++
 plugins/core.c                      | 67 ++++++++++++++++++++
 target/alpha/helper.c               | 12 ++++
 target/arm/helper.c                 | 25 ++++++++
 target/arm/tcg/m_helper.c           | 18 ++++++
 target/avr/helper.c                 |  3 +
 target/mips/tcg/sysemu/tlb_helper.c | 11 ++++
 target/riscv/cpu_helper.c           |  9 +++
 target/sparc/int32_helper.c         |  7 +++
 target/sparc/int64_helper.c         | 10 +++
 tests/tcg/plugins/discons.c         | 95 ++++++++++++++++++++++++++++
 tests/tcg/plugins/meson.build       |  2 +-
 16 files changed, 430 insertions(+), 2 deletions(-)
 create mode 100644 contrib/plugins/traps.c
 create mode 100644 tests/tcg/plugins/discons.c

-- 
2.45.2



^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2025-01-11 12:16 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).