Repository navigation
x86: use the masked count to decide whether rotates define OF - #1547
Open
bacescuandrei wants to merge 2 commits into
Open
bacescuandrei wants to merge 2 commits into
bacescuandrei wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ROL,ROR,RCLandRCRcompute their result from the masked count (get_shift():count & 0x1f, or& 0x3ffor 64-bit operands), but decided whether OF is defined by comparing the unmasked source with 1. With a count register such asCL = 0x21, the instruction rotates by 1 and the Intel SDM defines OF (IF (COUNT & COUNTMASK) = 1 THEN OF := ...), but miasm left OF at 0:The same happens for
ROR,RCLandRCR, for immediate counts (ROL EAX, 0x21) and for 64-bit operands with counts such as0x41. The shift template already compares the masked count. This makes_rotate_tplandrotate_with_carry_tpluse the masked count as well.Added
test_ROTATE_OF_masked_counttotest/arch/x86/sem.py, which checks the four rotates withCL = 0x21. It fails on master and passes with this change.Found by comparing single instructions executed by the python jitter (x86_64 mode, 64/32/16/8-bit operands) with Unicorn 2.1.4; the mismatches were the 32/16/8-bit rotates with
CL = 0x21. With this change, 55,552 cases over 118 ALU, shift, rotate, bit-test and extension instructions agree with Unicorn on the general-purpose registers and on the flags the SDM defines for each case.Also run with this change: the
test/arch/x86/unit/mn_*.pyscripts with the python and gcc jitters (45 runs,mn_float.pywithout the python jitter as intest_all.py),test/arch/x86/sem.pyandtest/arch/x86/arch.py. The llvm jitter was not available here.