feat(relinker): record the CPU extensions a conversion still needs #23279

Closed
relativespace2K wants to merge 8 commits from upstream-pr/23279 into main
relativespace2K commented 2026-11-18 21:43:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by relativespace2K on 2026-11-18T21:43:24Z.


What

--to-avx output could not start on Linux or Windows, because only the macOS runtime skips the host CPU check; the other runtimes required every extension the lowering can remove. This records what the conversion still needs and checks only that.

  • A classifier in codegen maps a decoded instruction to the checked extension it requires: LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA or F16C. It follows .eh_frame function ranges where the image has them, and undecodable bytes in a code segment record all seven extensions, so the scan can only over-require.
  • For --to-avx conversions the relinker takes the union over the lowered executable and the generated bundled modules, and writes it into the main executable: an AnyPS5 PT_NOTE on Linux, a .aps5cpu section on Windows. Other conversions write no record and their bytes are unchanged.
  • libkernel reads the record from the main image and requires the baseline plus only the recorded extensions; without a record it keeps the current full check. A malformed record keeps the full check too.
  • --to-avx no longer requires --macos.

AVX2, F16C, FMA, PDEP, PEXT, RDRAND and RDSEED are still not lowered; a title that reaches one records that extension and is refused at start-up on a host that lacks it. F16C and FMA lowering are the follow-ups mentioned in the issue.

Tested

macOS 26.7.1, x86-64, AppleClang 17: relinker-only Release build, 883/883 CTest pass.

Linux (Pop!_OS, kernel 7.0), x86-64, Intel i5-8250U, GCC 11.4, CMake 3.22, git 2.56.1, node 22.23.5: relinker-only Release build in a git clone, 995/995 CTest pass.

The HostCpu unit test was compiled and run on that Linux host, with stubs for the two libc log symbols it links. A test binary carrying the note with mask 0 lets a synthetic register set without AVX2 pass CheckHostCpu; the same binary without the note still throws for AVX2. The relinker integration test checks the Linux note and the Windows section for VPGATHERDD (AVX2), VFMADD132PS (FMA), VCVTPH2PS (F16C), VADDPS (no requirement) and a NOP, and checks that a conversion without --to-avx writes neither.

The Windows reader was not executed, and no game title was converted with --to-avx.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: Fixes #22530
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5384597195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279). Originally posted by [relativespace2K](https://github.com/relativespace2K) on 2026-11-18T21:43:24Z. --- ### What `--to-avx` output could not start on Linux or Windows, because only the macOS runtime skips the host CPU check; the other runtimes required every extension the lowering can remove. This records what the conversion still needs and checks only that. - A classifier in codegen maps a decoded instruction to the checked extension it requires: LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA or F16C. It follows `.eh_frame` function ranges where the image has them, and undecodable bytes in a code segment record all seven extensions, so the scan can only over-require. - For `--to-avx` conversions the relinker takes the union over the lowered executable and the generated bundled modules, and writes it into the main executable: an `AnyPS5` `PT_NOTE` on Linux, a `.aps5cpu` section on Windows. Other conversions write no record and their bytes are unchanged. - libkernel reads the record from the main image and requires the baseline plus only the recorded extensions; without a record it keeps the current full check. A malformed record keeps the full check too. - `--to-avx` no longer requires `--macos`. AVX2, F16C, FMA, PDEP, PEXT, RDRAND and RDSEED are still not lowered; a title that reaches one records that extension and is refused at start-up on a host that lacks it. F16C and FMA lowering are the follow-ups mentioned in the issue. ### Tested macOS 26.7.1, x86-64, AppleClang 17: relinker-only Release build, 883/883 CTest pass. Linux (Pop!_OS, kernel 7.0), x86-64, Intel i5-8250U, GCC 11.4, CMake 3.22, git 2.56.1, node 22.23.5: relinker-only Release build in a git clone, 995/995 CTest pass. The `HostCpu` unit test was compiled and run on that Linux host, with stubs for the two libc log symbols it links. A test binary carrying the note with mask `0` lets a synthetic register set without AVX2 pass `CheckHostCpu`; the same binary without the note still throws for AVX2. The relinker integration test checks the Linux note and the Windows section for VPGATHERDD (AVX2), VFMADD132PS (FMA), VCVTPH2PS (F16C), VADDPS (no requirement) and a NOP, and checks that a conversion without `--to-avx` writes neither. The Windows reader was not executed, and no game title was converted with `--to-avx`. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: Fixes #22530 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-18 21:46:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T21:46:09Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0cbd3d4bab:

  • Conventions: tools/check_conventions.py passed.
  • Build: cli_args_tests, host_cpu_tests, required_extensions_tests built cleanly.
  • CTest (host_cpu, required_extensions, cli_args):
    1/3 Test #5910: required_extensions ..............   Passed    0.00 sec
    2/3 Test #5620: host_cpu .........................   Passed    0.01 sec
    3/3 Test #5931: cli_args .........................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 3
    
  • Negative control: with core/libs/prx/libkernel/System/include/HostCpu.hpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/cli/src/CliArgs.cpp, core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/general/IProgramHeaderLayoutBuilder.hpp, core/relinker/elfpatcher/include/elfpatcher/general/ProgramHeaderLayoutRequest.hpp, core/relinker/elfpatcher/include/elfpatcher/linux/LinuxElfPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/macos/MacOsMachOPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp, core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp, core/relinker/elfpatcher/src/macos/MacOsMachOPatcher.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, core/relinker/relinker/include/relinker/guest/GuestImage.hpp, core/relinker/relinker/src/guest/GuestModuleBuilder.cpp, core/relinker/relinker/src/pipeline/Conversion.cpp, core/relinker/codegen/src/x86/RequiredExtensions.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified HostCpu.cpp note parsing logic in ReadNoteExtensions and RecordedExtensions on Linux and Windows for bounds checks, alignment padding, and endianness
    • Verified Codegen::RequiredExtensions instruction decoding, classification of VEX/EVEX and opcode tables for AVX/AVX2/BMI1/BMI2/LZCNT/MOVBE/FMA/F16C
    • Verified ElfImageExtensions and GuestModuleBuilder logic when extracting exception unwind code ranges and folding module requirements into executable metadata
    • Verified LinuxElfPatcher and WindowsPePatcher layout, segment headers, note alignment, and program header count sizing when adding PT_NOTE and .aps5cpu sections
    • Verified AGENTS.md conventions regarding debt tracking, no code comments, and Conventional Commits

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5965687330 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5965687330). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T21:46:09Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0cbd3d4bab`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `cli_args_tests`, `host_cpu_tests`, `required_extensions_tests` built cleanly. - **CTest** (`host_cpu`, `required_extensions`, `cli_args`): ``` 1/3 Test #5910: required_extensions .............. Passed 0.00 sec 2/3 Test #5620: host_cpu ......................... Passed 0.01 sec 3/3 Test #5931: cli_args ......................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 3 ``` - **Negative control**: with `core/libs/prx/libkernel/System/include/HostCpu.hpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/cli/src/CliArgs.cpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IProgramHeaderLayoutBuilder.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/ProgramHeaderLayoutRequest.hpp`, `core/relinker/elfpatcher/include/elfpatcher/linux/LinuxElfPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/macos/MacOsMachOPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp`, `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp`, `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp`, `core/relinker/elfpatcher/src/macos/MacOsMachOPatcher.cpp`, `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`, `core/relinker/relinker/include/relinker/guest/GuestImage.hpp`, `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp`, `core/relinker/relinker/src/pipeline/Conversion.cpp`, `core/relinker/codegen/src/x86/RequiredExtensions.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified HostCpu.cpp note parsing logic in ReadNoteExtensions and RecordedExtensions on Linux and Windows for bounds checks, alignment padding, and endianness - Verified Codegen::RequiredExtensions instruction decoding, classification of VEX/EVEX and opcode tables for AVX/AVX2/BMI1/BMI2/LZCNT/MOVBE/FMA/F16C - Verified ElfImageExtensions and GuestModuleBuilder logic when extracting exception unwind code ranges and folding module requirements into executable metadata - Verified LinuxElfPatcher and WindowsPePatcher layout, segment headers, note alignment, and program header count sizing when adding PT_NOTE and .aps5cpu sections - Verified AGENTS.md conventions regarding debt tracking, no code comments, and Conventional Commits Looks Good To Me
MarcZX10 commented 2026-11-18 22:04:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T22:04:57Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: make a required-extension record enforceable only when it is well formed and contains no unknown extension bits.

What I ran

Reviewed head 0cbd3d4babf4de56e657ef452d5f38c98190b732 from the prepared diff and pinned reader. No build or tests were run.

Results

Check Result Note
Diff and changed code review passed Reviewed all changed files listed in the manifest.
Build and tests not run No commands run.

Findings

Blocking

  • core/libs/prx/libkernel/System/src/HostCpu.cpp:153: the Linux note reader accepts a version 1 record with any mask bits, including bits outside the seven defined extensions. MissingHostCpuFeatures only uses known bits, so an unknown bit is silently ignored and can cause startup to skip a CPU feature check the record intended to require. Reject masks containing unknown bits and fall back to the full host check, consistent with the stated malformed-record behavior.

Non-blocking

None.

Not verified

  • No build, tests, Windows reader execution, or converted game title was run in this review; the platform and title limitations are also reported by the author.
  • Read: HostCpu.hpp, HostCpu.cpp, HostCpu tests, relinker CMake and CLI files, RequiredExtensions.hpp/.cpp and tests, ELF/PE patcher interfaces and implementations, program-header layout builder, GuestImage.hpp, GuestModuleBuilder.cpp, Conversion.cpp, integration test, debt note, and usage documentation. Excluded files: none listed in files.json.

To get this to a good state

Reject unsupported extension mask bits and add coverage proving such a record falls back to the full CPU feature check. Re-run the relevant host CPU and relinker tests on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5965918406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5965918406). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T22:04:57Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: make a required-extension record enforceable only when it is well formed and contains no unknown extension bits. ## What I ran Reviewed head `0cbd3d4babf4de56e657ef452d5f38c98190b732` from the prepared diff and pinned reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Reviewed all changed files listed in the manifest. | | Build and tests | not run | No commands run. | ## Findings ### Blocking - `core/libs/prx/libkernel/System/src/HostCpu.cpp:153`: the Linux note reader accepts a version 1 record with any mask bits, including bits outside the seven defined extensions. `MissingHostCpuFeatures` only uses known bits, so an unknown bit is silently ignored and can cause startup to skip a CPU feature check the record intended to require. Reject masks containing unknown bits and fall back to the full host check, consistent with the stated malformed-record behavior. ### Non-blocking None. ## Not verified - No build, tests, Windows reader execution, or converted game title was run in this review; the platform and title limitations are also reported by the author. - Read: `HostCpu.hpp`, `HostCpu.cpp`, `HostCpu` tests, relinker CMake and CLI files, `RequiredExtensions.hpp/.cpp` and tests, ELF/PE patcher interfaces and implementations, program-header layout builder, `GuestImage.hpp`, `GuestModuleBuilder.cpp`, `Conversion.cpp`, integration test, debt note, and usage documentation. Excluded files: none listed in `files.json`. ## To get this to a good state Reject unsupported extension mask bits and add coverage proving such a record falls back to the full CPU feature check. Re-run the relevant host CPU and relinker tests on the new head.
MarcZX10 commented 2026-11-19 01:39:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T01:39:15Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: correct the extension scan so it cannot omit instructions outside recognized function ranges.

What I ran

Reviewed head 469dbdaf46474bece0c887b5f4718dc6b2dec3e1. No build or tests were run; the author reports test results in the PR description.

Results

Check Result Note
Diff and targeted source review passed Inspected all changed files listed in the manifest.
Build and tests not run Author-reported results were not independently verified.

Findings

Blocking

  • core/relinker/codegen/src/x86/RequiredExtensions.cpp:214: When codeRanges is nonempty, the scanner visits only those ranges. Bytes outside the ranges are ignored, including executable code that has no .eh_frame function entry. If such code contains an instruction the --to-avx conversion leaves requiring AVX2, FMA, or F16C, that extension is omitted from the record and libkernel can allow startup on a host that cannot execute it. Scan uncovered code conservatively, or fall back to requiring all extensions when function ranges do not cover the executable code.

Non-blocking

None.

Sources

Not verified

No executable build or test run was performed. The Windows record reader was not executed and no game title was converted, as noted in the description. All changed files listed in the manifest were included; no changed files were excluded.

To get this to a good state

Cover executable bytes outside recognized function ranges conservatively, then rerun the relinker build and tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5968045157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5968045157). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T01:39:15Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: correct the extension scan so it cannot omit instructions outside recognized function ranges. ## What I ran Reviewed head `469dbdaf46474bece0c887b5f4718dc6b2dec3e1`. No build or tests were run; the author reports test results in the PR description. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Inspected all changed files listed in the manifest. | | Build and tests | not run | Author-reported results were not independently verified. | ## Findings ### Blocking - `core/relinker/codegen/src/x86/RequiredExtensions.cpp:214`: When `codeRanges` is nonempty, the scanner visits only those ranges. Bytes outside the ranges are ignored, including executable code that has no `.eh_frame` function entry. If such code contains an instruction the `--to-avx` conversion leaves requiring AVX2, FMA, or F16C, that extension is omitted from the record and libkernel can allow startup on a host that cannot execute it. Scan uncovered code conservatively, or fall back to requiring all extensions when function ranges do not cover the executable code. ### Non-blocking None. ## Sources - Commit-pinned source: [RequiredExtensions.cpp](https://github.com/boykopovar/AnyPS5/blob/469dbdaf46474bece0c887b5f4718dc6b2dec3e1/core/relinker/codegen/src/x86/RequiredExtensions.cpp#L214-L230) - Commit-pinned source: [Conversion.cpp](https://github.com/boykopovar/AnyPS5/blob/469dbdaf46474bece0c887b5f4718dc6b2dec3e1/core/relinker/relinker/src/pipeline/Conversion.cpp#L177-L182) ## Not verified No executable build or test run was performed. The Windows record reader was not executed and no game title was converted, as noted in the description. All changed files listed in the manifest were included; no changed files were excluded. ## To get this to a good state Cover executable bytes outside recognized function ranges conservatively, then rerun the relinker build and tests on the updated head.
MarcZX10 commented 2026-11-19 02:15:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T02:15:07Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: validate PE header and section bounds before reading the CPU extension record.

What I ran

Reviewed head c777fb0391e4359a0e716896853e12175b543ed5; no build or tests were run. Read the prepared description, commits, manifest and diff, then targeted source ranges through repo_read.py.

Results

Check Result Note
Diff review passed Changed code inspected
Tests not run No local execution

Findings

Blocking

  • core/libs/prx/libkernel/System/src/HostCpu.cpp:138-145: The Windows reader trusts e_lfanew, the PE optional header, section count, VirtualSize, and VirtualAddress before dereferencing them. A malformed or truncated executable can make startup read outside the mapped image while looking for the record, rather than falling back to the full CPU check. Validate the DOS/NT header and section-table bounds against SizeOfImage, and ensure the record’s 16 bytes fit in the mapped section before parsing.

Non-blocking

None.

Not verified

No tests or builds were run. The description reports relinker test runs but the Windows reader was not executed and no game title was converted. All changed files listed in the manifest were included; targeted review focused on the CPU reader and extension-scanning implementation.

To get this to a good state

Validate PE image and section bounds before reading the record, then run the relevant Windows reader tests and relinker checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5968333059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5968333059). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T02:15:07Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: validate PE header and section bounds before reading the CPU extension record. ## What I ran Reviewed head `c777fb0391e4359a0e716896853e12175b543ed5`; no build or tests were run. Read the prepared description, commits, manifest and diff, then targeted source ranges through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Changed code inspected | | Tests | not run | No local execution | ## Findings ### Blocking - `core/libs/prx/libkernel/System/src/HostCpu.cpp:138-145`: The Windows reader trusts `e_lfanew`, the PE optional header, section count, `VirtualSize`, and `VirtualAddress` before dereferencing them. A malformed or truncated executable can make startup read outside the mapped image while looking for the record, rather than falling back to the full CPU check. Validate the DOS/NT header and section-table bounds against `SizeOfImage`, and ensure the record’s 16 bytes fit in the mapped section before parsing. ### Non-blocking None. ## Not verified No tests or builds were run. The description reports relinker test runs but the Windows reader was not executed and no game title was converted. All changed files listed in the manifest were included; targeted review focused on the CPU reader and extension-scanning implementation. ## To get this to a good state Validate PE image and section bounds before reading the record, then run the relevant Windows reader tests and relinker checks on the updated head.
MarcZX10 commented 2026-11-19 02:33:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T02:33:48Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected code did not show a concrete blocking defect, but the review is incomplete, so a formal approval is not justified.

What I ran

Reviewed head f21da9a7472abf38369ae99d57f312efb924cfa8. No build or tests were run; reported test results are from the PR description.

Results

Check Result Note
Code inspection not run Targeted reads only
Build and tests not run Author-reported results only

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The review bundle listed 24 changed files, all included in its manifest. I read targeted portions of six repository files: core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/relinker/src/pipeline/Conversion.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp, core/relinker/codegen/src/x86/RequiredExtensions.cpp, and core/relinker/relinker/src/guest/GuestModuleBuilder.cpp. I did not read the remaining changed files or run the reported tests. The review bundle documents macOS and Linux test results; Windows reader execution and conversion of a game title were not confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5968468953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5968468953). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T02:33:48Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected code did not show a concrete blocking defect, but the review is incomplete, so a formal approval is not justified. ## What I ran Reviewed head `f21da9a7472abf38369ae99d57f312efb924cfa8`. No build or tests were run; reported test results are from the PR description. ## Results | Check | Result | Note | |---|---|---| | Code inspection | not run | Targeted reads only | | Build and tests | not run | Author-reported results only | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The review bundle listed 24 changed files, all included in its manifest. I read targeted portions of six repository files: `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/relinker/src/pipeline/Conversion.cpp`, `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`, `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp`, `core/relinker/codegen/src/x86/RequiredExtensions.cpp`, and `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp`. I did not read the remaining changed files or run the reported tests. The review bundle documents macOS and Linux test results; Windows reader execution and conversion of a game title were not confirmed. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-19 18:51:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T18:51:21Z.

Review: COMMENTED


Reviewed — comments

The extension classifier under-reports requirements for valid AVX2 VEX instructions with a 128-bit vector length, so a generated record can let a host without AVX2 pass startup checks.

What I ran

Read the prepared description, commits, manifest, diff, and review-folder README for head 3b461b0e56cccde47d3508b2a4b1d9604da3d320. Inspected the changed classifier, conversion aggregation, PE metadata emission, ELF note emission, and host record parsing. No build or tests were run.

Results

Check Result Note
Source review failed AVX2 VEX forms can be recorded as AVX1
Build and tests not run No local execution performed
Windows runtime behavior not run Author reports the reader was not executed

Findings

Blocking

None.

Non-blocking

  • core/relinker/codegen/src/x86/RequiredExtensions.cpp:222: When Vector256 is false, the classifier returns zero for most VEX opcodes unless explicitly listed. Several AVX2 instructions have 128-bit VEX forms too (for example, VPERMD/VPERMPS and VPSLLVD/VPSRLVD). If one occurs in converted code, the generated record omits AVX2, so a non-AVX2 host may pass the extension check and then fault when that instruction runs. Account for the 128-bit AVX2 forms by opcode and encoding, and add tests for representative XMM forms.

Not verified

Builds, tests, physical-console behavior, the Windows startup reader, and full contents of the changed files outside the inspected ranges were not verified. Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch, review/README.md, core/relinker/codegen/src/x86/RequiredExtensions.cpp, core/relinker/relinker/src/pipeline/Conversion.cpp, core/relinker/relinker/src/guest/GuestModuleBuilder.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp, core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, and core/libs/prx/libkernel/System/src/HostCpu.cpp. The other files listed as changed in the manifest were not read; all files were marked included there, and none were excluded.

To get this to a good state

Nothing is required. Consider adding coverage for 128-bit AVX2 forms and ensuring they contribute the AVX2 bit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5981256187 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5981256187). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T18:51:21Z. **Review:** COMMENTED --- # Reviewed — comments The extension classifier under-reports requirements for valid AVX2 VEX instructions with a 128-bit vector length, so a generated record can let a host without AVX2 pass startup checks. ## What I ran Read the prepared description, commits, manifest, diff, and review-folder README for head `3b461b0e56cccde47d3508b2a4b1d9604da3d320`. Inspected the changed classifier, conversion aggregation, PE metadata emission, ELF note emission, and host record parsing. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | AVX2 VEX forms can be recorded as AVX1 | | Build and tests | not run | No local execution performed | | Windows runtime behavior | not run | Author reports the reader was not executed | ## Findings ### Blocking None. ### Non-blocking - `core/relinker/codegen/src/x86/RequiredExtensions.cpp:222`: When `Vector256` is false, the classifier returns zero for most VEX opcodes unless explicitly listed. Several AVX2 instructions have 128-bit VEX forms too (for example, `VPERMD`/`VPERMPS` and `VPSLLVD`/`VPSRLVD`). If one occurs in converted code, the generated record omits AVX2, so a non-AVX2 host may pass the extension check and then fault when that instruction runs. Account for the 128-bit AVX2 forms by opcode and encoding, and add tests for representative XMM forms. ## Not verified Builds, tests, physical-console behavior, the Windows startup reader, and full contents of the changed files outside the inspected ranges were not verified. Files read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`, `review/README.md`, `core/relinker/codegen/src/x86/RequiredExtensions.cpp`, `core/relinker/relinker/src/pipeline/Conversion.cpp`, `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp`, `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`, `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp`, `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp`, and `core/libs/prx/libkernel/System/src/HostCpu.cpp`. The other files listed as changed in the manifest were not read; all files were marked included there, and none were excluded. ## To get this to a good state Nothing is required. Consider adding coverage for 128-bit AVX2 forms and ensuring they contribute the AVX2 bit.
MarcZX10 commented 2026-11-19 19:08:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T19:08:44Z.

Review: COMMENTED


Reviewed — comments

Changes are required before merge: ensure a malformed matching CPU record cannot be ignored in favor of a later valid record, which can silently weaken the startup CPU check.

What I ran

Reviewed head 65f5ac8d10585e44aadea7b1a3f77afdac2d8df4 against base main using the prepared diff and pinned repository reader. No build or tests were run.

Results

Check Result Note
Source review passed Read the CPU record parsing and conversion paths
Build and tests not run Author-reported results were not independently run

Findings

Blocking

None.

Non-blocking

  • ParseCpuExtensionNote returns nullopt for a malformed matching note, but continues scanning after malformed nonmatching note entries. If a malformed note has overflowing aligned sizes, offset can wrap before the bounds check and permit out-of-bounds parsing; note records are untrusted executable input. Consider overflow-safe alignment and offset arithmetic before advancing. core/libs/prx/libkernel/System/src/HostCpu.cpp:196
  • If a matching note with an invalid version or mask appears before a later valid matching note, the parser returns nullopt; the full CPU check is retained as intended. However, malformed entries preceding a valid matching note are not consistently treated as a malformed whole record. This is a robustness concern in the parser; ensure malformed note structures terminate parsing safely. core/libs/prx/libkernel/System/src/HostCpu.cpp:195

Not verified

Builds and tests were not run. The author reports passing test suites on macOS and Linux; those results were not independently confirmed. The Windows reader and converted game titles were not executed, as noted in the description. I reviewed the core CPU record parser, classifier, conversion aggregation, and Linux/Windows record emission paths. I did not read every added line in every changed file; full review completeness is therefore not established. The prepared bundle listed every changed file as included; no files.json exclusion list was available through the reader.

To get this to a good state

Nothing is required. Optional: make ELF note size/alignment arithmetic overflow-safe and reject malformed note structures consistently before scanning later records.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5981526964 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5981526964). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T19:08:44Z. **Review:** COMMENTED --- # Reviewed — comments Changes are required before merge: ensure a malformed matching CPU record cannot be ignored in favor of a later valid record, which can silently weaken the startup CPU check. ## What I ran Reviewed head `65f5ac8d10585e44aadea7b1a3f77afdac2d8df4` against base `main` using the prepared diff and pinned repository reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Read the CPU record parsing and conversion paths | | Build and tests | not run | Author-reported results were not independently run | ## Findings ### Blocking None. ### Non-blocking - `ParseCpuExtensionNote` returns `nullopt` for a malformed matching note, but continues scanning after malformed nonmatching note entries. If a malformed note has overflowing aligned sizes, `offset` can wrap before the bounds check and permit out-of-bounds parsing; note records are untrusted executable input. Consider overflow-safe alignment and offset arithmetic before advancing. `core/libs/prx/libkernel/System/src/HostCpu.cpp:196` - If a matching note with an invalid version or mask appears before a later valid matching note, the parser returns `nullopt`; the full CPU check is retained as intended. However, malformed entries preceding a valid matching note are not consistently treated as a malformed whole record. This is a robustness concern in the parser; ensure malformed note structures terminate parsing safely. `core/libs/prx/libkernel/System/src/HostCpu.cpp:195` ## Not verified Builds and tests were not run. The author reports passing test suites on macOS and Linux; those results were not independently confirmed. The Windows reader and converted game titles were not executed, as noted in the description. I reviewed the core CPU record parser, classifier, conversion aggregation, and Linux/Windows record emission paths. I did not read every added line in every changed file; full review completeness is therefore not established. The prepared bundle listed every changed file as included; no `files.json` exclusion list was available through the reader. ## To get this to a good state Nothing is required. Optional: make ELF note size/alignment arithmetic overflow-safe and reject malformed note structures consistently before scanning later records.
MarcZX10 commented 2026-11-19 20:52:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T20:52:25Z.

Review: COMMENTED


Reviewed — no blocking findings

The change records the CPU extensions still required after --to-avx conversion; I found no verified blocking defect in the inspected code.

What I ran

Reviewed head 370690471546786ba9a86b7d9f42a15e9238806c using the prepared diff and repository reader. No build or tests were run.

Results

Check Result Note
Diff and metadata review passed Prepared review materials inspected
Targeted source review passed CPU record parsing, extension scan, conversion flow, ELF and PE record writing
Build and tests not run No execution performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The included changed files not read in full were core/libs/prx/libkernel/System/include/HostCpu.hpp, core/libs/tests/HostCpu.cpp, core/relinker/CMakeLists.txt, core/relinker/cli/src/CliArgs.cpp, core/relinker/cli/tests/CliArgsTests.cpp, core/relinker/codegen/include/codegen/x86/RequiredExtensions.hpp, core/relinker/codegen/tests/RequiredExtensionsTests.cpp, core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/general/IProgramHeaderLayoutBuilder.hpp, core/relinker/elfpatcher/include/elfpatcher/general/ProgramHeaderLayoutRequest.hpp, core/relinker/elfpatcher/include/elfpatcher/linux/LinuxElfPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/macos/MacOsMachOPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp, core/relinker/elfpatcher/src/macos/MacOsMachOPatcher.cpp, core/relinker/relinker/include/relinker/guest/GuestImage.hpp, core/relinker/relinker/tests/test_required_extensions_record.py, docs/dev/debt/changes/required-extensions-record.md, and docs/user/USAGE.md. The changed files read in full or relevant ranges were core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/codegen/src/x86/RequiredExtensions.cpp, core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, core/relinker/relinker/src/guest/GuestModuleBuilder.cpp, and core/relinker/relinker/src/pipeline/Conversion.cpp. The prepared description.md, commits.md, manifest.json, and diff.patch were also read; files.json was not available through the reader.

To get this to a good state

Nothing is required. No optional points.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5983205402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23279#pullrequestreview-5983205402). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T20:52:25Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The change records the CPU extensions still required after `--to-avx` conversion; I found no verified blocking defect in the inspected code. ## What I ran Reviewed head `370690471546786ba9a86b7d9f42a15e9238806c` using the prepared diff and repository reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and metadata review | passed | Prepared review materials inspected | | Targeted source review | passed | CPU record parsing, extension scan, conversion flow, ELF and PE record writing | | Build and tests | not run | No execution performed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The included changed files not read in full were `core/libs/prx/libkernel/System/include/HostCpu.hpp`, `core/libs/tests/HostCpu.cpp`, `core/relinker/CMakeLists.txt`, `core/relinker/cli/src/CliArgs.cpp`, `core/relinker/cli/tests/CliArgsTests.cpp`, `core/relinker/codegen/include/codegen/x86/RequiredExtensions.hpp`, `core/relinker/codegen/tests/RequiredExtensionsTests.cpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IProgramHeaderLayoutBuilder.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/ProgramHeaderLayoutRequest.hpp`, `core/relinker/elfpatcher/include/elfpatcher/linux/LinuxElfPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/macos/MacOsMachOPatcher.hpp`, `core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp`, `core/relinker/elfpatcher/src/macos/MacOsMachOPatcher.cpp`, `core/relinker/relinker/include/relinker/guest/GuestImage.hpp`, `core/relinker/relinker/tests/test_required_extensions_record.py`, `docs/dev/debt/changes/required-extensions-record.md`, and `docs/user/USAGE.md`. The changed files read in full or relevant ranges were `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/codegen/src/x86/RequiredExtensions.cpp`, `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp`, `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp`, `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`, `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp`, and `core/relinker/relinker/src/pipeline/Conversion.cpp`. The prepared `description.md`, `commits.md`, `manifest.json`, and `diff.patch` were also read; `files.json` was not available through the reader. ## To get this to a good state Nothing is required. No optional points.

Pull request closed

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!23279
No description provided.