All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH v2 0/7] QEMU binary instrumentation prototype
@ 2018-06-05 10:39 Pavel Dovgalyuk
  2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 1/7] tcg: add headers for non-target helpers Pavel Dovgalyuk
                   ` (11 more replies)
  0 siblings, 12 replies; 43+ messages in thread
From: Pavel Dovgalyuk @ 2018-06-05 10:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, maria.klimushenkova, dovgaluk, pavel.dovgaluk,
	pbonzini, vilanova

The following series implements dynamic binary instrumentation upon QEMU.

It is based on the following prior sources:
 - KVM Forum 2017 talk "Instrumenting, Introspection, and Debugging with QEMU"
   https://www.linux-kvm.org/images/3/3d/Introspect.pdf
 - Discussion on Lluis Vilanova instrumentation patch series
   https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03357.html

There are many implementations of the instrumentation for QEMU.
We have our own attempt on github: https://github.com/ispras/qemu/tree/plugins
But this series differ from that approach and it is intended
to provide a stable interface for adding and extending the QEMU binary
analysis functions.

We propose adding new instrumentation API for QEMU which will include
the following parts:
 - some translator modifications to enable instrumenting the instructions
   (and memory operations in the next version of the patches)
 - dynamic binary instrumentation part (a sample which is currently submitted
   in this RFC series)
 - subsystem for dynamically loaded plugins that interact with this API

The aim of the instrumentation is implementing different runtime
tracers that can track the executed instructions, memory and
hardware operations. The implementation should not incur too much
overhead to make memory tracing as efficient as it is possible
for this heavy task.

The plugins should not have too many dependencies from the QEMU
core. They should be built as a separate projects using just
a couple of the headers.

For the current patches the plugins should provide the following
callbacks:
 - "needs" callback to check whether the specific instruction
   should be instrumented by this plugin
 - "run" callback which called before executing the instuction

Our instrumentation subsystem exploits TCG helper mechanism to embed
callbacks into the translation blocks. These callbacks may be inserted
before the specific instructions.

The aim of submission of this series at that early stage is to get
the feedback which will guide the development process. We are faced
the following questions:
 1. Does every plugins should have its own callback embedded into the TB
    (which will cause TB extra growth in case of multiple plugins),
    or the instrumentation layer's callback should invoke the plugins
    that wanted to instrument that specific instruction?
 2. How the plugins should function? Will they work as a binary dynamic
    libraries or a script on some interpreted language?
 3. Should the plugins reuse QEMU configuration script results?
    Now there is no possibility for using platform-specific macros
    generated by QEMU configure.
 4. Maybe QEMU module infrastructure should be extended to support
    plugins too?
 5. How the GDB-related CPU inspection interface may be used better?
    We should pass a register code to read the value. These codes
    are not described in any of the files. Maybe a function for
    accessing register by name should be added?


v2 changes:
 - added a subsystem for the plugins
 - added QEMU side API for plugins
 - added sample plugins for simple tracing

---

Pavel Dovgalyuk (7):
      tcg: add headers for non-target helpers
      Add plugin support
      plugins: provide helper functions for plugins
      tcg: add instrumenting module
      plugins: add plugin template
      plugin: add instruction execution logger
      plugins: add syscall logging plugin sample


 Makefile.target                   |    1 
 accel/tcg/translator.c            |    5 +
 configure                         |   14 ++++
 include/exec/helper-register.h    |   53 +++++++++++++++
 include/qemu/instrument.h         |    7 ++
 include/qemu/plugins.h            |    8 ++
 plugins/exec-log/Makefile         |   19 +++++
 plugins/exec-log/exec-log.c       |   18 +++++
 plugins/helper.h                  |    1 
 plugins/include/plugins.h         |   18 +++++
 plugins/plugins.c                 |  132 +++++++++++++++++++++++++++++++++++++
 plugins/qemulib.c                 |   31 +++++++++
 plugins/syscall-log/Makefile      |   19 +++++
 plugins/syscall-log/syscall-log.c |   44 ++++++++++++
 plugins/template/Makefile         |   19 +++++
 plugins/template/template.c       |   19 +++++
 qemu-options.hx                   |   10 +++
 tcg/tcg.c                         |   12 +++
 tcg/tcg.h                         |    3 +
 vl.c                              |    8 ++
 20 files changed, 440 insertions(+), 1 deletion(-)
 create mode 100644 include/exec/helper-register.h
 create mode 100644 include/qemu/instrument.h
 create mode 100644 include/qemu/plugins.h
 create mode 100644 plugins/exec-log/Makefile
 create mode 100644 plugins/exec-log/exec-log.c
 create mode 100644 plugins/helper.h
 create mode 100644 plugins/include/plugins.h
 create mode 100644 plugins/plugins.c
 create mode 100644 plugins/qemulib.c
 create mode 100644 plugins/syscall-log/Makefile
 create mode 100644 plugins/syscall-log/syscall-log.c
 create mode 100644 plugins/template/Makefile
 create mode 100644 plugins/template/template.c

--
Pavel Dovgalyuk

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

end of thread, other threads:[~2018-09-13  6:55 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 10:39 [Qemu-devel] [RFC PATCH v2 0/7] QEMU binary instrumentation prototype Pavel Dovgalyuk
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 1/7] tcg: add headers for non-target helpers Pavel Dovgalyuk
2018-06-05 13:07   ` Thomas Huth
2018-06-06  7:30     ` Pavel Dovgalyuk
2018-09-07 12:16   ` Alex Bennée
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 2/7] Add plugin support Pavel Dovgalyuk
2018-09-07 10:11   ` Alex Bennée
2018-09-13  6:40     ` Pavel Dovgalyuk
2018-09-07 12:34   ` Alex Bennée
2018-09-10  8:30     ` Pavel Dovgalyuk
2018-09-07 14:14   ` Alex Bennée
2018-09-10 11:41     ` Pavel Dovgalyuk
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 3/7] plugins: provide helper functions for plugins Pavel Dovgalyuk
2018-09-07 13:06   ` Alex Bennée
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 4/7] tcg: add instrumenting module Pavel Dovgalyuk
2018-09-07 13:36   ` Alex Bennée
2018-09-13  6:55     ` Pavel Dovgalyuk
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 5/7] plugins: add plugin template Pavel Dovgalyuk
2018-09-07 13:41   ` Alex Bennée
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 6/7] plugin: add instruction execution logger Pavel Dovgalyuk
2018-09-07 13:59   ` Alex Bennée
2018-06-05 10:39 ` [Qemu-devel] [RFC PATCH v2 7/7] plugins: add syscall logging plugin sample Pavel Dovgalyuk
2018-09-07 14:06   ` Alex Bennée
2018-09-10  9:18     ` Pavel Dovgalyuk
2018-09-10 13:58       ` Alex Bennée
2018-06-05 10:49 ` [Qemu-devel] [RFC PATCH v2 0/7] QEMU binary instrumentation prototype Peter Maydell
2018-06-05 11:56   ` Pavel Dovgalyuk
2018-06-25  5:46     ` Pavel Dovgalyuk
2018-06-25  9:06       ` Peter Maydell
2018-09-07 14:10       ` Alex Bennée
2018-07-10 13:06     ` Stefan Hajnoczi
2018-07-11  6:02       ` Pavel Dovgalyuk
2018-07-30 13:26         ` Pavel Dovgalyuk
2018-08-29  5:39       ` Pavel Dovgalyuk
2018-08-29 19:57         ` Peter Maydell
2018-08-30  4:03           ` Alex Bennée
2018-06-06  8:52 ` no-reply
2018-06-06  9:21 ` no-reply
2018-06-06 10:45 ` no-reply
2018-09-07 14:39 ` Alex Bennée
2018-09-08  0:57   ` Peter Maydell
2018-09-10  9:01     ` Alex Bennée
2018-09-10 11:44       ` Pavel Dovgalyuk

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.