mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-17 07:02:03 -06:00
plugins: try and make plugin_insn_append more ergonomic
Currently we make the assumption that the guest frontend loads all op code bytes sequentially. This mostly holds up for regular fixed encodings but some architectures like s390x like to re-read the instruction which causes weirdness to occur. Rather than changing the frontends make the plugin API a little more ergonomic and able to handle the re-read case. Stuff will still get strange if we read ahead of the opcode but so far no front ends have done that and this patch asserts the case so we can catch it early if they do. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20211026102234.3961636-21-alex.bennee@linaro.org>
This commit is contained in:
parent
e83f79b3fa
commit
357af9be5c
4 changed files with 17 additions and 7 deletions
|
@ -27,13 +27,21 @@ void plugin_gen_insn_end(void);
|
|||
void plugin_gen_disable_mem_helpers(void);
|
||||
void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info);
|
||||
|
||||
static inline void plugin_insn_append(const void *from, size_t size)
|
||||
static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
|
||||
{
|
||||
struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn;
|
||||
abi_ptr off;
|
||||
|
||||
if (insn == NULL) {
|
||||
return;
|
||||
}
|
||||
off = pc - insn->vaddr;
|
||||
if (off < insn->data->len) {
|
||||
g_byte_array_set_size(insn->data, off);
|
||||
} else if (off > insn->data->len) {
|
||||
/* we have an unexpected gap */
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
insn->data = g_byte_array_append(insn->data, from, size);
|
||||
}
|
||||
|
@ -62,7 +70,7 @@ static inline void plugin_gen_disable_mem_helpers(void)
|
|||
static inline void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info)
|
||||
{ }
|
||||
|
||||
static inline void plugin_insn_append(const void *from, size_t size)
|
||||
static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
|
||||
{ }
|
||||
|
||||
#endif /* CONFIG_PLUGIN */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue