Skip to contentSkip to conversation

execlog TCG plugin to log instructions

PATCH Applied Alexandre Iooss 2 participants 4 messages Jul 2, 2021 – Jul 5, 2021

lore
Share & tools
lore
#0 lore raw

v3 cover execlog TCG plugin to log instructions

execlog is a plugin that logs executed instructions with some useful metadata including memory access.

The output of the plugin is designed to be usable with other tools. For example it could be used with a side-channel leakage model to create side-channel traces from QEMU for security evaluation.

Changes since v2:
- Fix typo "tvg-plugins" to "tcg-plugins" in commit title.
- Add warning about plugin output size in documentation.
- Fix user mode tracing by using a dynamic list.
- Fix last instructions not being logged.
- Remove empty first line in plugin output.

Changes since v1:
- The output is now easier to parse.
- Use QEMU logging API rather than FILE* to write output.
- Don't reject memory information in user mode.
- Merge memory information with instruction execution. Now one line means one instruction.
- Add documentation.

Alexandre Iooss (2):
contrib/plugins: add execlog to log instruction execution and memory
access
docs/devel: tcg-plugins: add execlog plugin description

 MAINTAINERS                |   1 +
 contrib/plugins/Makefile   |   1 +
 contrib/plugins/execlog.c  | 153 +++++++++++++++++++++++++++++++++++++
 docs/devel/tcg-plugins.rst |  24 ++++++
 4 files changed, 179 insertions(+)
 create mode 100644 contrib/plugins/execlog.c
Signature · 1 line
2.31.1
#1 lore raw

PATCH v3 1/2 contrib/plugins: add execlog to log instruction execution and memory access

Log instruction execution and memory access to a file.
This plugin can be used for reverse engineering or for side-channel analysis using QEMU.

---
 MAINTAINERS               |   1 +
 contrib/plugins/Makefile  |   1 +
 contrib/plugins/execlog.c | 153 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 contrib/plugins/execlog.c
MAINTAINERS +1 -0
index cfbf7ef79b..709ae43864 100644
@@ -2978,6 +2978,7 @@ F: include/tcg/
 
 TCG Plugins
 M: Alex Bennée <[email protected]>
+R: Alexandre Iooss <[email protected]>
 S: Maintained
 F: docs/devel/tcg-plugins.rst
 F: plugins/
contrib/plugins/Makefile +1 -0
index b9d7935e5e..51093acd17 100644
@@ -13,6 +13,7 @@ include $(BUILD_DIR)/config-host.mak
 VPATH += $(SRC_PATH)/contrib/plugins
 
 NAMES :=
+NAMES += execlog
 NAMES += hotblocks
 NAMES += hotpages
 NAMES += howvec
contrib/plugins/execlog.c new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.31.1
#2 lore raw

PATCH v3 2/2 docs/devel: tcg-plugins: add execlog plugin description

In reply to Alexandre Iooss

This adds description of the execlog TCG plugin with an example.

---
 docs/devel/tcg-plugins.rst | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
docs/devel/tcg-plugins.rst +24 -0
index 18c6581d85..c1e589693c 100644
@@ -319,3 +319,27 @@ the user to see what hardware is accessed how often. It has a number of options:
       off:0000001c, 1, 2
       off:00000020, 1, 2
       ...
+
+- contrib/plugins/execlog.c
+
+The execlog tool traces executed instructions with memory access. It can be used
+for debugging and security analysis purposes.
+Please be aware that this will generate a lot of output.
+
+The plugin takes no argument::
+
+  qemu-system-arm $(QEMU_ARGS) \
+    -plugin ./contrib/plugins/libexeclog.so -d plugin
+
+which will output an execution trace following this structure::
+
+  # vCPU, vAddr, opcode, disassembly[, load/store, memory addr, device]...
+  0, 0xa12, 0xf8012400, "movs r4, #0"
+  0, 0xa14, 0xf87f42b4, "cmp r4, r6"
+  0, 0xa16, 0xd206, "bhs #0xa26"
+  0, 0xa18, 0xfff94803, "ldr r0, [pc, #0xc]", load, 0x00010a28, RAM
+  0, 0xa1a, 0xf989f000, "bl #0xd30"
+  0, 0xd30, 0xfff9b510, "push {r4, lr}", store, 0x20003ee0, RAM, store, 0x20003ee4, RAM
+  0, 0xd32, 0xf9893014, "adds r0, #0x14"
+  0, 0xd34, 0xf9c8f000, "bl #0x10c8"
+  0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM
Signature · 1 line
2.31.1
Applied
#3 lore raw
In reply to Alexandre Iooss
Quoted 6 lines · Alexandre Iooss

execlog is a plugin that logs executed instructions with some useful metadata including memory access.

The output of the plugin is designed to be usable with other tools. For example it could be used with a side-channel leakage model to create side-channel traces from QEMU for security evaluation.

Queued to plugins/next, thanks.

Quoted 27 lines

Changes since v2:
- Fix typo "tvg-plugins" to "tcg-plugins" in commit title.
- Add warning about plugin output size in documentation.
- Fix user mode tracing by using a dynamic list.
- Fix last instructions not being logged.
- Remove empty first line in plugin output.

Changes since v1:
- The output is now easier to parse.
- Use QEMU logging API rather than FILE* to write output.
- Don't reject memory information in user mode.
- Merge memory information with instruction execution. Now one line means one instruction.
- Add documentation.

Alexandre Iooss (2):
contrib/plugins: add execlog to log instruction execution and memory
access
docs/devel: tcg-plugins: add execlog plugin description

 MAINTAINERS                |   1 +
 contrib/plugins/Makefile   |   1 +
 contrib/plugins/execlog.c  | 153 +++++++++++++++++++++++++++++++++++++
 docs/devel/tcg-plugins.rst |  24 ++++++
 4 files changed, 179 insertions(+)
 create mode 100644 contrib/plugins/execlog.c
Signature · 1 line
Alex Bennée