feat(relinker): lower MCOMMIT and RDPRU for Intel with execution tests #2780

Merged
SuarezPM merged 1 commit from upstream-pr/2780 into main 2026-10-20 03:22:50 +00:00
SuarezPM commented 2026-10-10 14:37:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SuarezPM on 2026-10-10T14:37:26Z.


What

Narrowed per 19 Oct review: only the Intel lowering with its execution tests, rebased onto current main (eaa5c9238). The symbol-index and fuzz parts from the previous head are dropped: main already covers the hashed export provider map, and the matcher has been restructured since.

  • MCOMMIT lowers in place to STC plus NOP padding via _inPlace, preserving instruction length. RDPRU lowers through an out-of-line stub that frames the red zone with the existing LeaRspBelowRedZone/LeaRspRestore spills and dispatches ECX: selectors 0/1 (AMD APM Vol. 3 MPERF/APERF, unreadable on Intel hosts) return the host TSC as a disclosed monotonic-counter approximation (ratio always 1.0); other selectors yield zero EDX:EAX. LOCK-prefixed MCOMMIT/RDPRU stay Unsupported. Sequences containing either instruction lower through _emitOutOfLine with the same wait-state check.
  • docs/dev/debt/relinker.md replaces the does not lower RDPRU/MCOMMIT entry with the lowering description and its unverified assumptions (TSC-for-MPERF/APERF substitution, non-zero selectors, any console path reporting MCOMMIT CF=0).

Tested

$ cmake -S . -B build-relinker -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON
-- Configuring done -- Generating done

$ cmake --build build-relinker --parallel
[250/250] Linking CXX executable tests/amd64_only_converter_tests

$ ctest --test-dir build-relinker --output-on-failure
100% tests passed out of 218 (amd64_only_converter passed, incl. rdpruExecution/mcommitExecution)

$ python3 tools/check_conventions.py --base origin/main
All conventions checks passed.

Host: Linux x86-64 (CachyOS), Ryzen 5 3600, RTX 2060 Super. Execution tests ran on this host. Full Linux/Windows builds need the maintainer manual build.yml run for PR 2780.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (relinker-only change, no AGC/shader recompiler/VideoOut)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4811973638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780). Originally posted by [SuarezPM](https://github.com/SuarezPM) on 2026-10-10T14:37:26Z. --- ### What Narrowed per 19 Oct review: only the Intel lowering with its execution tests, rebased onto current `main` (`eaa5c9238`). The symbol-index and fuzz parts from the previous head are dropped: `main` already covers the hashed export provider map, and the matcher has been restructured since. - `MCOMMIT` lowers in place to `STC` plus NOP padding via `_inPlace`, preserving instruction length. `RDPRU` lowers through an out-of-line stub that frames the red zone with the existing `LeaRspBelowRedZone`/`LeaRspRestore` spills and dispatches `ECX`: selectors 0/1 (AMD APM Vol. 3 MPERF/APERF, unreadable on Intel hosts) return the host TSC as a disclosed monotonic-counter approximation (ratio always 1.0); other selectors yield zero `EDX:EAX`. `LOCK`-prefixed `MCOMMIT`/`RDPRU` stay `Unsupported`. Sequences containing either instruction lower through `_emitOutOfLine` with the same wait-state check. - `docs/dev/debt/relinker.md` replaces the `does not lower RDPRU/MCOMMIT` entry with the lowering description and its unverified assumptions (TSC-for-MPERF/APERF substitution, non-zero selectors, any console path reporting `MCOMMIT` `CF=0`). ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ``` $ cmake -S . -B build-relinker -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON -- Configuring done -- Generating done $ cmake --build build-relinker --parallel [250/250] Linking CXX executable tests/amd64_only_converter_tests $ ctest --test-dir build-relinker --output-on-failure 100% tests passed out of 218 (amd64_only_converter passed, incl. rdpruExecution/mcommitExecution) $ python3 tools/check_conventions.py --base origin/main All conventions checks passed. ``` Host: Linux x86-64 (CachyOS), Ryzen 5 3600, RTX 2060 Super. Execution tests ran on this host. Full Linux/Windows builds need the maintainer manual `build.yml` run for PR 2780. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a (relinker-only change, no AGC/shader recompiler/VideoOut) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-10 14:37:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T14:37:37Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098618731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780#issuecomment-6098618731). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T14:37:37Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
github-actions[bot] commented 2026-10-17 23:14:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T23:14:12Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7918 core/relinker/codegen/tests/Amd64OnlyConverterTests.cpp L1809-1810

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/relinker.md
PR 6977 docs/dev/debt/relinker.md
PR 7822 docs/dev/debt/relinker.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6242922586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780#issuecomment-6242922586). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T23:14:12Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7918](https://www.github.com/boykopovar/AnyPS5/pull/7918) | `core/relinker/codegen/tests/Amd64OnlyConverterTests.cpp` [L1809-1810](https://github.com/boykopovar/AnyPS5/blob/db9fe523101ebde1223442478e179f784f319f97/core/relinker/codegen/tests/Amd64OnlyConverterTests.cpp#L1809-L1810) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/relinker.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/relinker.md` | | [PR 7822](https://www.github.com/boykopovar/AnyPS5/pull/7822) | `docs/dev/debt/relinker.md` |
oneandonlydean commented 2026-10-17 23:57:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:57:54Z.


Thanks for reopening this. It no longer merges cleanly into current main. Could you rebase onto current main? The MCOMMIT/RDPRU lowering part overlaps #2771, which is open for the same instructions, so it would help to split this into separate PRs (symbol index, fuzz test, Intel lowering) and leave the lowering to whichever of the two lands first. We'll review and run full CI on the new heads.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243431935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780#issuecomment-6243431935). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T23:57:54Z. --- Thanks for reopening this. It no longer merges cleanly into current main. Could you rebase onto current main? The MCOMMIT/RDPRU lowering part overlaps #2771, which is open for the same instructions, so it would help to split this into separate PRs (symbol index, fuzz test, Intel lowering) and leave the lowering to whichever of the two lands first. We'll review and run full CI on the new heads.
oneandonlydean commented 2026-10-19 09:52:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T09:52:13Z.


@SuarezPM A correction to our 17 Oct comment: #2771 isn't open. It was closed without merging, so main still returns unsupported for MCOMMIT/RDPRU, and the lowering in this PR is still wanted.

Since then, main has also covered most of the symbol-index part (GuestModuleBuilder keeps the export type in its hashed provider map), and Amd64OnlyInstructionMatcher has been restructured. So the request is narrower now: could you rebase just the Intel lowering, with its execution tests, onto current main? We'll check MCOMMIT's flag result against the APM in review (this PR sets CF, #2771 cleared it), then run full CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264468877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780#issuecomment-6264468877). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T09:52:13Z. --- @SuarezPM A correction to our 17 Oct comment: #2771 isn't open. It was closed without merging, so `main` still returns unsupported for MCOMMIT/RDPRU, and the lowering in this PR is still wanted. Since then, `main` has also covered most of the symbol-index part (GuestModuleBuilder keeps the export type in its hashed provider map), and `Amd64OnlyInstructionMatcher` has been restructured. So the request is narrower now: could you rebase just the Intel lowering, with its execution tests, onto current `main`? We'll check MCOMMIT's flag result against the APM in review (this PR sets CF, #2771 cleared it), then run full CI.
SuarezPM commented 2026-10-19 22:22:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SuarezPM on 2026-10-19T22:22:46Z.


Rebased to current main as requested 19 Oct, narrowed to just the Intel lowering with its execution tests.

  • Dropped the symbol-index and fuzz parts: main already keeps the export type in its hashed provider map, and the matcher has been restructured since (Rosetta target, _emitOutOfLine central dispatch). This head ports the lowering onto that structure: Match + _emitOutOfLine both route RDPRU/MCOMMIT with the same _validWait fail-closed check.
  • MCOMMIT flag note for review: this PR sets CF via STC (committed case as the only observable one under x86-TSO with host-DRAM-backed guest memory). #2771 cleared it; main still returns Unsupported for both, verified at eaa5c9238.
  • Overlap after narrowing (pr_overlap.py on ai/relinker-hardening): line-level conflicts only with #7822 (debt/relinker.md L14, the same entry this PR rewrites) and #7918 (Amd64OnlyConverterTests.cpp L1796-1797, insertion area); 3 PRs share files but could not be compared due to base conflicts (#5021, #6977 debt; #7332 matcher+tests+debt) - reviewed manually, no same-function duplication.
  • Evidence on this host (Linux x86-64 CachyOS, Ryzen 5 3600): relinker-only Release build 250/250, ctest 218/218 passed including rdpruExecution/mcommitExecution, check_conventions.py passed. Full builds need the maintainer manual build.yml run for 2780.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278670673 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2780#issuecomment-6278670673). Originally posted by [SuarezPM](https://github.com/SuarezPM) on 2026-10-19T22:22:46Z. --- Rebased to current main as requested 19 Oct, narrowed to just the Intel lowering with its execution tests. - Dropped the symbol-index and fuzz parts: main already keeps the export type in its hashed provider map, and the matcher has been restructured since (Rosetta target, _emitOutOfLine central dispatch). This head ports the lowering onto that structure: Match + _emitOutOfLine both route RDPRU/MCOMMIT with the same _validWait fail-closed check. - MCOMMIT flag note for review: this PR sets CF via STC (committed case as the only observable one under x86-TSO with host-DRAM-backed guest memory). #2771 cleared it; main still returns Unsupported for both, verified at eaa5c9238. - Overlap after narrowing (pr_overlap.py on ai/relinker-hardening): line-level conflicts only with #7822 (debt/relinker.md L14, the same entry this PR rewrites) and #7918 (Amd64OnlyConverterTests.cpp L1796-1797, insertion area); 3 PRs share files but could not be compared due to base conflicts (#5021, #6977 debt; #7332 matcher+tests+debt) - reviewed manually, no same-function duplication. - Evidence on this host (Linux x86-64 CachyOS, Ryzen 5 3600): relinker-only Release build 250/250, ctest 218/218 passed including rdpruExecution/mcommitExecution, check_conventions.py passed. Full builds need the maintainer manual build.yml run for 2780.
Sign in to join this conversation.
No reviewers
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!2780
No description provided.