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

i#7410: Fix incorrect x86 ISA categories and movntdqa operands #7411

Merged
merged 8 commits into from
Mar 31, 2025

Conversation

derekbruening
Copy link
Contributor

@derekbruening derekbruening commented Mar 28, 2025

Adds a check that the load and store categories strictly match the instr_{reads,writes}_memory() on every x86 opcode. This revealed a number of incorrect catLoad and catStore labels which are now removed from:

  • OP_lea (see also below)
  • OP_lahf (see also below)
  • OP_vbroadcastf32x2
  • OP_vbroadcasti32x2
  • OP_fld with only register operands
  • OP_fst{,p} with only register operands
  • OP_fld* which insert literals

Fixes {v,}movntdqa which the above check detected had its operands in the wrong order: it was listed as a store in the table when it is in fact a load. Also adds catSIMD to some variants that were missing it.

Fixes the following x86 ISA category errors:

  • OP_lea is now catMath instead of catLoad
  • OP_nop_modrm is now catOther instead of catSIMD
  • OP_lahf is now catState instead of catLoad

Categorizes the following previously uncategorized opcodes:

  • OP_xchg and OP_fxchg are now catMove
  • OP_pushf is now catStore|catState
  • OP_popf is now catLoad|catState
  • OP_sahf is now catState
  • OP_cmov* is now catMove
  • OP_nop is now catOther

None of these changes affect other IR interfaces like instr_{reads,write}_memory().
There is no compatibility issue with drmemtrace address traces: no raw trace impact; the final trace is impacted for movntdqa and (for regdeps) the categories but there's no compatibility change: just an increase in accuracy from raw2trace or record_filter output.

Fixes #7410

Adds a check that the load and store categories strictly match the
instr_{reads,writes}_memory() on every x86 opcode. This revealed a
number of incorrect catLoad and catStore labels which are now removed
from:
+ OP_lea (see also below)
+ OP_lahf (see also below)
+ OP_vbroadcastf32x2
+ OP_vbroadcasti32x2
+ OP_fld with only register operands
+ OP_fst{,p} with only register operands
+ OP_fld* which insert literals

Fixes {v,}movntdqa which the above check detected had its operands in
the wrong order: it was listed as a store in the table when it is in
fact a load.  Also adds catSIMD to some variants that were missing it.

Fixes the following x86 ISA category errors:
+ OP_lea is now catMath instead of catLoad
+ OP_nop_modrm is now catOther instead of catSIMD
+ OP_lahf is now catState instead of catLoad

Categorizes the following previously uncategorized opcodes:
+ OP_xchg and OP_fxchg are now catMove
+ OP_pushf is now catStore|catState
+ OP_popf is now catLoad|catState
+ OP_sahf is now catState
+ OP_cmov* is now catMove
+ OP_nop is now catOther

Fixes #7410
@edeiana edeiana self-requested a review March 28, 2025 21:35
@derekbruening
Copy link
Contributor Author

I see you started a review: there was one test failure: had to update opcode_categories output (that asm has OP_lea in it); all set now.

Copy link
Contributor

@edeiana edeiana left a comment

Choose a reason for hiding this comment

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

Ok, clients/drcachesim/tests/offline-opcode_categories.templatex has been fixed.
Everything else LGTM!

@derekbruening
Copy link
Contributor Author

VS2019-32 failure is:

D:\a\dynamorio\dynamorio\suite\tests\api\ir_x86.c(489) : fatal error C1002: compiler is out of heap space in pass 2

Yet is was green in the first commit. So on the borderline? May have to split the ir test headers further?

@derekbruening
Copy link
Contributor Author

Now record_filter_unit_tests has a failure that may be related: but it didn't fail in the 1st commit?

@derekbruening derekbruening merged commit 814070f into master Mar 31, 2025
24 checks passed
@derekbruening derekbruening deleted the i7410-fix-categories branch March 31, 2025 21:26
derekbruening added a commit that referenced this pull request Apr 1, 2025
Adds support for "-mode regdeps" in all builds of drdisas.
I found this useful when working on PR #7411 where I had
to update/understand regdeps disassembly in our tests.

Adds a test.

Also manually tested:
```
$ clients/bin64/drdisas -mode regdeps 00001931 04020204 00000026
 00001931 04020204 load store [4byte]       %rv0 %rv2 %rv36 -> %rv0
 00000026
```

Issue: #6662, #7410
derekbruening added a commit that referenced this pull request Apr 1, 2025
Adds support for "-mode regdeps" in all builds of drdisas. I found this
useful when working on PR #7411 where I had to update/understand regdeps
disassembly in our tests.

Adds a test.

Also manually tested:
```
$ clients/bin64/drdisas -mode regdeps 00001931 04020204 00000026
 00001931 04020204 load store [4byte]       %rv0 %rv2 %rv36 -> %rv0
 00000026
```

Issue: #6662, #7410
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.

x86 decoding table contains a number of incorrect categories
3 participants