|
@@ -101,13 +101,13 @@ static void gen_disable_mem_helper(void)
|
|
offsetof(ArchCPU, env));
|
|
offsetof(ArchCPU, env));
|
|
}
|
|
}
|
|
|
|
|
|
-static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb)
|
|
|
|
|
|
+static void gen_udata_cb(struct qemu_plugin_regular_cb *cb)
|
|
{
|
|
{
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
|
|
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
- tcg_gen_call2(cb->regular.f.vcpu_udata, cb->regular.info, NULL,
|
|
|
|
|
|
+ tcg_gen_call2(cb->f.vcpu_udata, cb->info, NULL,
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_ptr_temp(tcg_constant_ptr(cb->userp)));
|
|
tcgv_ptr_temp(tcg_constant_ptr(cb->userp)));
|
|
tcg_temp_free_i32(cpu_index);
|
|
tcg_temp_free_i32(cpu_index);
|
|
@@ -153,21 +153,21 @@ static TCGCond plugin_cond_to_tcgcond(enum qemu_plugin_cond cond)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static void gen_udata_cond_cb(struct qemu_plugin_dyn_cb *cb)
|
|
|
|
|
|
+static void gen_udata_cond_cb(struct qemu_plugin_conditional_cb *cb)
|
|
{
|
|
{
|
|
- TCGv_ptr ptr = gen_plugin_u64_ptr(cb->cond.entry);
|
|
|
|
|
|
+ TCGv_ptr ptr = gen_plugin_u64_ptr(cb->entry);
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
TCGv_i64 val = tcg_temp_ebb_new_i64();
|
|
TCGv_i64 val = tcg_temp_ebb_new_i64();
|
|
TCGLabel *after_cb = gen_new_label();
|
|
TCGLabel *after_cb = gen_new_label();
|
|
|
|
|
|
/* Condition should be negated, as calling the cb is the "else" path */
|
|
/* Condition should be negated, as calling the cb is the "else" path */
|
|
- TCGCond cond = tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond.cond));
|
|
|
|
|
|
+ TCGCond cond = tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond));
|
|
|
|
|
|
tcg_gen_ld_i64(val, ptr, 0);
|
|
tcg_gen_ld_i64(val, ptr, 0);
|
|
- tcg_gen_brcondi_i64(cond, val, cb->cond.imm, after_cb);
|
|
|
|
|
|
+ tcg_gen_brcondi_i64(cond, val, cb->imm, after_cb);
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
- tcg_gen_call2(cb->cond.f.vcpu_udata, cb->cond.info, NULL,
|
|
|
|
|
|
+ tcg_gen_call2(cb->f.vcpu_udata, cb->info, NULL,
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_ptr_temp(tcg_constant_ptr(cb->userp)));
|
|
tcgv_ptr_temp(tcg_constant_ptr(cb->userp)));
|
|
gen_set_label(after_cb);
|
|
gen_set_label(after_cb);
|
|
@@ -177,37 +177,37 @@ static void gen_udata_cond_cb(struct qemu_plugin_dyn_cb *cb)
|
|
tcg_temp_free_ptr(ptr);
|
|
tcg_temp_free_ptr(ptr);
|
|
}
|
|
}
|
|
|
|
|
|
-static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb)
|
|
|
|
|
|
+static void gen_inline_add_u64_cb(struct qemu_plugin_inline_cb *cb)
|
|
{
|
|
{
|
|
- TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry);
|
|
|
|
|
|
+ TCGv_ptr ptr = gen_plugin_u64_ptr(cb->entry);
|
|
TCGv_i64 val = tcg_temp_ebb_new_i64();
|
|
TCGv_i64 val = tcg_temp_ebb_new_i64();
|
|
|
|
|
|
tcg_gen_ld_i64(val, ptr, 0);
|
|
tcg_gen_ld_i64(val, ptr, 0);
|
|
- tcg_gen_addi_i64(val, val, cb->inline_insn.imm);
|
|
|
|
|
|
+ tcg_gen_addi_i64(val, val, cb->imm);
|
|
tcg_gen_st_i64(val, ptr, 0);
|
|
tcg_gen_st_i64(val, ptr, 0);
|
|
|
|
|
|
tcg_temp_free_i64(val);
|
|
tcg_temp_free_i64(val);
|
|
tcg_temp_free_ptr(ptr);
|
|
tcg_temp_free_ptr(ptr);
|
|
}
|
|
}
|
|
|
|
|
|
-static void gen_inline_store_u64_cb(struct qemu_plugin_dyn_cb *cb)
|
|
|
|
|
|
+static void gen_inline_store_u64_cb(struct qemu_plugin_inline_cb *cb)
|
|
{
|
|
{
|
|
- TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry);
|
|
|
|
- TCGv_i64 val = tcg_constant_i64(cb->inline_insn.imm);
|
|
|
|
|
|
+ TCGv_ptr ptr = gen_plugin_u64_ptr(cb->entry);
|
|
|
|
+ TCGv_i64 val = tcg_constant_i64(cb->imm);
|
|
|
|
|
|
tcg_gen_st_i64(val, ptr, 0);
|
|
tcg_gen_st_i64(val, ptr, 0);
|
|
|
|
|
|
tcg_temp_free_ptr(ptr);
|
|
tcg_temp_free_ptr(ptr);
|
|
}
|
|
}
|
|
|
|
|
|
-static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb,
|
|
|
|
|
|
+static void gen_mem_cb(struct qemu_plugin_regular_cb *cb,
|
|
qemu_plugin_meminfo_t meminfo, TCGv_i64 addr)
|
|
qemu_plugin_meminfo_t meminfo, TCGv_i64 addr)
|
|
{
|
|
{
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
|
|
|
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
|
- tcg_gen_call4(cb->regular.f.vcpu_mem, cb->regular.info, NULL,
|
|
|
|
|
|
+ tcg_gen_call4(cb->f.vcpu_mem, cb->info, NULL,
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_i32_temp(cpu_index),
|
|
tcgv_i32_temp(tcg_constant_i32(meminfo)),
|
|
tcgv_i32_temp(tcg_constant_i32(meminfo)),
|
|
tcgv_i64_temp(addr),
|
|
tcgv_i64_temp(addr),
|
|
@@ -220,16 +220,16 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb)
|
|
{
|
|
{
|
|
switch (cb->type) {
|
|
switch (cb->type) {
|
|
case PLUGIN_CB_REGULAR:
|
|
case PLUGIN_CB_REGULAR:
|
|
- gen_udata_cb(cb);
|
|
|
|
|
|
+ gen_udata_cb(&cb->regular);
|
|
break;
|
|
break;
|
|
case PLUGIN_CB_COND:
|
|
case PLUGIN_CB_COND:
|
|
- gen_udata_cond_cb(cb);
|
|
|
|
|
|
+ gen_udata_cond_cb(&cb->cond);
|
|
break;
|
|
break;
|
|
case PLUGIN_CB_INLINE_ADD_U64:
|
|
case PLUGIN_CB_INLINE_ADD_U64:
|
|
- gen_inline_add_u64_cb(cb);
|
|
|
|
|
|
+ gen_inline_add_u64_cb(&cb->inline_insn);
|
|
break;
|
|
break;
|
|
case PLUGIN_CB_INLINE_STORE_U64:
|
|
case PLUGIN_CB_INLINE_STORE_U64:
|
|
- gen_inline_store_u64_cb(cb);
|
|
|
|
|
|
+ gen_inline_store_u64_cb(&cb->inline_insn);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
g_assert_not_reached();
|
|
g_assert_not_reached();
|
|
@@ -240,15 +240,21 @@ static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb,
|
|
enum qemu_plugin_mem_rw rw,
|
|
enum qemu_plugin_mem_rw rw,
|
|
qemu_plugin_meminfo_t meminfo, TCGv_i64 addr)
|
|
qemu_plugin_meminfo_t meminfo, TCGv_i64 addr)
|
|
{
|
|
{
|
|
- if (cb->rw & rw) {
|
|
|
|
- switch (cb->type) {
|
|
|
|
- case PLUGIN_CB_MEM_REGULAR:
|
|
|
|
- gen_mem_cb(cb, meminfo, addr);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
|
|
+ switch (cb->type) {
|
|
|
|
+ case PLUGIN_CB_MEM_REGULAR:
|
|
|
|
+ if (rw && cb->regular.rw) {
|
|
|
|
+ gen_mem_cb(&cb->regular, meminfo, addr);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case PLUGIN_CB_INLINE_ADD_U64:
|
|
|
|
+ case PLUGIN_CB_INLINE_STORE_U64:
|
|
|
|
+ if (rw && cb->inline_insn.rw) {
|
|
inject_cb(cb);
|
|
inject_cb(cb);
|
|
- break;
|
|
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ g_assert_not_reached();
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|