Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.

aarch64: add everything except instructions#1418

Merged
ehennenfent merged 7 commits into
trailofbits:merge-aarch64from
nkaretnikov:aarch64-everything-except-instructions
Apr 30, 2019
Merged

aarch64: add everything except instructions#1418
ehennenfent merged 7 commits into
trailofbits:merge-aarch64from
nkaretnikov:aarch64-everything-except-instructions

Conversation

@nkaretnikov

@nkaretnikov nkaretnikov commented Apr 29, 2019

Copy link
Copy Markdown
Contributor

Based on disconnect3d/aarch64/skeleton.


This change is Reviewable

Based on disconnect3d/aarch64/skeleton.
@nkaretnikov nkaretnikov mentioned this pull request Apr 29, 2019
@nkaretnikov

Copy link
Copy Markdown
Contributor Author

See #1366 (comment).

Otherwise, 'scripts/travis_test.sh' fails to work.

@ehennenfent ehennenfent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 17 of 18 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @nkaretnikov)


examples/script/aarch64/count_instructions.py, line 11 at r2 (raw file):

DIR = os.path.dirname(__file__)
FILE = os.path.join(DIR, 'hello42')

Would consider renaming this file to 'hello42.py'


manticore/native/cpu/aarch64.py, line 280 at r2 (raw file):

    # See 'UTS_MACHINE' and 'COMPAT_UTS_MACHINE' in the Linux kernel source.
    # https://stackoverflow.com/a/45125525
    machine = 'aarch64'

Would prefer to switch this to an enum if possible


tests/native/test_aarch64cpu.py, line 8 at r2 (raw file):

from nose.tools import nottest

from manticore.core.smtlib import *

In general we try to avoid import *, but since this is in a test, we can probably ignore the performance penalty

@nkaretnikov

nkaretnikov commented Apr 30, 2019

Copy link
Copy Markdown
Contributor Author

I'm so glad you suggested to rename the example script! I have done that and realized it's now broken. I don't get the same behavior as on a pre-rebase branch. I suspect something has changed in the syscall layer, investigating...

UPD: Okay, I've figured it out. It's a change in manticore/native/cpu/abstractcpu.py, I'll push this fix shortly:

[...]
     def _reg_name(self, reg_id):
[...]
-        if reg_id >= X86_REG_ENDING:
-            logger.warning("Trying to get register name for a non-register")
-            return None

@ehennenfent could you explain why this code was added? It wouldn't work for Armv7 either.

The reason I thought of syscalls first is that the "Unimplemented system call" warning was added to sys_faccessat, which is used by my test binaries basic and hello42. I don't think there's a reason to implement it as part of this PR because the syscall checks for /etc/ld.so.nohwcap, so it shouldn't have any effect on execution. See: https://unix.stackexchange.com/questions/353310/where-to-get-etc-ld-so-nohwcap-file-from/353311

FWIW, here are my old comments explaining how to run the examples:

Note that you'll need to test on a branch with all the AArch64 changes present (such as the last PR or your own development branch).

@nkaretnikov nkaretnikov changed the title aarch64: add everything except instructions WIP: aarch64: add everything except instructions Apr 30, 2019

@nkaretnikov nkaretnikov left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 16 of 19 files reviewed, 3 unresolved discussions (waiting on @ehennenfent)


manticore/native/cpu/aarch64.py, line 280 at r2 (raw file):

Previously, ehennenfent (Eric Hennenfent) wrote…

Would prefer to switch this to an enum if possible

Me too, but I don't currently have any hardware or emulators that report anything other than aarch64 (LE).
So I'd rather not change this without testing. And there might be other places that just use aarch64 in the code.


tests/native/test_aarch64cpu.py, line 8 at r2 (raw file):

Previously, ehennenfent (Eric Hennenfent) wrote…

In general we try to avoid import *, but since this is in a test, we can probably ignore the performance penalty

Done.


examples/script/aarch64/count_instructions.py, line 11 at r2 (raw file):

Previously, ehennenfent (Eric Hennenfent) wrote…

Would consider renaming this file to 'hello42.py'

Done.

@nkaretnikov nkaretnikov changed the title WIP: aarch64: add everything except instructions aarch64: add everything except instructions Apr 30, 2019
@ehennenfent
ehennenfent changed the base branch from master to merge-aarch64 April 30, 2019 16:09

@ehennenfent ehennenfent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That register number limit check was added here. It was to combat a bug we encountered when using different versions of capstone that had different maximum register numbers on x86. You're right that it will probably break other architectures. I'd suggest expanding this check to handle the various architectures. IE:

if (<arch> == x86 and reg_id >= X86_REG_ENDING) or 
   (<arch> == aarch64 and reg_id >= ARM64_REG_ENDING):

Just worry about correctly supporting x86 and aarch64 here and I'll make a note to go fix the other architectures after we merge. The correct REG_ENDING variables can be found in the *_const.py files here

Reviewed 3 of 3 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@nkaretnikov nkaretnikov left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Reviewable status: 18 of 19 files reviewed, all discussions resolved (waiting on @ehennenfent)

@ehennenfent ehennenfent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@ehennenfent
ehennenfent merged commit 04a1cd3 into trailofbits:merge-aarch64 Apr 30, 2019
ekilmer added a commit that referenced this pull request May 17, 2019
* master: (28 commits)
  AArch64: fix ldrb size (#1433)
  System Call Audit (#1384)
  ManticoreBase refactor (#1385)
  Add missing checks for ARM boundaries (#1429)
  aarch64: add instruction tests: T-U (#1423)
  aarch64: add instruction tests: M-S (#1422)
  aarch64: add instruction tests: C-L (#1421)
  aarch64: add instruction tests: A-B (#1420)
  aarch64: add everything except instructions (#1418)
  fixup: support ARM64 in '_reg_name'
  Revert "fixup: remove x86-specific code from '_reg_name'"
  review: avoid wildcard imports
  review: rename the file
  fixup: remove x86-specific code from '_reg_name'
  fixup: do not use relative imports
  Generates a more sensible symbolic default for constructor arguments (#1414)
  aarch64: add instructions
  aarch64: add everything except instructions
  Switches the Travis-CI badge from .org to .com (#1416)
  Performance optimization : use set instead of list (#1415)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants