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>
This commit is contained in:
Glenn Baker 2024-10-22 15:46:50 +02:00
parent bfe3acb432
commit d84208e829
3 changed files with 10 additions and 1 deletions

View File

@ -1584,6 +1584,7 @@ static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target)
static inline bool has_hookmem(TCGContext *s)
{
return HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ_AFTER) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_WRITE);
}

View File

@ -1679,6 +1679,13 @@ static void * const qemu_st_helpers[16] = {
[MO_BEQ] = helper_be_stq_mmu,
};
static inline bool has_hookmem(TCGContext *s)
{
return HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ_AFTER) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_WRITE);
}
/* Perform the TLB load and compare.
Inputs:
@ -1763,7 +1770,7 @@ static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
tcg_out_mov(s, ttype, r1, addrlo);
// Unicorn: fast path if hookmem is not enable
if (!HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ) && !HOOK_EXISTS(s->uc, UC_HOOK_MEM_WRITE))
if (!has_hookmem(s))
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
else
/* slow_path, so data access will go via load_helper() */

View File

@ -2011,6 +2011,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi,
static inline bool has_hookmem(TCGContext *s)
{
return HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ_AFTER) ||
HOOK_EXISTS(s->uc, UC_HOOK_MEM_WRITE);
}