loader: emulate the register forms of SSE4a EXTRQ and INSERTQ #467

Closed
github-bot wants to merge 1 commit from gh-pr/467/head into gh-pr/467/base
Owner

@⁠brandostrong on GitHub · 2026-09-02 21:50 UTC · original
brandostrong:fix/sse4a-register-forms → main · +42 −12 · 1 files · 1 commits · closed without merging

Problem. Astro Bot's asset unpacker executes register-form extrq xmm2, xmm5 (66 0f 79 d5) and insertq. The emulator handled only the immediate forms, so the instruction trapped. A first attempt with swapped operands corrupted a register and crashed about a thousand flips later in libc.

Change. Emulate the register forms per the AMD64 SSE4a specification: destination is ModRM.reg, the length/index descriptor is ModRM.rm, and the destination's upper qword is left untouched as the hardware does.

Effect. Astro Bot's unpack stage runs through with no register corruption (six further runs).

Verification. Verified against the game's own unpacker disassembly; loader tests pass.

References

  • AMD64 Architecture Programmer's Manual, Volume 4 (128-bit and 256-bit media instructions): EXTRQ (66 0F 78 /0 ib ib, 66 0F 79 /r) and INSERTQ (F2 0F 78 /r ib ib, F2 0F 79 /r); destination is ModRM.reg, upper qword unchanged.
**@⁠brandostrong** on GitHub · 2026-09-02 21:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/467) `brandostrong:fix/sse4a-register-forms` → `main` · +42 −12 · 1 files · 1 commits · closed without merging **Problem.** Astro Bot's asset unpacker executes register-form `extrq xmm2, xmm5` (`66 0f 79 d5`) and `insertq`. The emulator handled only the immediate forms, so the instruction trapped. A first attempt with swapped operands corrupted a register and crashed about a thousand flips later in libc. **Change.** Emulate the register forms per the AMD64 SSE4a specification: destination is ModRM.reg, the length/index descriptor is ModRM.rm, and the destination's upper qword is left untouched as the hardware does. **Effect.** Astro Bot's unpack stage runs through with no register corruption (six further runs). **Verification.** Verified against the game's own unpacker disassembly; loader tests pass. **References** - AMD64 Architecture Programmer's Manual, Volume 4 (128-bit and 256-bit media instructions): `EXTRQ` (`66 0F 78 /0 ib ib`, `66 0F 79 /r`) and `INSERTQ` (`F2 0F 78 /r ib ib`, `F2 0F 79 /r`); destination is ModRM.reg, upper qword unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:22:25 +00:00
github-bot closed this pull request 2026-11-26 09:22:25 +00:00
Author
Owner

@⁠Nmzik on GitHub · 2026-09-17 07:17 UTC · original

Credited

**@⁠Nmzik** on GitHub · 2026-09-17 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/467#issuecomment-5710559299) Credited

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.