mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1483] x64_recomp: 0F 01 /r needs its ModRM byte (X64-RECOMP-GROUP7) #1513
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#1513
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/1483
Author: @kett1m
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:x64-recomp-grp7📝 Commits (1)
c1df54cx64_recomp: 0F 01 /r is a ModRM group, so the walk stops one byte late (X64-RECOMP-GROUP7)📊 Changes
3 files changed (+59 additions, -5 deletions)
View changed files
📝
docs/mobile.md(+15 -4)📝
tests/test_x64_recomp.py(+20 -0)📝
tools/x64_recomp.py(+24 -1)📄 Description
tools/x64_recomp.py's0Ftable has no entry for opcode0x01, so the wholesystem-instruction group decoded as the unknown
op0f_01of two bytes. Every form of0F 01 /rcarries a ModRM byte: the memory forms are SGDT/SIDT/LGDT/LIDT/SMSW/LMSW/INVLPG, andthe register forms are whole ModRM bytes (MONITOR, MWAIT, XGETBV, XSETBV, CLZERO, MONITORX,
MWAITX, RDTSCP, SWAPGS, the VMX/SVM instructions). The walk stopped after the two opcode bytes,
so every instruction after it in the function was read at the wrong offset.
Measurement
A per-instruction differential against GNU objdump over the retail image's
.text: objdump'slinear walk and the decoder's walk read the same bytes and the instruction lengths are compared
(
objdump -d --start-address/--stop-addressover the section, 26,674,180 objdump instructions).The image is
game_scarlett_master.exe, SHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993. REA measured the sectionranges with
gnu.objdumpsection_headers, evidenceev_e29cbdffd0dc7c46889b2a1f955011ce9f2795017233c97107ded73f9186dd90:.textVMA0x140001000, file0x400, size0x5f3f966;.pdataVMA0x14abcf000, file0x6e03a00.The differential flags 16
0F 01boundaries, all one byte short before the fix:clzero, RVAs0x4e89a70to0x4e89bb4, in two neighbouring.pdatafunctions(
0x4e899c0and0x4e89b80). The first sits at the head of the title's 64-byte zeroing loop(
clzero;add $0x40,%rax;cmp %r10,%rax;jbback to it), so these run, they are notstray data.
xgetbv, RVAs0x21ae7b5and0x55e8e92.monitorx, RVAs0x4fafbd7and0x4fafd21.mwaitx, RVAs0x4fafc00and0x4fafd52.Over the whole
.pdatacorpus (recomp_census.py's walk, 299,257 functions), the fix lets 9functions decode further, 638 instructions in total, and 7 of them reach the end of the function
with no unknown instruction left.
Test
tests/test_x64_recomp.py::DecodeTests::test_group7_0f01_carries_modrmpins the register forms(CLZERO, XGETBV, MONITORX, MWAITX, MONITOR, RDTSCP, SWAPGS, SMSW) at three bytes and the memory
forms (
sgdt [rax],sgdt [rsp+0x10],invlpg [rsp+0x10]) at their fullModRM/SIB/displacement length. Against the unfixed decoder it fails:
0f 01 fcdecodes to size2.
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 the measurement and the evidence ID. The differential is local analysisof the 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.