relinker: Windows conversion fails since #2238 on titles with XOP code (decoder has no XOP support) #2559

Closed
opened 2026-10-10 05:35:06 +00:00 by reyani-dev · 1 comment
reyani-dev commented 2026-10-10 05:35:06 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T05:35:06Z.


Since #2238 (ba525633, "root code addresses taken by RIP-relative LEA"), the Windows conversion of three homebrew catalog titles fails:

FAIL: Code analysis: overlapping instruction boundaries (offset 0x1ce450b)   PPSA74126 Stremio Plus
FAIL: Code analysis: overlapping instruction boundaries (offset 0x1b3938b)   PPSA99082 OpenNOW PS5
FAIL: Code analysis: overlapping instruction boundaries (offset 0x2b08e1b)   PPSA99420

Linux output (relinker eboot.elf app.elf) still converts them, so Linux-only catalog runs don't show it. Stremio Plus and OpenNOW converted on main c72d5ce1. A git bisect of core/relinker between c72d5ce1 and bc40a6b5 points to ba525633, and the parent of that commit converts both. (PPSA99420 failed earlier on the now-fixed empty PT_TLS check.)

Cause. The x86 decoder has no XOP (AMD 8F escape) support. It reads 8F E8 .. as POP r/m with a 2-byte length. In Stremio Plus, a CPU-dispatch routine at 0x1c135d7 stores function pointers with lea r8, [rip+...] to 0x1ce4470 and 0x1ce4560. Those are real function starts, using XOP vpperm (8f e8 f8 a3 4a 10 60, 8f e8 c0 a3 ba 70 ff ff ff 30, …). #2238 now roots them, and decoding them loses the instruction boundaries. The walk then lands on the last byte of vmovdqa %xmm1,0x40(%rdi) at 0x1ce450b, and the next vmovq 0x64(%rsi),%xmm0 has a 0x64 displacement byte, which the overlap check takes for an FS prefix. The XOP paths are never executed on a PS5 (Zen 2 has no XOP), but they have to decode.

Fix, ready to cherry-pick. AchrafReyani:fix/relinker-decode-xop (2253d53d, one commit on bc40a6b5). I can't open it as a PR because of the intake check.

  • X64InstructionDecoder treats 8F followed by a map field (low 5 bits) of 8 or more as a three-byte XOP prefix. 8F can only be POP r/m with ModRM.reg = 0, so its next byte's low 5 bits are below 8. The prefix is followed by an opcode and a ModRM operand, plus an 8-bit immediate in map 8 or a 32-bit one in map 0Ah.
  • This applies in both the length decoder and DecodeInstruction, so XOP RIP-relative operands are reported like VEX ones.
  • amd64_only_converter gains XOP lengths: register, disp8 and disp32 forms, maps 8, 9 and 0Ah, with the two instructions above from the title. It also checks that 8F C0, 41 8F 07 and 8F 05 disp32 still decode as POP, and that an XOP RIP-relative operand is reported. Without the decoder change these checks fail ("decoded with the wrong length").

Checked on Windows (WinLibs GCC 15.2.0, relinker-only Release build):

  • The relinker ctest passes 55/55.
  • With the fix, all three titles convert again with --windows.
  • I relinked all 48 catalog titles that could be downloaded and unwrapped (sha256 checked against the catalog records) with main bc40a6b5 and with the branch. These three are the only titles whose result changes.
  • On the fork CI, the relinker jobs pass on Ubuntu, Windows and macOS.

The titles were relinked only, not executed.

Found with Claude Code.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5788467994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2559). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T05:35:06Z. --- Since #2238 (`ba525633`, "root code addresses taken by RIP-relative LEA"), the Windows conversion of three homebrew catalog titles fails: ``` FAIL: Code analysis: overlapping instruction boundaries (offset 0x1ce450b) PPSA74126 Stremio Plus FAIL: Code analysis: overlapping instruction boundaries (offset 0x1b3938b) PPSA99082 OpenNOW PS5 FAIL: Code analysis: overlapping instruction boundaries (offset 0x2b08e1b) PPSA99420 ``` Linux output (`relinker eboot.elf app.elf`) still converts them, so Linux-only catalog runs don't show it. Stremio Plus and OpenNOW converted on `main` c72d5ce1. A `git bisect` of `core/relinker` between c72d5ce1 and bc40a6b5 points to `ba525633`, and the parent of that commit converts both. (PPSA99420 failed earlier on the now-fixed empty `PT_TLS` check.) **Cause.** The x86 decoder has no XOP (AMD `8F` escape) support. It reads `8F E8 ..` as `POP r/m` with a 2-byte length. In Stremio Plus, a CPU-dispatch routine at `0x1c135d7` stores function pointers with `lea r8, [rip+...]` to `0x1ce4470` and `0x1ce4560`. Those are real function starts, using XOP `vpperm` (`8f e8 f8 a3 4a 10 60`, `8f e8 c0 a3 ba 70 ff ff ff 30`, …). #2238 now roots them, and decoding them loses the instruction boundaries. The walk then lands on the last byte of `vmovdqa %xmm1,0x40(%rdi)` at `0x1ce450b`, and the next `vmovq 0x64(%rsi),%xmm0` has a `0x64` displacement byte, which the overlap check takes for an FS prefix. The XOP paths are never executed on a PS5 (Zen 2 has no XOP), but they have to decode. **Fix, ready to cherry-pick.** [`AchrafReyani:fix/relinker-decode-xop`](https://github.com/AchrafReyani/AnyPS5/tree/fix/relinker-decode-xop) (2253d53d, one commit on bc40a6b5). I can't open it as a PR because of the intake check. - `X64InstructionDecoder` treats `8F` followed by a map field (low 5 bits) of 8 or more as a three-byte XOP prefix. `8F` can only be `POP r/m` with ModRM.reg = 0, so its next byte's low 5 bits are below 8. The prefix is followed by an opcode and a ModRM operand, plus an 8-bit immediate in map 8 or a 32-bit one in map 0Ah. - This applies in both the length decoder and `DecodeInstruction`, so XOP RIP-relative operands are reported like VEX ones. - `amd64_only_converter` gains XOP lengths: register, disp8 and disp32 forms, maps 8, 9 and 0Ah, with the two instructions above from the title. It also checks that `8F C0`, `41 8F 07` and `8F 05 disp32` still decode as `POP`, and that an XOP RIP-relative operand is reported. Without the decoder change these checks fail ("decoded with the wrong length"). **Checked on Windows** (WinLibs GCC 15.2.0, relinker-only Release build): - The relinker `ctest` passes 55/55. - With the fix, all three titles convert again with `--windows`. - I relinked all 48 catalog titles that could be downloaded and unwrapped (sha256 checked against the catalog records) with `main` bc40a6b5 and with the branch. These three are the only titles whose result changes. - On the fork CI, the relinker jobs pass on Ubuntu, Windows and macOS. The titles were relinked only, not executed. Found with Claude Code.
reyani-dev commented 2026-10-10 06:04:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T06:04:07Z.


Full build of the branch on the fork (run 38027642514) merged into main bc40a6b5:

  • the Linux job passes;
  • the relinker jobs pass on Linux, Windows and macOS;
  • the Windows job passes 606/606 on its rerun. The first attempt hit guest_video_out_wqhd_detection with 0xc0000374, the VideoOut heap corruption of #2540.

I also relinked the three titles with --windows --to-intel. They convert with the branch, so the XOP code (CPU-dispatched, never run on a PS5) doesn't trip the AMD-only converter. On main they fail the same way as without --to-intel.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094473871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2559#issuecomment-6094473871). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T06:04:07Z. --- Full build of the branch on the fork ([run 38027642514](https://github.com/AchrafReyani/AnyPS5/actions/runs/38027642514)) merged into `main` bc40a6b5: - the Linux job passes; - the relinker jobs pass on Linux, Windows and macOS; - the Windows job passes 606/606 on its rerun. The first attempt hit `guest_video_out_wqhd_detection` with `0xc0000374`, the VideoOut heap corruption of #2540. I also relinked the three titles with `--windows --to-intel`. They convert with the branch, so the XOP code (CPU-dispatched, never run on a PS5) doesn't trip the AMD-only converter. On `main` they fail the same way as without `--to-intel`.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2559
No description provided.