mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:25:52 +01:00
[PR #1120] x64_recomp: vzeroupper is three bytes, not four (X64-RECOMP-VZEROUPPER-NO-MODRM) #1155
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#1155
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/1120
Author: @kett1m
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:x64-recomp-vzeroupper📝 Commits (1)
7b78bd6x64_recomp: vzeroupper is three bytes, not four (X64-RECOMP-VZEROUPPER-NO-MODRM)📊 Changes
3 files changed (+51 additions, -1 deletions)
View changed files
📝
tests/test_recomp_census.py(+26 -0)📝
tests/test_x64_recomp.py(+16 -0)📝
tools/x64_recomp.py(+9 -1)📄 Description
Claimed in the coordination issue as: X64-RECOMP-VZEROUPPER-NO-MODRM
What and why
decode_onegave every VEX map-1 opcode the operand shapeV W, which reads a ModRMbyte. VEX.128/256.0F.WIG 77 (vzeroupper / vzeroall) is the one map-1 VEX opcode with no
ModRM byte at all, so it decoded as four bytes and the byte it took as an operand was
really the next instruction. From the first vzeroupper in a function the walk was one
byte out of step, and the shifted walk could run past the end of the function.
Measured on the retail Xbox Series image (
game_scarlett_master.exe, SHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993) with REAinspect_with_objdump. Section-header evidenceev_e29cbdffd0dc7c46889b2a1f955011ce9f2795017233c97107ded73f9186dd90maps.textRVA0x140001000to file0x400and.pdataRVA0x14abcf000to file0x6e03a00;file-header evidence
ev_4ec749bb6395770cf8a099344c042bfd7ba67ff269f47e7ae115443028d4e127gives entry
0x1456a1ec8. Ten.pdatafunctions hold such a vzeroupper. RVA0xa4ab00(file
0xa49f00, 95 bytes) hasc5 f8 77at offset 81 followed by thee8of a call,and ends
90 48 83 c4 68 c3, that isnop; add rsp,68h; ret. The walk readc4 68 c3there because the vzeroupper had eaten the call's
e8.Before the change
python3 -I tools/recomp_census.py <exe>aborted withIndexError: index out of range. After it the census runs over all 299,257.pdatafunctions: 21,518,571decoded instructions, 84.77% translated coverage, 41,091 decode errors, 48,224
v77, andno
.pdatafunction ends inside a VEX or EVEX prefix (10 before). 20,620 of the 299,257functions decode to a different instruction stream; 453 have a decode gap only in the
unfixed walk and the change adds none.
tools/gdk_runtime_calls.pyalready makes this exception for the same opcode(
modrm = not (vmap == 1 and b == 0x77)), andtests/test_gdk_runtime_calls.pypinsC5 F8 77at 3 bytes.Tested
python3 -I tests/test_x64_recomp.py: 36 tests OK, 26 qemu skips.python3 -I tests/test_recomp_census.py: 9 tests OK.The two new tests fail against the unfixed decoder (2 failures, 2 errors in the decoder
file; 1 failure, 1 error in the census file).
python3 -m compileall -q make_game.py tools tests: exit 0.python3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp.py tests/test_recomp_census.py: exit 0, no output.The tests are synthetic bytes and a byte-built PE; no game files.
GPUs tested: n/a (decoder and census are CPU-only)
AI-assisted: yes (DeepSeek V4.1 Flash)
Checklist
mainand merges cleanly.docs/design.mdcontract row.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.