qemu/tcg: fix UC_HOOK_MEM_READ on aarch64. (#2028)
* qemu/tcg: fix UC_HOOK_MEM_READ on aarch64. Directly jump into the slow path when there is any hookmem enabled. This fixes #1908. Signed-off-by: Glenn Baker <glenn.baker@gmx.com> * qemu/tcg: fix UC_HOOK_MEM_READ on ppc64. Directly jump into the slow path when there is any hookmem enabled. Signed-off-by: Glenn Baker <glenn.baker@gmx.com> * qemu/tcg: check for UC_HOOK_MEM_READ_AFTER. Use has_hookmem() helper to determine wether "slow-path" TLB read is needed. Add this helper to x86 architecture as well so that to check for all hookmem. Signed-off-by: Glenn Baker <glenn.baker@gmx.com> * qemu/tcg: factor out has_hookmem(). It's the same implementation for all architectures, so factor out has_hookmem() into tcg_uc_has_hookmem(). Signed-off-by: Glenn Baker <glenn.baker@gmx.com> --------- Signed-off-by: Glenn Baker <glenn.baker@gmx.com>
This commit is contained in:
@@ -2014,7 +2014,8 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
MemOp opc = get_memop(oi);
|
||||
TCGReg hi, lo, arg = TCG_REG_R3;
|
||||
|
||||
if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) {
|
||||
const int type = tcg_uc_has_hookmem(s) ? R_PPC_REL24 : R_PPC_REL14;
|
||||
if (!patch_reloc(lb->label_ptr[0], type, (intptr_t)s->code_ptr, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2062,7 +2063,8 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
MemOp s_bits = opc & MO_SIZE;
|
||||
TCGReg hi, lo, arg = TCG_REG_R3;
|
||||
|
||||
if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) {
|
||||
const int type = tcg_uc_has_hookmem(s) ? R_PPC_REL24 : R_PPC_REL14;
|
||||
if (!patch_reloc(lb->label_ptr[0], type, (intptr_t)s->code_ptr, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2142,7 +2144,11 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64)
|
||||
|
||||
/* Load a pointer into the current opcode w/conditional branch-link. */
|
||||
label_ptr = s->code_ptr;
|
||||
tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
|
||||
// Unicorn: fast path if hookmem is not enabled
|
||||
if (!tcg_uc_has_hookmem(s))
|
||||
tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
|
||||
else
|
||||
tcg_out32(s, B | LK);
|
||||
|
||||
rbase = TCG_REG_R3;
|
||||
#else /* !CONFIG_SOFTMMU */
|
||||
@@ -2217,7 +2223,11 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64)
|
||||
|
||||
/* Load a pointer into the current opcode w/conditional branch-link. */
|
||||
label_ptr = s->code_ptr;
|
||||
tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
|
||||
// Unicorn: fast path if hookmem is not enabled
|
||||
if (!tcg_uc_has_hookmem(s))
|
||||
tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
|
||||
else
|
||||
tcg_out32(s, B | LK);
|
||||
|
||||
rbase = TCG_REG_R3;
|
||||
#else /* !CONFIG_SOFTMMU */
|
||||
|
||||
Reference in New Issue
Block a user