Browse Source

plugins: add read-only property for registers

Some registers should be marked as read-only from a plugin API
perspective, as writing to them via qemu_plugin_write_register has no
effect. This includes the program counter, and we expose this fact to
the plugins with this patch.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Florian Hofhammer <florian.hofhammer@epfl.ch>
Link: https://lore.kernel.org/qemu-devel/20260305-setpc-v5-v7-6-4c3adba52403@epfl.ch
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
master
Florian Hofhammer 4 weeks ago
committed by Pierrick Bouvier
parent
commit
3ebd871cbd
  1. 3
      include/plugins/qemu-plugin.h
  2. 16
      plugins/api.c

3
include/plugins/qemu-plugin.h

@ -979,11 +979,14 @@ struct qemu_plugin_register;
* writing value with qemu_plugin_write_register
* @name: register name
* @feature: optional feature descriptor, can be NULL
* @is_readonly: true if the register cannot be written via
* qemu_plugin_write_register
*/
typedef struct {
struct qemu_plugin_register *handle;
const char *name;
const char *feature;
bool is_readonly;
} qemu_plugin_reg_descriptor;
/**

16
plugins/api.c

@ -410,6 +410,12 @@ bool qemu_plugin_bool_parse(const char *name, const char *value, bool *ret)
* ancillary data the plugin might find useful.
*/
static const char pc_str[] = "pc"; /* generic name for program counter */
static const char eip_str[] = "eip"; /* x86-specific name for PC */
static const char rip_str[] = "rip"; /* x86_64-specific name for PC */
static const char pswa_str[] = "pswa"; /* s390x-specific name for PC */
static const char iaoq_str[] = "iaoq"; /* HP/PA-specific name for PC */
static const char rpc_str[] = "rpc"; /* microblaze-specific name for PC */
static GArray *create_register_handles(GArray *gdbstub_regs)
{
GArray *find_data = g_array_new(true, true,
@ -427,6 +433,16 @@ static GArray *create_register_handles(GArray *gdbstub_regs)
/* Create a record for the plugin */
desc.handle = GINT_TO_POINTER(grd->gdb_reg + 1);
desc.name = g_intern_string(grd->name);
desc.is_readonly = false;
if (g_strcmp0(desc.name, pc_str) == 0
|| g_strcmp0(desc.name, eip_str) == 0
|| g_strcmp0(desc.name, rip_str) == 0
|| g_strcmp0(desc.name, pswa_str) == 0
|| g_strcmp0(desc.name, iaoq_str) == 0
|| g_strcmp0(desc.name, rpc_str) == 0
) {
desc.is_readonly = true;
}
desc.feature = g_intern_string(grd->feature_name);
g_array_append_val(find_data, desc);
}

Loading…
Cancel
Save