Repository navigation
aarch64: fix ANDS/BICS/TST flags, EXTR and division by zero - #1548
Open
bacescuandrei wants to merge 2 commits into
Open
bacescuandrei wants to merge 2 commits into
bacescuandrei wants to merge 2 commits into
Conversation
- ANDS, BICS and TST clear C and V. - EXTR takes Rn as the high part of the extracted pair. - UDIV and SDIV by zero give 0 instead of raising an exception.
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.
Three aarch64 semantics differences from the architecture, found by comparing the python jitter with Unicorn 2.1.4 on single instructions:
ANDS,BICSandTSTset N and Z but left C and V unchanged. The Arm ARM definesNZCV = result<N-1>:IsZero(result):'00'for these, so C and V are now cleared.EXTR Xd, Xn, Xm, #lsbextracts fromXn:Xm, withXnas the high part. The semantics builtExprCompose(arg2, arg3), which putsXnin the low part; for exampleEXTR X0, X1, X2, 1withX1 = 1,X2 = 0gave 0 instead of0x8000000000000000.UDIVandSDIVwith a zero divisor raisedEXCEPT_DIV_BY_ZERO. On AArch64 division by zero does not trap and the result is 0 (if IsZero(operand2) then result = 0).Added unit tests
test/arch/aarch64/unit/mn_ands.py,mn_extr.pyandmn_div.pyand listed them intest/test_all.py. With the master semantics all three fail with both the python and gcc jitters; with this change they pass with both, andmn_ubfm.pystill passes. (When switching between the two versions the gcc jitter's block cache in/tmp/miasm_cachehas to be cleared, otherwise blocks compiled with the old semantics are reused.)With this change, 252,072 single-instruction cases of the aarch64 differential comparison no longer show differences for these instructions. The miasm encodings of the
ANDS,EXTRandSDIVcases were checked withllvm-mc.