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.67k stars 1.35k forks source link

Unicorn Engine Crash When Emulating DR7 Register Update with 0x10005 #2001

Open Z4ee opened 2 months ago

Z4ee commented 2 months ago

When attempting to emulate the following instructions:

mov rax, 0x10005
mov dr7, rax

a crash occurs in the Unicorn emulator. This is due to the cpu_x86_update_dr7_x86_64 function calling cpu_breakpoint_insert_x86_64, which then triggers tb_flush_sparc64. The latter performs a TCG region reset (via tcg_region_reset_all_x86_64), effectively wiping the emulation region.

As a result, when cpu_x86_update_dr7_x86_64 returns, it attempts to exit into a now-cleared region, causing the crash.