mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1485] x64_recomp: the 0F SIMD ranges skip eight ModRM opcodes (X64-RECOMP-SIMD-TABLE) #1517
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1517
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1485
Author: @kett1m
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:x64-recomp-simd-table📝 Commits (1)
d6e8cbdx64_recomp: the 0F SIMD ranges skip eight ModRM opcodes (X64-RECOMP-SIMD-TABLE)📊 Changes
3 files changed (+39 additions, -3 deletions)
View changed files
📝
docs/mobile.md(+12 -0)📝
tests/test_x64_recomp.py(+21 -0)📝
tools/x64_recomp.py(+6 -3)📄 Description
The
0FSIMD opcode list intools/x64_recomp.pyis generated from opcode ranges, and theranges left out eight opcodes that take a ModRM byte:
7C/7D, HADDPD/HADDPS and HSUBPD/HSUBPS (66andF2forms)D0, ADDSUBPD/ADDSUBPSD7, PMOVMSKB (66form; the MMX form has no prefix)E6, CVTDQ2PD, CVTTPD2DQ, CVTPD2DQE7, MOVNTDQF0, LDDQUF7, MASKMOVDQUWith no table entry each decoded as the unknown
op0f_XXof its two opcode bytes, so the byteafter them was read as the next instruction and the rest of the function was decoded from the
wrong offset.
Measurement
The image is
game_scarlett_master.exe, SHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993. REA measured the sectionranges with
gnu.objdumpsection_headers, evidenceev_e29cbdffd0dc7c46889b2a1f955011ce9f2795017233c97107ded73f9186dd90:.textVMA0x140001000, file0x400, size0x5f3f966;.pdataVMA0x14abcf000, file0x6e03a00..pdatafunction (299,257) with the unfixed decoder, 6 functions stop on one ofthese opcodes. The first unknown in each is
op0f_7d(RVA0x17e1060),op0f_e6(
0x277a710,0x3137ab0,0x562bc40),op0f_e7(0x3081860) andop0f_f7(0x3e2aad0).With the fix they decode 852 instructions further and 3 reach the end of the function with no
unknown left.
.text: objdump's linear walk and thedecoder's walk read the same bytes and the instruction lengths are compared (26,674,180
objdump instructions). It drops 6 length mismatches, 4
F3 0F E6(CVTDQ2PD, RVAs0x562ad45,0x562ad6e,0x562e320,0x562e395) and 266 REX.W 0F D7(PMOVMSKB, RVAs0x564df78,0x565191f), and adds none. The totals are 52,638 before and 52,632 after.Enumerating the
0Fopcodes against the set of legacy SSE/MMX instructions that take a ModRMbyte leaves none out after the change;
movnti(0F C3) is already its own entry.Test
tests/test_x64_recomp.py::DecodeTests::test_simd_opcodes_outside_the_ranges_carry_modrmcoversthe eight opcodes in the register and memory forms. Against the unfixed decoder the first case
(
f3 0f e6 c9) decodes asunknown; with the fix each keeps its ModRM/SIB/displacement length.python -I tests/test_x64_recomp.py: 33 tests OK, 26 skipped (this host has noqemu-system-aarch64).
python -I tests/test_recomp_census.py: 11 tests OK.python3 -m compileall -q make_game.py tools testsexits 0.python -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp.py docs/mobile.mdexits0 with no output.
docs/mobile.mdrecords both counts and the evidence ID. The differential is local analysis ofthe shipped file; nothing was executed. No game files, no GPU, nothing online. Tested on Linux
(openSUSE Tumbleweed, Python 3.13.18, binutils 2.47), 12 cores.
AI-assisted (DeepSeek V4.1 Flash).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.