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

AArch64 armv9.2 update #1907

Merged
merged 12 commits into from
Oct 6, 2022

Conversation

FinnWilkinson
Copy link
Contributor

@FinnWilkinson FinnWilkinson commented Aug 1, 2022

The work done is this pull request updates the AArch64 disassembler to Armv9.2-a; based upon LLVM 14.0.5.

Detailed below is a summary of changes made :

  • New .inc files for AArch64 architecture
  • Implemented new decode and printing functions as required for AArch64
  • Updated relevant enums in Arm64.h
    • System and Operand Registers, ARM64 instructions, ARM64 Groups, System Operands,
  • Reformatted many of the synctool python scripts to work with LLVM 14's changes
  • Created a new struct and added to instruction_object to expose the SVCR value (used by SME)
  • Created a new SVCR print-out to make clear which sys_register is being updated and which bits are changed
    • In the SVCR register, bits 0 and 1 are used to signify if the ZA and SM context modes respectively are enabled/disabled
  • Updated the AArch64 tablegen source files to LLVM 14.0.5
  • Few minor bug fixes

Edit :

  • Created new struct arm64_op_sme_index and added to cs_arm64_op to more accuratly represent SME instruction operands that have index of the form [wn, #imm].
    • set_sme_index and relevant print functions were added so that the appropriate SME instructions use this new struct rather than arm64_op_mem

I am sure that this PR will be incomplete, so please let me know of any changes or fixes that should be made!

@kabeor
Copy link
Member

kabeor commented Aug 4, 2022

Hi, plz check ci result.

@FinnWilkinson
Copy link
Contributor Author

To note - the Python CI tests are segfaulting and failing various tests, despite displaying test pass

@aquynh
Copy link
Collaborator

aquynh commented Aug 4, 2022 via email

@FinnWilkinson
Copy link
Contributor Author

please can you clean up the PR, as it includes a lot of old commits?

Yes of course. After fixing the CI test issues, I will squash commits into logical blocks to reduce and clean up the PR.

@FinnWilkinson
Copy link
Contributor Author

One of the failing tests is due to the change made in #1655 being reverted. This was done as it was noticed that access types were not always correct, and I was getting segFaults when using Capstone with an external project.

Whilst the fix from #1655 does correct the access types for aliased cmp instructions, it collects incorrect access types for others. In the case of ldrsw x2, [x0], #4 (HEX= 0x024480B8) the access types should be: x2=WRITE, [x0]=READ | WRITE, however with the change from #1655 the access types are x2=READ | WRITE, [x0]=READ | WRITE.

@kabeor @aquynh please advise on whether the change made in #1655 should be reverted in this PR (and the corresponding test in issues.cs commented out) or if said change should remain and be fixed at a later date?

@kabeor
Copy link
Member

kabeor commented Aug 11, 2022

Hi, thanks for your contribution. I think reverting it temporary in your code and report this issue is a good way for now, we can focus on that after merge this pr.

@FinnWilkinson
Copy link
Contributor Author

Appologies for the delay on this PR. I aim to fix the latest CIFuzz error and tidy the commit history this week

@FinnWilkinson
Copy link
Contributor Author

Hi @kabeor, please could the fuzzing tests and other workflows be re-run? Thanks

@kabeor
Copy link
Member

kabeor commented Sep 22, 2022

Hi @kabeor, please could the fuzzing tests and other workflows be re-run? Thanks

Hi, fuzzing test not pass, plz check it:)

@FinnWilkinson
Copy link
Contributor Author

Hi, fuzzing test not pass, plz check it:)

Sorry for the delay, I have re-worked the logic which was causing the address sanitizer error, so hopefully the issue has now been resolved!

@kabeor
Copy link
Member

kabeor commented Sep 28, 2022

Still failed😢, plz check again.

make arm64 needs to be performed before AArch64GenRegisterV.inc is generated.
…atting changes in LLVM 14.0.5 tablegen files.

 - asmwriter.py : As well as new functions, recognition of new SME index printing was added. The printAliasInstr function also required a re-write to match its counter-part and changes in logic in LLVM 14.0.5
 - disassemblertables-arch.py : Minor type changes for some functions, as well as adding support for new SME decode functions.
 - mapping_insn-arch.py : Minor change to correct incorrect instruction aliasing in generated AArch64MappingInsn.inc etc.
 - registerinfo.py : minor change to reflect change in LLVM 14.0.5
 - systemoperand.py : corrected minor type changes made in LLVM 14.0.5 and added extraction of SVCR, BTI, DBnXS lists and encoding functions.
Added new decode functions, mainly for SME matrix operands and SVCR sys
register, as well as updating existing decode functions which have seen
changes in LLVM 14.0.5.

The _getInstruction function has also been updated to its LLVM 14.0.5
counterpart; with a new switch case for adding implicit operands to the
relevant SME instructions.
14.0.5, and introduced new arm64 operand types.

New operand type for svcr MSR/MRS/SMSTART/SMSTOP instructions to
facilitate easier cstool printing.

New operand type for SME instructions with a matrix register that is
indexed.
Implemented new functions present in LLVM 14.0.5 for any new instruction
type in Armv9.2; mainly SME / Matrix printing functions.

New set_sme_index function added (called from AArch64GenAsmWriter.inc)
to correctly add operands to new sme_index operand type. Doing_SME_Index
bool added to cs_struct to indicate when operands should be added to
sme_index type.

Functionality added to support SMSTART/SMSTOP aliases.
Issue 1653 test commented out as the change made for this issue was reverted due to it being incomplete for all instructions. New issue capstone-engine#1911 has been opened to document that the original issue needs re-addressing.
@FinnWilkinson
Copy link
Contributor Author

Have solved fuzzing errors and cleaned up the commit history. Please see and let me know if it is all satisfactory!

@kabeor
Copy link
Member

kabeor commented Oct 6, 2022

Very awesome! Thanks for your great contribution. Merged.
We need keeping our eyes on #1655 next step.

@kabeor kabeor merged commit 662bb3f into capstone-engine:next Oct 6, 2022
@wideglide
Copy link
Contributor

It appears this PR broke something in the python bindings? #1929

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

Successfully merging this pull request may close these issues.

4 participants