test(relinker): execute the in-place Rosetta replacements #8236
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8236"
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?
Imported from boykopovar/AnyPS5. Originally posted by javierUDP on 2026-10-20T05:22:39Z.
What
The
--to-rosettareplacements for RDPID, RDSEED and CLWB are checked through their bytes, but none of them is ever executed, while the SSE4A, SHA, CLZERO, reciprocal, RDPRU, MCOMMIT and RDTSCP stubs are. All three of these raise an illegal instruction on a Rosetta host, which is the reason the replacements exist, so running them is what shows they stand in correctly.The execution section now calls each one and checks what it leaves behind:
Tested
Apple M5, macOS 26.4, AppleClang 21.0.0, relinker-only build of current
main.-DCMAKE_OSX_ARCHITECTURES=x86_64, executed under Rosetta: 209/209, with the three new checks running.python3 tools/check_conventions.py --base origin/mainpasses.No Linux or Windows host was available; the section also builds there and the checks are host-independent.
#7999 moves in-place AMD-only replacements into a short instruction window and touches the same file. These checks exercise that path rather than change it, so there is no functional dependency either way.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file: n/a, test-only change.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by javierUDP on 2026-10-20T06:19:49Z.
On the overlap notice: #7918 does not merge into
mainon its own. Merged intomain1ed63f63cby itself it conflicts incore/relinker/codegen/tests/Amd64OnlyConverterTests.cpp, the same file the notice lists, so the conflict is between that pull request andmainrather than with this one, and it needs a rebase either way.This branch only appends three functions to the x86-64 execution section of that file and three calls in
main(), so once #7918 is rebased the two should compose without touching the same lines.Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-20T07:32:29Z.
Review: COMMENTED
Reviewed the diff and CI results.
Code: Adds execution tests for three Rosetta in-place replacements that were previously only checked through byte comparison:
stc+setc). Correct — the trampoline stub for RDPID returns processor 0 as documented.produced = carry == 1) is the right way to detect a valid seed value.rbx=0x5A...) are preserved, plus flags unchanged. Correct — CLWB should be a no-op from the caller's perspective.All three follow the established pattern from
rdtscpExecution()/mcommitExecution()above: mmap executable page, copy stub, inline asm call withsub $128, %%rspfor red-zone, check results, munmap.The non-x86-64 stubs (
void rdpidExecution() {}etc.) are correctly added in the#elsebranch to keep the test compilable on all platforms.CI: All green —
conventions,intake,labels,eligibilitypass. The relinker tests themselves pass on all four platform/compiler combinations: macOS ARM64, macOS x86_64 (Rosetta — where these stubs are actually exercised), Ubuntu g++, and Windows g++.PR body: Complete template, honest about the host used (Apple M5 under Rosetta). Notes the overlap with #7999 and correctly explains why there's no functional dependency.
No issues found. Well-structured test addition that fills a real coverage gap.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-21T21:34:23Z.
Review: COMMENTED
Independent run on Apple silicon under Rosetta 2, which the thread had not covered yet.
Apple M2 Max, macOS 27.2 (26B5091g), Apple clang, CMake 4.4.4, Ninja, relinker-only Release build. Head
d5886fce8merged onto current main0c6a5bd59(clean). Built arm64 and x86-64 (-DCMAKE_OSX_ARCHITECTURES=x86_64 -DPython3_EXECUTABLE=/usr/bin/python3, Python 3.9.6).amd64_only_converterpasses. The three new execution tests run the converted in-place replacements as real code: RDPID leaves processor 0 in RAX and keeps the carry flag set, RDSEED reports a random value (CF set) within the 16 attempts, and CLWB is a no-op that leaves its address register, an unrelated register and the flags unchanged.__x86_64__-only no-ops there) andamd64_only_converterpasses.main; this is the added execution coverage running on an Apple host under Rosetta.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T03:53:51Z.
Review: APPROVED
Re-reviewed
e27a9d3e01e51eb1cc549ba80ba1b2f1b356c83a. Approve; the earlier blocker is resolved.The earlier merge-conflict blocker is cleared. Reviewed the complete current test-only patch: RDPID and CLWB checks verify relevant register/flag preservation, RDSEED checks the replacement length and bounded success, and inline calls protect the red zone. The new execution bodies remain guarded for Linux/macOS x86-64.
Validation: The exact current file compiles in C++23 with current matching relinker headers. Hosted Build 40256933244 logs show amd64_only_converter passes on Ubuntu (job 121360738660) and macOS x86-64 (job 121360738706); the respective full relinker CTest runs report 309 and 299 tests passing. Current Conventions passes.
Scope: Local Windows syntax does not execute the guarded bodies; execution evidence comes from the hosted merged-PR jobs. No game/performance or broad CPU-feature portability claim.