[PATCH v4 5/9] plugins: Add memory hardware address read/write API

2025-05-22 Thread Rowan Hart
to permit a specified address space, for example to facilitate architecture-specific plugins that want to operate on them, for example reading ARM secure memory. Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 93 plugins

[PATCH v4 4/9] plugins: Add memory virtual address write API

2025-05-22 Thread Rowan Hart
x27;t currently in the context of the plugin. Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 21 + plugins/api.c | 18 ++ 2 files changed, 39 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu

[PATCH v4 6/9] plugins: Add patcher plugin and test

2025-05-22 Thread Rowan Hart
: novafacing Signed-off-by: Rowan Hart --- tests/tcg/Makefile.target | 1 + tests/tcg/plugins/meson.build | 2 +- tests/tcg/plugins/patch.c | 302 ++ tests/tcg/x86_64/Makefile.softmmu-target | 32 ++- tests/tcg/x86_64/system/patch

[PATCH v4 0/9] Add additional plugin API functions to read and write memory and registers

2025-05-22 Thread Rowan Hart
of these functions in the future if we change our minds! Rowan Hart (2): plugins: Add enforcement of QEMU_PLUGIN_CB flags in register R/W callbacks plugins: Remove use of qemu_plugin_read_register where it is not permitted novafacing (7): gdbstub: Expose gdb_write_register functio

[PATCH v4 7/9] plugins: Add hypercalls plugin and test

2025-05-22 Thread Rowan Hart
From: novafacing This patch adds a plugin that implements a simple form of hypercalls from guest code to the plugin by using the register read API. It accepts only one hypercall, which writes a magic value to guest memory. Signed-off-by: novafacing Signed-off-by: Rowan Hart --- tests/tcg

[PATCH v4 3/9] plugins: Add enforcement of QEMU_PLUGIN_CB flags in register R/W callbacks

2025-05-22 Thread Rowan Hart
functions (in particular, the register read and write API) will call qemu_plugin_get_cb_flags() to check the level is at least the level they require. Signed-off-by: Rowan Hart --- accel/tcg/plugin-gen.c | 27 + include/qemu/plugin.h | 12 include/qemu/qemu-plugin.h

[PATCH v4 8/9] plugins: Remove use of qemu_plugin_read_register where it is not permitted

2025-05-22 Thread Rowan Hart
flags are enforced and qemu_plugin_read_register can no longer be called from a vcpu_init callback because it does not request the QEMU_PLUGIN_CB_ flag (nor does it have a mechanism to do so). Signed-off-by: Rowan Hart --- tests/tcg/plugins/insn.c | 22 +- 1 file changed, 1

[PATCH v4 2/9] plugins: Add register write API

2025-05-22 Thread Rowan Hart
From: novafacing This patch adds a function to the plugins API to allow plugins to write register contents. It also moves the qemu_plugin_read_register function so all the register-related functions are grouped together in the file. Signed-off-by: novafacing Signed-off-by: Rowan Hart

[PATCH v4 1/9] gdbstub: Expose gdb_write_register function to consumers of gdbstub

2025-05-22 Thread Rowan Hart
From: novafacing This patch exposes the gdb_write_register function from gdbstub/gdbstub.c via the exec/gdbstub.h header file to support use in plugins to write register contents. Signed-off-by: novafacing Signed-off-by: Rowan Hart --- gdbstub/gdbstub.c | 2 +- include/exec/gdbstub.h

[PATCH v4 9/9] plugins: Update plugin version and add notes

2025-05-22 Thread Rowan Hart
From: novafacing This patch updates the plugin version to gate new APIs and adds notes describing what has been added. Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu

Re: [PATCH v3 5/8] Add memory hardware address read/write API

2025-05-22 Thread Rowan Hart
> > > > This definition strikes me as odd. What was your reason to assert > > `current_cpu` here, but not in the other two functions? Also a bit > > surprising is the declaration of `cpu` if you use it in just one place > > (rather than just use `current_cpu` directly as for the assertion). > > > >

Re: [PATCH v3 2/8] Add register write API

2025-05-22 Thread Rowan Hart
> a) handle the QEMU_PLUGIN_CB_RW_REGS I missed that this was not already handled. I'll fix that. > b) try and enforce we are only being called from such callbacks Sure, beyond documentation I suppose we can add and check a flag to ensure this. I think it's a good idea to reduce foot guns from

Re: [PATCH v3 2/8] Add register write API

2025-05-22 Thread Rowan Hart
Hi Julian, > Again, what was the reason for moving `qemu_plugin_read_register`? I moved it so it's grouped with get_registers above instead of being separated below the memory functions. I can move it back, just seemed nicer that way. -Rowan On Thu, May 22, 2025, 4:59 AM Julian Ganz wrote: >

Re: [PATCH v3 5/8] Add memory hardware address read/write API

2025-05-21 Thread Rowan Hart
Well, first I just noticed that I left a debug print in this function! So I'll fix that. Reading this patch, and patch 3 (Add address space API), I am not sure AddressSpace is something we want to leak in plugins interface. It is a concept *very* internal to QEMU, and not reflecting directly s

[PATCH v3 2/8] Add register write API

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 57 +- plugins/api.c | 26 - 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/include/qemu/qemu-plugin.h b

[PATCH v3 1/8] Expose gdb_write_register function to consumers of gdbstub

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- gdbstub/gdbstub.c | 2 +- include/exec/gdbstub.h | 14 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 565f6b33a9..5846e481be 100644 --- a

[PATCH v3 7/8] Add hypercalls plugin and test

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- tests/tcg/Makefile.target | 1 + tests/tcg/plugins/hypercalls.c| 552 ++ tests/tcg/plugins/meson.build | 2 +- tests/tcg/x86_64/Makefile.softmmu

[PATCH v3 3/8] Add address space API

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/plugin.h | 6 +++ include/qemu/qemu-plugin.h | 45 ++ plugins/api.c | 79 ++ 3 files changed, 130 insertions(+) diff --git a

[PATCH v3 6/8] Add patcher plugin and test

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- tests/tcg/Makefile.target | 1 + tests/tcg/plugins/meson.build | 2 +- tests/tcg/plugins/patch.c | 324 ++ tests/tcg/x86_64/Makefile.softmmu-target

[PATCH v3 5/8] Add memory hardware address read/write API

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 96 +++ plugins/api.c | 100 + 2 files changed, 196 insertions(+) diff --git a/include/qemu/qemu-plugin.h b

[PATCH v3 0/8] Add additional plugin API functions to read and write memory and registers

2025-05-21 Thread 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 ut

[PATCH v3 4/8] Add memory virtual address write API

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 21 + plugins/api.c | 18 ++ 2 files changed, 39 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index

[PATCH v3 8/8] Update plugin version and add notes

2025-05-21 Thread Rowan Hart
From: novafacing Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index d4f229abd9..4cf2955560 100644 --- a/include/qemu/qemu-plugin.h +++ b/include

Re: [PATCH v2 3/3] Add inject plugin and x86_64 target for the inject plugin

2024-12-06 Thread Rowan Hart
>> +++ b/tests/tcg/plugins/inject.c > > Could we find a better name? For sure, maybe "hypercalls.c" since that's really what it's mostly about. >> @@ -0,0 +1,206 @@ >> +/* >> + * Copyright (C) 2024, Rowan Hart >> + * >> + * Licen

Re: [PATCH v2 0/3] Add additional plugin API functions to read and write memory and registers

2024-12-06 Thread Rowan Hart
> I am personally in favor to adding such features in upstream QEMU, but we > should discuss it with the maintainers, because it would allow to change the > state of execution, which is something qemu plugins actively didn't try to > do. It's a real paradigm shift for plugins. > > By writing to

[PATCH v2 1/3] Expose gdb_write_register function to consumers of gdbstub

2024-12-06 Thread Rowan Hart
From: novafacing --- gdbstub/gdbstub.c | 2 +- include/exec/gdbstub.h | 14 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b1def7e71d..7d87a3324c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -536,7 +536

[PATCH v2 3/3] Add inject plugin and x86_64 target for the inject plugin

2024-12-06 Thread Rowan Hart
tests/tcg/plugins/inject.c create mode 100644 tests/tcg/x86_64/inject-target.c diff --git a/tests/tcg/plugins/inject.c b/tests/tcg/plugins/inject.c new file mode 100644 index 00..9edc2cd34e --- /dev/null +++ b/tests/tcg/plugins/inject.c @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2024, Rowan

[PATCH v2 2/3] Add plugin API functions for register R/W, hwaddr R/W, vaddr W

2024-12-06 Thread Rowan Hart
From: novafacing --- include/qemu/qemu-plugin.h | 116 + plugins/api.c | 66 - 2 files changed, 168 insertions(+), 14 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 0fba36ae02..b812593

[PATCH v2 0/3] Add additional plugin API functions to read and write memory and registers

2024-12-06 Thread Rowan Hart
This patch set follows a previous patch which added the qemu_plugin_read_memory_vaddr function and adds a set of similar functions to read and write registers, virtual memory, and physical memory. The use case I have in mind is for use of QEMU for program analysis and testing. For example, a fuzze

[PATCH 2/2] Add plugin API functions for register R/W, hwaddr R/W, vaddr W

2024-12-06 Thread Rowan Hart
From: novafacing --- include/qemu/qemu-plugin.h | 116 + plugins/api.c | 66 - 2 files changed, 168 insertions(+), 14 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 0fba36ae02..b812593

[PATCH 0/2] Add additional plugin API functions to read and write memory and registers

2024-12-06 Thread Rowan Hart
This patch set follows a previous patch which added the qemu_plugin_read_memory_vaddr function and adds a set of similar functions to read and write registers, virtual memory, and physical memory. The use case I have in mind is for use of QEMU for program analysis and testing. For example, a fuzze

[PATCH 1/2] Expose gdb_write_register function to consumers of gdbstub

2024-12-06 Thread Rowan Hart
From: novafacing --- gdbstub/gdbstub.c | 2 +- include/exec/gdbstub.h | 14 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b1def7e71d..7d87a3324c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -536,7 +536

Re: [PATCH 0/1] plugins: add API to read guest CPU memory from hwaddr

2024-09-17 Thread Rowan Hart
> > See: > > tests/tcg/i386/system/boot.S > tests/tcg/alpha/system/boot.S > tests/tcg/loongarch64/system/boot.S > tests/tcg/aarch64/system/boot.S > tests/tcg/x86_64/system/boot.S > tests/tcg/arm/system/boot.S > > for what is needed (basically a MMU-enabled flat memory map and some >

[PATCH v2 0/1] plugins: add API to read guest CPU memory from hwaddr

2024-08-29 Thread Rowan Hart
00 00 00 00 00 00 00 00 00 00 00 00 00 | Hello, RISC-V! For v2, removes a symbol left in qemu-plugins.symbols accidentally. Rowan Hart (1): plugins: add API to read guest CPU memory from hwaddr include/qemu/qemu-plugin.h | 22 ++ plugins/

[PATCH v2 1/1] plugins: add API to read guest CPU memory from hwaddr

2024-08-29 Thread Rowan Hart
Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 22 ++ plugins/api.c| 17 + plugins/qemu-plugins.symbols | 1 + 3 files changed, 40 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index

Re: [PATCH 1/1] plugins: add API to read guest CPU memory from hwaddr

2024-08-28 Thread Rowan Hart
> + qemu_plugin_read_cpu_memory_hwaddr; > + qemu_plugin_read_io_memory_hwaddr; This second symbol name should be removed, I initially wanted to implement for IO as well but there is no good generic way I can see to access a list of IO AddressSpace to read from.

[PATCH 1/1] plugins: add API to read guest CPU memory from hwaddr

2024-08-27 Thread Rowan Hart
Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 22 ++ plugins/api.c| 17 + plugins/qemu-plugins.symbols | 2 ++ 3 files changed, 41 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index

[PATCH 0/1] plugins: add API to read guest CPU memory from hwaddr

2024-08-27 Thread Rowan Hart
00 00 00 00 00 00 00 00 00 00 00 00 00 | Hello, RISC-V! Rowan Hart (1): plugins: add API to read guest CPU memory from hwaddr include/qemu/qemu-plugin.h | 22 ++ plugins/api.c| 17 + plugins/qemu-plugins.symbols | 2 ++ 3

[PATCH v3 2/2] plugins: add option to dump write argument to syscall plugin

2024-08-27 Thread Rowan Hart
Signed-off-by: Rowan Hart Reviewed-by: Pierrick Bouvier Tested-by: Pierrick Bouvier --- docs/about/emulation.rst| 14 - tests/tcg/plugins/syscall.c | 117 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b

[PATCH v3 0/2] plugins: add plugin API to read guest memory

2024-08-27 Thread Rowan Hart
doc build issue. Rowan Hart (2): plugins: add plugin API to read guest memory plugins: add option to dump write argument to syscall plugin docs/about/emulation.rst | 14 - include/qemu/qemu-plugin.h | 32 +- plugins/api.c| 20 ++ plugins/qemu-plugi

[PATCH v3 1/2] plugins: add plugin API to read guest memory

2024-08-27 Thread Rowan Hart
Signed-off-by: Rowan Hart Reviewed-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 32 +++- plugins/api.c| 20 plugins/qemu-plugins.symbols | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include

[PATCH v2 2/2] plugins: add option to dump write argument to syscall plugin

2024-08-26 Thread Rowan Hart
Signed-off-by: Rowan Hart --- docs/about/emulation.rst| 14 - tests/tcg/plugins/syscall.c | 117 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index eea1261baa..e85d494ff0 100644

[PATCH v2 1/2] plugins: add plugin API to read guest memory

2024-08-26 Thread Rowan Hart
Signed-off-by: Rowan Hart --- include/qemu/qemu-plugin.h | 32 +++- plugins/api.c| 20 plugins/qemu-plugins.symbols | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu

[PATCH v2 0/2] plugins: add plugin API to read guest memory

2024-08-26 Thread Rowan Hart
) * Accurate and easier execution trace extraction * Debugging and logging tools An example of its use is added to the existing syscalls plugin, which now has an option to hexdump the buf argument to any write(2) syscalls which occur. Rowan Hart (2): plugins: add plugin API to read guest memory

Re: [PATCH] plugins: add plugin API to read guest memory

2024-08-26 Thread Rowan Hart
Alex, Thanks for the additional information. >> >> A key aspect of what you propose here, is that the memory may have >> changed during the write time, and when you read it, while what we >> propose guarantees to track every change correctly. >> >> It's not a bad thing, and both API are definitel

Re: [PATCH] plugins: add plugin API to read guest memory

2024-08-26 Thread Rowan Hart
Alex & Pierrick, Thank you for the feedback! This is my first contribution to QEMU, so I'm glad it at least passes the initial smell test :) > I'll make my comments in this patch, but for v2, please split those individual > commits, and a cover letter, describing your changes (https://github.com/

[PATCH] plugins: add plugin API to read guest memory

2024-08-21 Thread Rowan Hart
Signed-off-by: Rowan Hart --- docs/about/emulation.rst | 16 - include/qemu/qemu-plugin.h | 24 +++- plugins/api.c| 21 +++ plugins/qemu-plugins.symbols | 1 + tests/tcg/plugins/mem.c | 37 +++- tests/tcg/plugins/syscall.c | 113

QEMU Rust Crates + Plugins in Rust

2022-11-09 Thread Rowan Hart
Hi all, this is my first post to the mailing list! I've spent the last couple weeks building QEMU Rust crates to enable a couple goals: - Install QEMU binaries using cargo, the Rust package manager - Use git-latest QEMU binaries in Rust projects as a dependency - Write QEMU TCG plugins entirely in