-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Both EFLAGS and single-stepping through conditionals is broken on amd64 #499
Comments
can you send a PR to put your Python testcase above under |
btw, which assembler are you using for that "asm" tool? |
Can do. The assembler is just gas.
|
Uploaded a test cast / pull request. |
count=1 is facilitated by a HOOK_CODE callback and a counter, so it's likely the same issue. edit: nvm, I manually synced eflags and this test still fails. why isn't the parity flag getting set? |
It still fails even if you make this change to the test. diff --git a/tests/regress/x86_64_eflags.py b/tests/regress/x86_64_eflags.py
index ca7c48d..561fd36 100755
--- a/tests/regress/x86_64_eflags.py
+++ b/tests/regress/x86_64_eflags.py
@@ -13,7 +13,7 @@ class WrongEFLAGS(regress.RegressTest):
uc.mem_map(0x600000, 0x1000)
uc.mem_write(0x6000b0, CODE)
- uc.emu_start(0x6000b0, 0, count=1)
+ uc.emu_start(0x6000b0, 0x6000b3)
# Here's the original execution trace for this on actual hardware. |
I verified that this test also fails in the |
I also verified that this behavior does not occur in vanilla QEMU with qemu-user, even with the GDB stub and single-stepping.
|
can you elaborate how to reproduce the behavior of qemu-user with isntruction "xor r14,r14"? the output above seems to be generated by pwndbg, which i am not familiar with. thanks |
this issue with EFLAGS is due to Unicorn does not turn on the reserved flag (bit 1) on, but this behavior is undocumented in Intel manual. i dont see where Qemu handles this flag, or i missed that.s |
Here's the quick way to repro with QEMU.
The generated The punchline is:
If you'd like a copy of the ELF binary |
To answer the lingering question in #499 (comment) -- no, vanilla QEMU works correctly, even in single-step mode. This is a Unicorn-specific problem. |
Added yet-another-test in #511. |
Ping? :) |
Feel free to dupe to #496 if you want, but here's a concrete trace. I did not contribute there since this is an actual emulation failure, rather than a failure to be coherent inside a callback.
By using Binjitsu / Pwntools, you can easily assemble the following sequence of instructions:
It's also pretty easy to launch it in a debugger.
When the debugger pops up, here's what we see:
By instantiating a Unicorn context object with the current state and stepping four times, we should hit the HLT instruction, but we never do.
Here's the full trace, below. Note that everything between
emu_start
andemu_stop
is processed in callbacks.This repeats forever. Actually stepping forward in GDB shows that the HLT is indeed hit.
It looks like the underlying issue is that EFLAGS is not properly updated. The real value is 0x246, the emulated value (above) is 0x244.
The text was updated successfully, but these errors were encountered: