All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Enable PC diversion via the plugin API
@ 2026-02-24 15:46 Florian Hofhammer
  2026-02-24 15:48 ` [PATCH v4 1/7] plugins: add flag to specify whether PC is rw Florian Hofhammer
                   ` (7 more replies)
  0 siblings, 8 replies; 46+ messages in thread
From: Florian Hofhammer @ 2026-02-24 15:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: alex.bennee, pierrick.bouvier, richard.henderson, laurent, imp,
	berrange

[-- Attachment #1: Type: text/plain, Size: 5201 bytes --]

Hi,

This patch series builds on top of the discussion from the thread at
https://lore.kernel.org/qemu-devel/e9bcd7c7-2d67-469e-b2f3-d1a68e456b2b@epfl.ch/
and adds a plugin API function to set the program counter of the guest,
as just writing to it via qemu_plugin_write_register() has no direct
effect.

Based on the discussion in the above thread, the series also introduces
a means to declare registers as read-only from the plugin side, which
prevents plugins from writing to them via qemu_plugin_write_register().
This for now is only applied to the PC, and finding the PC register is
done via some rather hacky strcmp()s. In the above thread, we also
discussed encoding the read-only property in a custom attribute in the
GDB XMLs, but that would (1) make syncing with GDB harder, (2) not cover
all architectures, as there's not an XML description of all
architectures available in the gdb-xml/ directory, and (3) require quite
some changes to the whole GDB infrastructure in gdbstub/ to even encode
the attribute in the correct structs and pass them on over the different
layers up into the plugin API.

This version v4 of the patch series is more about small refactorings and
cleanups than changes in functionality.

Best regards,
Florian 

Changes:
v4:
- switch strcmp out in favor of g_strcmp0 
- split the patch introducing the qemu_plugin_set_pc() API into three
  patches, two for preparing the plugin infrastructure and the syscall
  handling code and a third introducing the actual plugin API
v3:
- make PC registers read-only across architectures
- add tests for read-only registers
- adjust test structure for qemu_plugin_set_pc() by moving
   architecture-specific tests into corresponding directories
v2:
- add setjmp() in syscall handling path to allow PC redirection from
   syscall callbacks (via longjmp(), the cpu_loop()'s setjmp() for
   exiting a TB would not be live anymore in syscall handlers)
- add flags to ensure the qemu_plugin_set_pc() API is only called from
   contexts where the CPU is live
- add test for qemu_plugin_set_pc() API
v1:
- initial version 


Florian Hofhammer (7):
  plugins: add flag to specify whether PC is rw
  linux-user: make syscall emulation interruptible
  plugins: add PC diversion API function
  tests/tcg: add test for qemu_plugin_set_pc API
  plugins: add read-only property for registers
  plugins: prohibit writing to read-only registers
  tests/tcg/plugins: test register readonly feature

 include/plugins/qemu-plugin.h                 | 18 +++++
 linux-user/aarch64/cpu_loop.c                 |  2 +-
 linux-user/alpha/cpu_loop.c                   |  2 +-
 linux-user/arm/cpu_loop.c                     |  2 +-
 linux-user/hexagon/cpu_loop.c                 |  2 +-
 linux-user/hppa/cpu_loop.c                    |  4 ++
 linux-user/i386/cpu_loop.c                    |  8 ++-
 linux-user/include/special-errno.h            |  8 +++
 linux-user/loongarch64/cpu_loop.c             |  5 +-
 linux-user/m68k/cpu_loop.c                    |  2 +-
 linux-user/microblaze/cpu_loop.c              |  2 +-
 linux-user/mips/cpu_loop.c                    |  5 +-
 linux-user/or1k/cpu_loop.c                    |  2 +-
 linux-user/ppc/cpu_loop.c                     |  6 +-
 linux-user/riscv/cpu_loop.c                   |  2 +-
 linux-user/s390x/cpu_loop.c                   |  2 +-
 linux-user/sh4/cpu_loop.c                     |  2 +-
 linux-user/sparc/cpu_loop.c                   |  4 +-
 linux-user/syscall.c                          | 16 +++++
 linux-user/xtensa/cpu_loop.c                  |  3 +
 plugins/api.c                                 | 43 ++++++++++--
 plugins/core.c                                | 29 ++++----
 tests/tcg/arm/Makefile.target                 |  6 ++
 tests/tcg/hexagon/Makefile.target             |  7 ++
 tests/tcg/mips/Makefile.target                |  6 +-
 tests/tcg/mips64/Makefile.target              | 15 ++++
 tests/tcg/mips64el/Makefile.target            | 15 ++++
 tests/tcg/mipsel/Makefile.target              | 15 ++++
 tests/tcg/multiarch/Makefile.target           | 22 +++++-
 .../{ => plugin}/check-plugin-output.sh       |  0
 .../{ => plugin}/test-plugin-mem-access.c     |  0
 .../plugin/test-plugin-skip-syscalls.c        | 26 +++++++
 tests/tcg/plugins/meson.build                 |  1 +
 tests/tcg/plugins/registers.c                 | 68 +++++++++++++++++++
 tests/tcg/plugins/syscall.c                   |  6 ++
 tests/tcg/sparc64/Makefile.target             | 16 +++++
 36 files changed, 331 insertions(+), 41 deletions(-)
 create mode 100644 tests/tcg/mips64/Makefile.target
 create mode 100644 tests/tcg/mips64el/Makefile.target
 create mode 100644 tests/tcg/mipsel/Makefile.target
 rename tests/tcg/multiarch/{ => plugin}/check-plugin-output.sh (100%)
 rename tests/tcg/multiarch/{ => plugin}/test-plugin-mem-access.c (100%)
 create mode 100644 tests/tcg/multiarch/plugin/test-plugin-skip-syscalls.c
 create mode 100644 tests/tcg/plugins/registers.c
 create mode 100644 tests/tcg/sparc64/Makefile.target


base-commit: afe653676dc6dfd49f0390239ff90b2f0052c2b8
-- 
2.53.0

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4346 bytes --]

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

end of thread, other threads:[~2026-03-02 13:07 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 15:46 [PATCH v4 0/7] Enable PC diversion via the plugin API Florian Hofhammer
2026-02-24 15:48 ` [PATCH v4 1/7] plugins: add flag to specify whether PC is rw Florian Hofhammer
2026-02-24 17:41   ` Alex Bennée
2026-02-24 15:50 ` [PATCH v4 2/7] linux-user: make syscall emulation interruptible Florian Hofhammer
2026-02-24 21:05   ` Pierrick Bouvier
2026-02-25  8:02     ` Florian Hofhammer
2026-02-25 17:00       ` Pierrick Bouvier
2026-02-25  9:25     ` Alex Bennée
2026-02-25  9:29       ` Florian Hofhammer
2026-02-25 12:25         ` Alex Bennée
2026-02-24 15:51 ` [PATCH v4 3/7] plugins: add PC diversion API function Florian Hofhammer
2026-02-24 17:46   ` Alex Bennée
2026-02-24 20:12     ` Pierrick Bouvier
2026-02-25  7:55       ` Florian Hofhammer
2026-02-24 15:52 ` [PATCH v4 4/7] tests/tcg: add test for qemu_plugin_set_pc API Florian Hofhammer
2026-02-24 16:55   ` Brian Cain
2026-02-24 20:24   ` Pierrick Bouvier
2026-02-25 14:58     ` Florian Hofhammer
2026-02-25 17:04       ` Pierrick Bouvier
2026-02-26  8:08         ` Florian Hofhammer
2026-02-24 20:35   ` Pierrick Bouvier
2026-02-25  7:59     ` Florian Hofhammer
2026-02-25 11:49       ` Florian Hofhammer
2026-02-25 17:07         ` Pierrick Bouvier
2026-02-25 17:09           ` Pierrick Bouvier
2026-02-24 21:28   ` Pierrick Bouvier
2026-02-25  8:03     ` Florian Hofhammer
2026-02-25 16:21   ` Florian Hofhammer
2026-02-25 17:30     ` Pierrick Bouvier
2026-02-25 17:39       ` Pierrick Bouvier
2026-02-26  8:30       ` Florian Hofhammer
2026-02-26 19:47         ` Pierrick Bouvier
2026-02-24 15:53 ` [PATCH v4 5/7] plugins: add read-only property for registers Florian Hofhammer
2026-02-24 17:46   ` Alex Bennée
2026-02-26 11:55   ` Florian Hofhammer
2026-02-26 14:33     ` Alex Bennée
2026-02-26 19:43       ` Pierrick Bouvier
2026-02-24 15:57 ` [PATCH v4 6/7] plugins: prohibit writing to read-only registers Florian Hofhammer
2026-02-24 17:49   ` Alex Bennée
2026-03-02 11:52     ` Florian Hofhammer
2026-03-02 13:03       ` Alex Bennée
2026-03-02 13:06         ` Florian Hofhammer
2026-02-24 15:58 ` [PATCH v4 7/7] tests/tcg/plugins: test register readonly feature Florian Hofhammer
2026-02-24 20:17   ` Pierrick Bouvier
2026-02-25  9:24   ` Alex Bennée
2026-02-24 20:14 ` [PATCH v4 0/7] Enable PC diversion via the plugin API Pierrick Bouvier

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.