qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] Add additional plugin API functions to read and write memory and registers
@ 2025-05-21  9:43 Rowan Hart
  2025-05-21  9:43 ` [PATCH v3 1/8] Expose gdb_write_register function to consumers of gdbstub Rowan Hart
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Rowan Hart @ 2025-05-21  9:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Alexandre Iooss, Richard Henderson,
	Alex Bennée, Eduardo Habkost, Philippe Mathieu-Daudé,
	Mahmoud Mandour, Paolo Bonzini, Rowan Hart

This patch series adds several new API functions focused on enabling use
cases around reading and writing guest memory from QEMU plugins. To support
these new APIs, some utility functionality around retrieving information about
address spaces is added as well.

The new qemu_plugin_write_register utilizes gdb_write_register, which is now
declared in gdbstub.h for this purpose instead of being static.

qemu_plugin_write_memory_vaddr utilizes cpu_memory_rw_debug much the same as
the existing read_memory_vaddr function does.

The read and write_hwaddr functions are the most different. These functions
use address_space_rw, which works well in most cases. There is an important
caveat that for writes, the page being written will be set dirty by the
write operation. This dirty setting requires locking the page range,
which can contend with an already held lock in page_collection_lock
when called in a tb translate callback with a write to the instruction
memory in the tb. The doc comments warn against doing this, and it's unlikely
anyone would want to do this.

I've also added two test plugins: one that implements a simple hypercall
interface that guest code can use to communicate with the plugin in a
structured way with a test to ensure that this hypercall works and writing
virtual memory works. And one that implements a simple patch utility to patch
memory at runtime. The test for the second plugin ensures the patch applies
successfully to instruction memory, and can use both hw and vaddr methods.

novafacing (8):
  Expose gdb_write_register function to consumers of gdbstub
  Add register write API
  Add address space API
  Add memory virtual address write API
  Add memory hardware address read/write API
  Add patcher plugin and test
  Add hypercalls plugin and test
  Update plugin version and add notes

 gdbstub/gdbstub.c                             |   2 +-
 include/exec/gdbstub.h                        |  14 +
 include/qemu/plugin.h                         |   6 +
 include/qemu/qemu-plugin.h                    | 217 ++++++-
 plugins/api.c                                 | 213 ++++++-
 tests/tcg/Makefile.target                     |   2 +
 tests/tcg/plugins/hypercalls.c                | 552 ++++++++++++++++++
 tests/tcg/plugins/meson.build                 |   2 +-
 tests/tcg/plugins/patch.c                     | 324 ++++++++++
 tests/tcg/x86_64/Makefile.softmmu-target      |  36 +-
 tests/tcg/x86_64/system/hypercalls-target.c   |  45 ++
 tests/tcg/x86_64/system/patch-target.c        |  32 +
 .../tcg/x86_64/system/validate-hypercalls.py  |  40 ++
 tests/tcg/x86_64/system/validate-patch.py     |  39 ++
 14 files changed, 1501 insertions(+), 23 deletions(-)
 create mode 100644 tests/tcg/plugins/hypercalls.c
 create mode 100644 tests/tcg/plugins/patch.c
 create mode 100644 tests/tcg/x86_64/system/hypercalls-target.c
 create mode 100644 tests/tcg/x86_64/system/patch-target.c
 create mode 100755 tests/tcg/x86_64/system/validate-hypercalls.py
 create mode 100755 tests/tcg/x86_64/system/validate-patch.py

-- 
2.49.0



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

end of thread, other threads:[~2025-05-22 22:38 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21  9:43 [PATCH v3 0/8] Add additional plugin API functions to read and write memory and registers Rowan Hart
2025-05-21  9:43 ` [PATCH v3 1/8] Expose gdb_write_register function to consumers of gdbstub Rowan Hart
2025-05-21 22:52   ` Pierrick Bouvier
2025-05-22  8:53   ` Manos Pitsidianakis
2025-05-22 11:59   ` Julian Ganz
2025-05-21  9:43 ` [PATCH v3 2/8] Add register write API Rowan Hart
2025-05-21 22:52   ` Pierrick Bouvier
2025-05-22 11:59   ` Julian Ganz
2025-05-22 15:02     ` Rowan Hart
2025-05-22 15:16       ` Julian Ganz
2025-05-22 15:39   ` Alex Bennée
2025-05-22 20:11     ` Rowan Hart
2025-05-21  9:43 ` [PATCH v3 3/8] Add address space API Rowan Hart
2025-05-21  9:43 ` [PATCH v3 4/8] Add memory virtual address write API Rowan Hart
2025-05-21 22:53   ` Pierrick Bouvier
2025-05-21  9:43 ` [PATCH v3 5/8] Add memory hardware address read/write API Rowan Hart
2025-05-21 23:18   ` Pierrick Bouvier
2025-05-22  3:34     ` Rowan Hart
2025-05-22 19:46       ` Pierrick Bouvier
2025-05-22 11:59   ` Julian Ganz
2025-05-22 19:16     ` Pierrick Bouvier
2025-05-22 21:01       ` Rowan Hart
2025-05-22 22:37         ` Pierrick Bouvier
2025-05-21  9:43 ` [PATCH v3 6/8] Add patcher plugin and test Rowan Hart
2025-05-21  9:43 ` [PATCH v3 7/8] Add hypercalls " Rowan Hart
2025-05-21  9:43 ` [PATCH v3 8/8] Update plugin version and add notes Rowan Hart

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).