qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH  v3 00/50] tcg plugin support
@ 2019-06-14 17:11 Alex Bennée
  2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 01/50] trace: expand mem_info:size_shift to 3 bits Alex Bennée
                   ` (53 more replies)
  0 siblings, 54 replies; 117+ messages in thread
From: Alex Bennée @ 2019-06-14 17:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée

Hi,

This is v3 of the proposed plugins API for QEMU. As Emilio is busy
having finished his time at Columbia I have volunteered to take the
patch series forward. Emilio's RFC v2 was posted last year:

  Subject: [RFC v2 00/38] Plugin support
  Date: Sun,  9 Dec 2018 14:37:11 -0500
  Message-Id: <20181209193749.12277-1-cota@braap.org>

The idea is to present a plugin interface that allows for interesting
experiments to be written while not exposing the internal details of
how the TCG works to the wider world.

Changes from last year

  - re-basing and fixing up conflicts
  - moved to plugins/ and split files up (core/api/loader)
  - added a design document (docs/devel/plugins.rst)
  - replaced auto-growing structures with glib GArray and friends
  - expanded API to include access to disassembly
  - wrote some more example plugins
  - dropped the RFC tag ;-)

There are a few things left to sort out. Currently the haddr
calculation relies on the softmmu TLB code for each architecture to
dump it in a cpu_env location. Currently this is only done on x86 and
we would require some tweaking to each backend. I think it would
probably be better to just have a wrapper helper which could do the
lookup of the (hot) TLB in C to calculate the address before calling
the helpers.

I also ended up adding a bunch of miscellaneous fixes at the end while
I was re-spinning. If they get some review I'll try and get the
non-controversial stuff up-streamed first.

The area that needs the most review is the single pass TCG op
insertion code. When plugins are enabled each instruction gets dummy
ops inserted and then at the end we swap those out for the actual
calls or remove them from the stream. Hopefully this is not too much
of an abuse of TCG mechanisms.

I'm aiming to get this in for 4.1 but I guess that will depend on how
the review and iteration goes.

Alex Bennée (12):
  docs/devel: add plugins.rst design document
  configure: add --enable-plugins (MOVE TO END)
  plugin: add implementation of the api
  tests/tcg: enable plugin testing
  tests/plugin: add a hotblocks plugin
  plugin: add qemu_plugin_insn_disas helper
  tests/plugin: add instruction execution breakdown
  tests/plugin: add hotpages plugin to breakdown memory access patterns
  accel/stubs: reduce headers from tcg-stub
  include/exec: wrap cpu_ldst.h in CONFIG_TCG
  include/exec/cpu-defs.h: fix typo
  TODO: API changes to make?

Emilio G. Cota (36):
  trace: expand mem_info:size_shift to 3 bits
  tcg/README: fix typo s/afterwise/afterwards/
  cpu: introduce cpu_in_exclusive_work_context()
  translate-all: use cpu_in_exclusive_work_context() in tb_flush
  plugin: add user-facing API
  plugin: add core code
  queue: add QTAILQ_REMOVE_SEVERAL
  cputlb: document get_page_addr_code
  cputlb: introduce get_page_addr_code_hostp
  plugin-gen: add module for TCG-related code
  tcg: add tcg_gen_st_ptr
  tcg: add MO_HADDR to TCGMemOp
  atomic_template: fix indentation in GEN_ATOMIC_HELPER
  atomic_template: add inline trace/plugin helpers
  cpu_ldst_useronly_template: remove redundant #ifndef CODE_ACCESS
  tcg: let plugins instrument memory accesses
  translate-all: notify plugin code of tb_flush
  *-user: notify plugin of exit
  *-user: plugin syscalls
  cpu: hook plugin vcpu events
  plugin-gen: add plugin_insn_append
  translator: add translator_ld{ub,sw,uw,l,q}
  target/arm: call qemu_plugin_insn_append
  target/ppc: fetch code with translator_ld
  target/sh4: fetch code with translator_ld
  target/i386: fetch code with translator_ld
  target/hppa: fetch code with translator_ld
  target/m68k: fetch code with translator_ld
  target/alpha: fetch code with translator_ld
  target/riscv: fetch code with translator_ld
  target/sparc: fetch code with translator_ld
  target/xtensa: fetch code with translator_ld
  target/openrisc: fetch code with translator_ld
  translator: inject instrumentation from plugins
  plugin: add API symbols to qemu-plugins.symbols
  tests/plugin: add sample plugins

Lluís Vilanova (2):
  vl: support -plugin option
  linux-user: support -plugin option

 Makefile                                  |   11 +-
 Makefile.target                           |    2 +
 accel/stubs/tcg-stub.c                    |    3 -
 accel/tcg/Makefile.objs                   |    1 +
 accel/tcg/atomic_template.h               |  117 ++-
 accel/tcg/cpu-exec.c                      |    3 +
 accel/tcg/cputlb.c                        |   56 +-
 accel/tcg/plugin-gen.c                    | 1079 +++++++++++++++++++++
 accel/tcg/plugin-helpers.h                |    6 +
 accel/tcg/translate-all.c                 |   15 +-
 accel/tcg/translator.c                    |   16 +
 bsd-user/syscall.c                        |   12 +
 configure                                 |   86 +-
 cpus-common.c                             |    2 +
 cpus.c                                    |   10 +
 disas.c                                   |  103 ++
 docs/devel/index.rst                      |    1 +
 docs/devel/plugins.rst                    |   99 ++
 exec.c                                    |    2 +
 include/disas/disas.h                     |    2 +
 include/exec/cpu-defs.h                   |   11 +-
 include/exec/cpu_ldst.h                   |    9 +
 include/exec/cpu_ldst_template.h          |   40 +-
 include/exec/cpu_ldst_useronly_template.h |   36 +-
 include/exec/exec-all.h                   |   64 +-
 include/exec/helper-gen.h                 |    1 +
 include/exec/helper-proto.h               |    1 +
 include/exec/helper-tcg.h                 |    1 +
 include/exec/plugin-gen.h                 |   71 ++
 include/exec/translator.h                 |   30 +-
 include/qemu/plugin.h                     |  261 +++++
 include/qemu/qemu-plugin.h                |  349 +++++++
 include/qemu/queue.h                      |   10 +
 include/qom/cpu.h                         |   19 +
 linux-user/exit.c                         |    1 +
 linux-user/main.c                         |   18 +
 linux-user/syscall.c                      |    3 +
 plugins/.gitignore                        |    2 +
 plugins/Makefile.objs                     |   21 +
 plugins/api.c                             |  274 ++++++
 plugins/core.c                            |  524 ++++++++++
 plugins/loader.c                          |  353 +++++++
 plugins/plugin.h                          |   95 ++
 plugins/qemu-plugins.symbols              |   36 +
 qemu-options.hx                           |   17 +
 qom/cpu.c                                 |    2 +
 target/alpha/translate.c                  |    2 +-
 target/arm/translate-a64.c                |    2 +
 target/arm/translate.c                    |    8 +-
 target/hppa/translate.c                   |    2 +-
 target/i386/translate.c                   |   10 +-
 target/m68k/translate.c                   |    2 +-
 target/openrisc/translate.c               |    2 +-
 target/ppc/translate.c                    |    8 +-
 target/riscv/translate.c                  |    2 +-
 target/sh4/translate.c                    |    4 +-
 target/sparc/translate.c                  |    2 +-
 target/xtensa/translate.c                 |    4 +-
 tcg/README                                |    2 +-
 tcg/i386/tcg-target.inc.c                 |    8 +
 tcg/tcg-op.c                              |   40 +-
 tcg/tcg-op.h                              |   16 +
 tcg/tcg-opc.h                             |    3 +
 tcg/tcg.c                                 |   22 +
 tcg/tcg.h                                 |   28 +
 tests/Makefile.include                    |   10 +-
 tests/plugin/Makefile                     |   31 +
 tests/plugin/bb.c                         |   66 ++
 tests/plugin/empty.c                      |   30 +
 tests/plugin/hotblocks.c                  |  145 +++
 tests/plugin/hotpages.c                   |  152 +++
 tests/plugin/howvec.c                     |  297 ++++++
 tests/plugin/insn.c                       |   63 ++
 tests/plugin/mem.c                        |   93 ++
 tests/tcg/Makefile                        |   34 +
 tests/tcg/arm/Makefile.softmmu-target     |    1 +
 trace-events                              |    2 +-
 vl.c                                      |   11 +
 78 files changed, 4855 insertions(+), 122 deletions(-)
 create mode 100644 accel/tcg/plugin-gen.c
 create mode 100644 accel/tcg/plugin-helpers.h
 create mode 100644 docs/devel/plugins.rst
 create mode 100644 include/exec/plugin-gen.h
 create mode 100644 include/qemu/plugin.h
 create mode 100644 include/qemu/qemu-plugin.h
 create mode 100644 plugins/.gitignore
 create mode 100644 plugins/Makefile.objs
 create mode 100644 plugins/api.c
 create mode 100644 plugins/core.c
 create mode 100644 plugins/loader.c
 create mode 100644 plugins/plugin.h
 create mode 100644 plugins/qemu-plugins.symbols
 create mode 100644 tests/plugin/Makefile
 create mode 100644 tests/plugin/bb.c
 create mode 100644 tests/plugin/empty.c
 create mode 100644 tests/plugin/hotblocks.c
 create mode 100644 tests/plugin/hotpages.c
 create mode 100644 tests/plugin/howvec.c
 create mode 100644 tests/plugin/insn.c
 create mode 100644 tests/plugin/mem.c

-- 
2.20.1



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

end of thread, other threads:[~2019-09-27 21:55 UTC | newest]

Thread overview: 117+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 17:11 [Qemu-devel] [PATCH v3 00/50] tcg plugin support Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 01/50] trace: expand mem_info:size_shift to 3 bits Alex Bennée
2019-06-17  2:12   ` Richard Henderson
2019-06-17  8:22     ` Alex Bennée
2019-06-17 23:29       ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 02/50] tcg/README: fix typo s/afterwise/afterwards/ Alex Bennée
2019-06-17  2:13   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 03/50] cpu: introduce cpu_in_exclusive_work_context() Alex Bennée
2019-06-17  2:15   ` Richard Henderson
2019-06-20  9:50     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 04/50] translate-all: use cpu_in_exclusive_work_context() in tb_flush Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 05/50] docs/devel: add plugins.rst design document Alex Bennée
2019-06-19  3:34   ` Pranith Kumar
2019-06-20 13:38     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 06/50] configure: add --enable-plugins (MOVE TO END) Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 07/50] plugin: add user-facing API Alex Bennée
2019-06-19  3:34   ` Pranith Kumar
2019-06-19 11:32     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 08/50] plugin: add core code Alex Bennée
     [not found]   ` <CADYwmhGiU_1GrBrR_tzBx+Lw+Hs3=Hi3AoPxRwkEj2pv9awqUg@mail.gmail.com>
2019-06-19 11:46     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 09/50] plugin: add implementation of the api Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 10/50] queue: add QTAILQ_REMOVE_SEVERAL Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 11/50] cputlb: document get_page_addr_code Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 12/50] cputlb: introduce get_page_addr_code_hostp Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 13/50] plugin-gen: add module for TCG-related code Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 14/50] tcg: add tcg_gen_st_ptr Alex Bennée
2019-06-17 20:19   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 15/50] tcg: add MO_HADDR to TCGMemOp Alex Bennée
2019-06-17 20:43   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 16/50] atomic_template: fix indentation in GEN_ATOMIC_HELPER Alex Bennée
2019-06-17 20:43   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 17/50] atomic_template: add inline trace/plugin helpers Alex Bennée
2019-06-17 20:47   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 18/50] cpu_ldst_useronly_template: remove redundant #ifndef CODE_ACCESS Alex Bennée
2019-06-17 20:47   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 19/50] tcg: let plugins instrument memory accesses Alex Bennée
2019-06-17 20:51   ` Richard Henderson
2019-06-28 15:30   ` Aaron Lindsay OS via Qemu-devel
2019-06-28 17:11     ` Alex Bennée
2019-06-28 17:58       ` Aaron Lindsay OS via Qemu-devel
2019-06-28 20:52         ` Alex Bennée
2019-07-01 14:40           ` Aaron Lindsay OS via Qemu-devel
2019-07-01 15:00             ` Alex Bennée
2019-07-02 14:07               ` Aaron Lindsay OS via Qemu-devel
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 20/50] translate-all: notify plugin code of tb_flush Alex Bennée
2019-06-17 20:54   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 21/50] *-user: notify plugin of exit Alex Bennée
2019-06-17 20:54   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 22/50] *-user: plugin syscalls Alex Bennée
2019-06-17 20:56   ` Richard Henderson
2019-06-19  3:35   ` Pranith Kumar
2019-07-01 14:20     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 23/50] cpu: hook plugin vcpu events Alex Bennée
2019-06-17 21:00   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 24/50] plugin-gen: add plugin_insn_append Alex Bennée
2019-06-17 21:03   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 25/50] translator: add translator_ld{ub, sw, uw, l, q} Alex Bennée
2019-06-17 21:06   ` Richard Henderson
2019-07-30 12:41     ` Alex Bennée
2019-07-30 13:23       ` Richard Henderson
2019-07-30 14:08         ` Alex Bennée
2019-07-30 17:04         ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 26/50] target/arm: call qemu_plugin_insn_append Alex Bennée
2019-06-17 22:28   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 27/50] target/ppc: fetch code with translator_ld Alex Bennée
2019-06-17 22:30   ` Richard Henderson
2019-06-19  9:39   ` David Gibson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 28/50] target/sh4: " Alex Bennée
2019-06-17 22:33   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 29/50] target/i386: " Alex Bennée
2019-06-17 22:33   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 30/50] target/hppa: " Alex Bennée
2019-06-17 22:34   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 31/50] target/m68k: " Alex Bennée
2019-06-17 22:35   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 32/50] target/alpha: " Alex Bennée
2019-06-17 22:35   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 33/50] target/riscv: " Alex Bennée
2019-06-17 22:38   ` Richard Henderson
2019-06-19 10:49     ` Palmer Dabbelt
2019-09-27 21:47       ` Alistair Francis
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 34/50] target/sparc: " Alex Bennée
2019-06-17 22:39   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 35/50] target/xtensa: " Alex Bennée
2019-06-17 22:41   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 36/50] target/openrisc: " Alex Bennée
2019-06-17 22:41   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 37/50] translator: inject instrumentation from plugins Alex Bennée
2019-06-17 22:44   ` Richard Henderson
2019-06-20 16:51     ` Alex Bennée
2019-07-01 16:01     ` Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 38/50] plugin: add API symbols to qemu-plugins.symbols Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 39/50] vl: support -plugin option Alex Bennée
2019-06-17 22:53   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 40/50] linux-user: " Alex Bennée
2019-06-17 22:54   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 41/50] tests/plugin: add sample plugins Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 42/50] tests/tcg: enable plugin testing Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 43/50] tests/plugin: add a hotblocks plugin Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 44/50] plugin: add qemu_plugin_insn_disas helper Alex Bennée
2019-06-17 23:09   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 45/50] tests/plugin: add instruction execution breakdown Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 46/50] tests/plugin: add hotpages plugin to breakdown memory access patterns Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 47/50] accel/stubs: reduce headers from tcg-stub Alex Bennée
2019-06-17 23:22   ` Richard Henderson
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 48/50] include/exec: wrap cpu_ldst.h in CONFIG_TCG Alex Bennée
2019-06-14 17:11 ` [Qemu-devel] [PATCH v3 49/50] include/exec/cpu-defs.h: fix typo Alex Bennée
2019-06-17 23:23   ` Richard Henderson
2019-06-14 17:12 ` [Qemu-devel] [PATCH v3 50/50] TODO: API changes to make? Alex Bennée
2019-06-14 17:41 ` [Qemu-devel] [PATCH v3 00/50] tcg plugin support Aleksandar Markovic
2019-06-14 18:39   ` Alex Bennée
2019-06-14 19:47 ` no-reply
2019-06-14 19:48 ` no-reply
2019-06-20 13:53 ` Pranith Kumar
2019-06-21  8:21   ` Alex Bennée
2019-06-21 17:36     ` Pranith Kumar
2019-07-01 16:51       ` 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).