Skip to content
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

Incorrect aarch64 umov decoding #2372

Open
psi-func opened this issue May 29, 2024 · 3 comments
Open

Incorrect aarch64 umov decoding #2372

psi-func opened this issue May 29, 2024 · 3 comments
Labels
Milestone

Comments

@psi-func
Copy link

Work environment

Questions Answers
OS/arch/bits Ubuntu 20.04, 64 bit
Architecture armv8
Source of Capstone git clone
Version/git commit v5.0.1, 097c04d

Instruction bytes giving faulty results

0x43,0x3c,0x1c,0x0e

Expected results

It should be:

umov w3, v2.S[3]

Steps to get the wrong result

./cstool -d arm64  0x43,0x3c,0x1c,0x0e 0x1000
1000  43 3c 1c 0e  mov  w3, v2.s[3]
        ID: 488 (mov)
        op_count: 2
                operands[0].type: REG = w3
                operands[0].access: WRITE
                operands[1].type: REG = v2
                operands[1].access: WRITE
                        Vector Arrangement Specifier: 0xb
                        Vector Index: 3
        Registers modified: w3 v2
        Groups: neon

Additional Logs, screenshots, source code, configuration dump, ...

According to official arm doc it's really alias on UMOV instruction, that's why ID: 488 (mov) is incorrect and leads to errors while using capstone as a library

@psi-func psi-func changed the title Incorrect Incorrect UMOV decoding May 29, 2024
@psi-func psi-func changed the title Incorrect UMOV decoding Incorrect aarch64 umov decoding May 29, 2024
@Rot127 Rot127 added this to the v5.0.2 milestone May 29, 2024
@Rot127
Copy link
Collaborator

Rot127 commented May 29, 2024

I would advice to use the next branch for AArch64. It is better in every dimension. This one is fixed there in more then one way (note the incorrect access of operands in the example of yours):

On next branch:

./cstool -d aarch64  0x43,0x3c,0x1c,0x0e 0x1000
1000  43 3c 1c 0e  mov	w3, v2.s[3]
	ID: 1285 (umov)
	Is alias: 1429 (mov) with ALIAS operand set
	op_count: 2
		operands[0].type: REG = w3
		operands[0].access: WRITE
		operands[1].type: REG = q2 (vreg)
		operands[1].access: READ
			Vector Arrangement Specifier: 0x20
			Vector Index: 3
	Registers read: q2
	Registers modified: w3
	Groups: HasNEON 

Added it of course to the v5.0.2 milestone nonetheless.

If you want to use the next branch I advice to wait for #2298 and #2321 to be merged.

@psi-func
Copy link
Author

Sorry, but next branch totally breaks API
could it be possible to change the major version of the project to make life easier

@Rot127
Copy link
Collaborator

Rot127 commented May 31, 2024

could it be possible to change the major version of the project to make life easier

The next branch is the development branch and will be released as v6 (planned in September).
If you need to check the "next" version number in source, you can use the CS_NEXT_VERSION macro.

Sorry, but next branch totally breaks API

Have you already tried to use #2321?
This should fix the rename problem from ARM64 to AArch64.
If you don't want to fiddle with merging PRs locally please stand by until @aquynh and @kabeor reviewed and merged it.

Also, as a general overview and justifications for API changes see the release guide: https://github.com/capstone-engine/capstone/blob/next/docs/cs_v6_release_guide.md

When it comes to new or removed instructions, please note that they changed unfortunately in the past quite often as well. This was because Capstone didn't do a clear distinction between instruction alias and real instructions. This is now fixed. But this is as well explained in the release guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants