diff options
| author | Rowan Hart <rowanbhart@gmail.com> | 2025-06-27 12:25:04 +0100 |
|---|---|---|
| committer | Alex Bennée <alex.bennee@linaro.org> | 2025-07-02 10:09:48 +0100 |
| commit | f00373b895da830ef6d0ee9a518e336e8252a4a3 (patch) | |
| tree | f48e4ba334f617cc1349059581d1d3c265e458d9 /plugins/api.c | |
| parent | 766e00bd570f54c8d08023a46cd3386e96ecd39f (diff) | |
| download | focaccia-qemu-f00373b895da830ef6d0ee9a518e336e8252a4a3.tar.gz focaccia-qemu-f00373b895da830ef6d0ee9a518e336e8252a4a3.zip | |
plugins: Add memory virtual address write API
This patch adds functions to the plugins API to allow reading and writing memory via virtual addresses. These functions only permit doing so on the current CPU, because there is no way to ensure consistency if plugins are allowed to read or write to other CPUs that aren't currently in the context of the plugin. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Rowan Hart <rowanbhart@gmail.com> Message-ID: <20250624175351.440780-5-rowanbhart@gmail.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-ID: <20250627112512.1880708-9-alex.bennee@linaro.org>
Diffstat (limited to 'plugins/api.c')
| -rw-r--r-- | plugins/api.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/api.c b/plugins/api.c index 3f04399c26..1f64a9ea64 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -476,6 +476,24 @@ bool qemu_plugin_read_memory_vaddr(uint64_t addr, GByteArray *data, size_t len) return true; } +bool qemu_plugin_write_memory_vaddr(uint64_t addr, GByteArray *data) +{ + g_assert(current_cpu); + + if (data->len == 0) { + return false; + } + + int result = cpu_memory_rw_debug(current_cpu, addr, data->data, + data->len, true); + + if (result < 0) { + return false; + } + + return true; +} + struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size) { return plugin_scoreboard_new(element_size); |