Skip to content

RFC plugins/next - fixes, sysfilter and vcpu_init tweaks

Alex Bennée qemu-arm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest12 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12contrib/plugins/hotblocks: Correctly free sorted counts listcontrib/plugins/hotblocks.c+5 -40 replies
2/12contrib/plugins/hotblocks: Fix off by one error in iteration of sorted blockscontrib/plugins/hotblocks.c+1 -20 replies
3/12contrib/plugins/hotblocks: Print uint64_t with PRIu64 rather than PRId64contrib/plugins/hotblocks.c+1 -10 replies
4/12docs/about/emulation: Add documentation for hotblocks plugin argumentsdocs/about/emulation.rst+10 -00 replies
5/12contrib/plugins/hotblocks: Allow limit to be set as a command line argumentcontrib/plugins/hotblocks.c docs/about/emulation.rst+11 -10 replies
6/12plugins: shorten aggressively long namecontrib/plugins/cflow.c contrib/plugins/howvec.c contrib/plugins/stoptrigger.c +5 more+36 -331 reply
7/12linux-user: add plugin API to filter syscallsinclude/qemu/plugin-event.h include/qemu/plugin.h include/qemu/qemu-plugin.h +4 more+123 -110 replies
8/12tcg tests: add a test to verify the syscall filter plugin APItests/tcg/multiarch/Makefile.target tests/tcg/multiarch/test-plugin-syscall-filter.c tests/tcg/plugins/syscall.c+57 -10 replies
9/12plugins: split init_hook into create and resethw/core/cpu-common.c include/qemu/plugin.h include/qemu/qemu-plugin.h +1 more+55 -201 reply
10/12target/arm: defer creation of gdb register until machine createdtarget/arm/cpu.c+33 -01 reply
11/12contrib/plugins: add systrace plugin for tracking exceptions and irqscontrib/plugins/meson.build contrib/plugins/systrace.c+573 -11 reply
12/12target/arm: allow gdb to read ARM_CP_NORAW regs (!upstream)target/arm/gdbstub.c target/arm/helper.c+19 -21 reply

Reviews trailers per patch

11 of 12 patches have a Reviewed-by or Acked-by.

PatchManos PitsidianakisPierrick BouvierMingyuan Xia
1/12R-b R-b
2/12R-b
3/12R-b R-b
4/12R-b
5/12R-b
6/12R-b
7/12R-b Co-authored-by
8/12R-b Co-authored-by
9/12
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [RFC PATCH 00/12] plugins/next - fixes, sysfilter and vcpu_init tweaks

Hi,

I thought I'd post the current state of the plugins/next tree for comments and reviews.

Firstly we have a bunch of fixes for the hotblocks plugins from Alex Bradbury.

We also have Ziyang Zhang's syscall filter patches which allow plugins to filter (and/or replace) syscalls. The initial use for this would be for something like Lorelei:

https://pretalx.com/kvm-forum-2025/talk/KFSGHS/

where using plugins avoids needing to integrate complex logic into linux-user itself. No doubt the reverse engineers would also find the capability useful.

There is also a discussion thread about a general purpose PC setting patch:

Message-Id: e64f4a1f-ac43-487b-f0af-08de04dbd9f1
Subject: [RFC PATCH v2 0/2] Enable PC diversion via the plugin API
From: Florian Hofhammer <[email protected]>
Date: Mon, 6 Oct 2025 15:21:21 +0200
Message-ID: <[email protected]>

but as we still need to work out a nice way to handle removing the PC from the register list I've left that out for now.

Finally I was doing some hacking around on my kvm/trap-me-harder patches and I wanted to check when IRQ's occurred and what systems registers were touched when. I then discovered that the ICC_ registers were not available to plugins due to being created after the CPUs are initialised. I've tried several approaches but it seems having a clean vCPU initialisation after machine creation is tricky so instead I've split the hooks into creation and reset and moved the plugin visable callback to reset. However this may change the assumptions about what to do in vcpu_init.

You can see some of the ugliness in the new systrace plugin which has to jump through hoops to deal with the fact the number of registers it can see changes several times. Unfortunately this seems to trigger a corruption bug which I haven't nailed down yet while running:

./qemu-system-aarch64 \
                  -machine type=virt,gic-version=3 \
                  -cpu neoverse-n1 \
                  -smp 4 \
                  -serial mon:stdio \
                  -m 1024 \
                  -accel tcg \
                  -kernel ~/lsrc/linux.git/builds/arm64.initramfs/arch/arm64/boot/Image.gz \
                  -append "console=ttyAMA0" \
                  -display none -d unimp,plugin,cpu_reset -plugin ./contrib/plugins/libsystrace.so,show_frompc=on,tracksw=msr,reg=icc\* -D boot.log

I'm open to better ideas about how to solve this particular problem.

Anyway happy holidays everyone, see you all in the new year ;-)

Alex.

Alex Bennée (5):
plugins: shorten aggressively long name
plugins: split init_hook into create and reset
target/arm: defer creation of gdb register until machine created contrib/plugins: add systrace plugin for tracking exceptions and irqs target/arm: allow gdb to read ARM_CP_NORAW regs (!upstream)

Alex Bradbury (5):
contrib/plugins/hotblocks: Correctly free sorted counts list contrib/plugins/hotblocks: Fix off by one error in iteration of sorted
blocks
contrib/plugins/hotblocks: Print uint64_t with PRIu64 rather than

    PRId64

docs/about/emulation: Add documentation for hotblocks plugin arguments contrib/plugins/hotblocks: Allow limit to be set as a command line
argument

Ziyang Zhang (2):
linux-user: add plugin API to filter syscalls
tcg tests: add a test to verify the syscall filter plugin API

 docs/about/emulation.rst                      |  12 +
 include/qemu/plugin-event.h                   |   1 +
 include/qemu/plugin.h                         |  52 +-
 include/qemu/qemu-plugin.h                    |  40 +-
 include/user/syscall-trace.h                  |  17 +
 contrib/plugins/cflow.c                       |  22 +-
 contrib/plugins/hotblocks.c                   |  20 +-
 contrib/plugins/howvec.c                      |   2 +-
 contrib/plugins/stoptrigger.c                 |  10 +-
 contrib/plugins/systrace.c                    | 572 ++++++++++++++++++
 hw/core/cpu-common.c                          |  21 +-
 linux-user/syscall.c                          |   7 +-
 plugins/api.c                                 |   9 +-
 plugins/core.c                                |  68 ++-
 target/arm/cpu.c                              |  33 +
 target/arm/gdbstub.c                          |   6 +-
 target/arm/helper.c                           |  15 +-
 .../multiarch/test-plugin-syscall-filter.c    |  35 ++
 tests/tcg/plugins/discons.c                   |  18 +-
 tests/tcg/plugins/inline.c                    |   6 +-
 tests/tcg/plugins/insn.c                      |   5 +-
 tests/tcg/plugins/syscall.c                   |  19 +
 contrib/plugins/meson.build                   |   2 +-
 tests/tcg/multiarch/Makefile.target           |   4 +-
 24 files changed, 922 insertions(+), 74 deletions(-)
 create mode 100644 contrib/plugins/systrace.c
 create mode 100644 tests/tcg/multiarch/test-plugin-syscall-filter.c
Signature · 1 line
2.47.3