unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.66k stars 1.35k forks source link

qemu/tcg: fix UC_HOOK_MEM_READ on aarch64. #2028

Open glennsec opened 1 month ago

glennsec commented 1 month ago

Directly jump into the slow path when there is any hookmem enabled. This fixes #1908.

glennsec commented 1 month ago

Hi, code updated to cover ppc64 as well.

PhilippTakacs commented 1 month ago

I think you missed at least UC_HOOK_MEM_READ_AFTER.

Also it would be nice to use HOOK_EXISTS_BOUNDED. This way the fast way is taken when no hook exists at the used address. But I don't know if this is possible at this place (you need the emulated physical address).

glennsec commented 1 month ago

I think you missed at least UC_HOOK_MEM_READ_AFTER.

Also it would be nice to use HOOK_EXISTS_BOUNDED. This way the fast way is taken when no hook exists at the used address. But I don't know if this is possible at this place (you need the emulated physical address).

Added check for UC_HOOK_MEM_READ_AFTER, including for i386. Factored out the code along the way. I am not sure either I can use HOOK_EXISTS_BOUNDED() as TCGContext.pc_start is set to the end of the BB at the point we call it for codegen.