feat(relinker): record the host CPU features --to-avx output needs #24915

Open
momgaroganuchi-crypto wants to merge 6 commits from upstream-pr/24915 into main
momgaroganuchi-crypto commented 2026-11-21 10:40:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by momgaroganuchi-crypto on 2026-11-21T10:40:23Z.


What

--to-avx lowers BMI1, BMI2, LZCNT and MOVBE for hosts with AVX but without AVX2, but only --macos output could start there: CheckHostCpu in libkernel required LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA and F16C unconditionally and did not know what the conversion removed.

The relinker now records what the output still needs:

  • HostCpuFeatureClassifier maps one decoded instruction to LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEOPT, XSAVEC, XSAVES, SSE4A, CLZERO, RDTSCP, FSGSBASE, AVX-VNNI, AVX-IFMA, AVX-VNNI-INT8 or AVX-NE-CONVERT, including the legacy encodings of the last sixteen and the VEX encodings of the AVX-VNNI, AVX-IFMA, AVX-VNNI-INT8 and AVX-NE-CONVERT families. A 256-bit VEX opcode outside the AVX1 list counts as AVX2, a 128-bit VEX opcode counts as AVX2 only for the listed AVX2-only forms, and FMA and F16C are matched before the width rule. The classification is deliberately conservative: data decoded as code can only require more. VEX.128 VPACKUSDW and the 256-bit VCVTDQ2PD, VCVTPD2DQ and VCVTTPD2DQ are AVX1, while only VEX.256 VPACKUSDW is AVX2. Register-source VBROADCASTSS/VBROADCASTSD are AVX2 while their memory forms are AVX1; the other 0F38/66 AVX1 opcodes (VPERMILPS, VPERMILPD, VTESTPS, VTESTPD, VPTEST, 0x0C-0x0F and 0x17) stay AVX1 in both forms. Legacy encodings, including TZCNT, LZCNT, MOVBE and the retained-extension forms, are recorded only after the full encoding passes X64InstructionDecoder; register and memory forms are distinguished so a fence is not mistaken for XSAVEOPT or CLWB.

  • Amd64OnlyConverter classifies every scanned instruction and unions the extensions of the instructions that no lowering replaced, in the executable and in every bundled module converted in the same run. GuestModuleBuilder returns that union.

  • Linux writes a 16-byte PT_OS_HOSTCPU program header pointing into the extra block; Windows writes a .hostcpu section next to .procpar. Both contain the magic APS5HCP1 and an eight-byte mask.

  • libc reads the record. libkernel requires the baseline (SSE through SSE4.2, POPCNT, CMPXCHG16B, LAHF/SAHF and AVX) plus the recorded bits, and keeps the existing all-extensions check when no record is present. The error names the missing recorded extensions. The runtime reads CPUID leaf 7 subleaf 1 for AVX-VNNI (EAX bit 4), AVX-IFMA (EAX bit 23), AVX-VNNI-INT8 (EDX bit 4) and AVX-NE-CONVERT (EDX bit 5), and leaf 80000001 EDX for RDTSCP.

  • --to-avx no longer requires --macos, and the CLI and user documentation describe the record. macOS output is unchanged: CheckHostCpu is not compiled there and no record is written.

The record is written only for --to-avx; other output keeps the old behavior. It is a union rather than per-module records, so a module loaded later from a separate conversion does not add bits. Implements the proposal in #22530. It overlaps the older #23279, which implements the same proposal; the two should be coordinated, not merged both.

Tested

Windows 11 26200, WinLibs GCC 16.2.0, AMD Ryzen AI 9 HX PRO 375 (Radeon 890M), build-full, based on main f5b7e1d1ac after rebasing:

  • host_cpu, host_cpu_feature_classifier, amd64_only_windows, cli_args and amd64_only_converter pass. host_cpu_record hit a local Windows PermissionError reading the converted file, so CI must reconfirm it.

  • iced-x86 1.22 sweep of every valid VEX.L=1 encoding finds no instruction that this classifier records as AVX1 while iced reports AVX2.

  • New end-to-end host_cpu_record: converts a fixture with a kept FMA and a lowered VPADDD ymm to Linux and Windows with --to-avx. Both records contain the magic and exactly the FMA and RDSEED bits; a plain conversion contains no record, and the Linux header points into a PT_LOAD.

  • New unit tests cover every classifier family and retained-extension encoding, the converter union and the subtraction of lowered instructions, and CheckHostCpu with an empty record, a partial record, each new bit and a baseline failure.

  • python tools/debt_fold.py --check and python tools/check_conventions.py --base origin/main pass. python tools/pr_overlap.py --branch feat/relinker-to-avx-host-cpu finds no open PR implementing these functions; it reports file-level overlap with older relinker PRs (#11525, #12678, #15245, #19569, #10861) that touch the same conversion files for unrelated reasons.

  • Not tested on a Sandy Bridge or Ivy Bridge host: no such hardware was available. The record was validated as bytes in the output and through the unit tests, not by starting a title on a CPU without AVX2. No decrypted title binary was available here, so the record was not produced from a retail title; the fixture covers FMA, AVX2 and RDSEED.

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: #22530

  • Unblocks: none

  • GPUs tested: n/a

  • AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5426969522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915). Originally posted by [momgaroganuchi-crypto](https://github.com/momgaroganuchi-crypto) on 2026-11-21T10:40:23Z. --- ### What `--to-avx` lowers BMI1, BMI2, LZCNT and MOVBE for hosts with AVX but without AVX2, but only `--macos` output could start there: `CheckHostCpu` in libkernel required LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA and F16C unconditionally and did not know what the conversion removed. The relinker now records what the output still needs: - `HostCpuFeatureClassifier` maps one decoded instruction to LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEOPT, XSAVEC, XSAVES, SSE4A, CLZERO, RDTSCP, FSGSBASE, AVX-VNNI, AVX-IFMA, AVX-VNNI-INT8 or AVX-NE-CONVERT, including the legacy encodings of the last sixteen and the VEX encodings of the AVX-VNNI, AVX-IFMA, AVX-VNNI-INT8 and AVX-NE-CONVERT families. A 256-bit VEX opcode outside the AVX1 list counts as AVX2, a 128-bit VEX opcode counts as AVX2 only for the listed AVX2-only forms, and FMA and F16C are matched before the width rule. The classification is deliberately conservative: data decoded as code can only require more. VEX.128 `VPACKUSDW` and the 256-bit `VCVTDQ2PD`, `VCVTPD2DQ` and `VCVTTPD2DQ` are AVX1, while only VEX.256 `VPACKUSDW` is AVX2. Register-source `VBROADCASTSS`/`VBROADCASTSD` are AVX2 while their memory forms are AVX1; the other 0F38/66 AVX1 opcodes (`VPERMILPS`, `VPERMILPD`, `VTESTPS`, `VTESTPD`, `VPTEST`, `0x0C`-`0x0F` and `0x17`) stay AVX1 in both forms. Legacy encodings, including TZCNT, LZCNT, MOVBE and the retained-extension forms, are recorded only after the full encoding passes `X64InstructionDecoder`; register and memory forms are distinguished so a fence is not mistaken for XSAVEOPT or CLWB. - `Amd64OnlyConverter` classifies every scanned instruction and unions the extensions of the instructions that no lowering replaced, in the executable and in every bundled module converted in the same run. `GuestModuleBuilder` returns that union. - Linux writes a 16-byte `PT_OS_HOSTCPU` program header pointing into the extra block; Windows writes a `.hostcpu` section next to `.procpar`. Both contain the magic `APS5HCP1` and an eight-byte mask. - libc reads the record. libkernel requires the baseline (SSE through SSE4.2, POPCNT, CMPXCHG16B, LAHF/SAHF and AVX) plus the recorded bits, and keeps the existing all-extensions check when no record is present. The error names the missing recorded extensions. The runtime reads CPUID leaf 7 subleaf 1 for AVX-VNNI (EAX bit 4), AVX-IFMA (EAX bit 23), AVX-VNNI-INT8 (EDX bit 4) and AVX-NE-CONVERT (EDX bit 5), and leaf 80000001 EDX for RDTSCP. - `--to-avx` no longer requires `--macos`, and the CLI and user documentation describe the record. macOS output is unchanged: `CheckHostCpu` is not compiled there and no record is written. The record is written only for `--to-avx`; other output keeps the old behavior. It is a union rather than per-module records, so a module loaded later from a separate conversion does not add bits. Implements the proposal in #22530. It overlaps the older #23279, which implements the same proposal; the two should be coordinated, not merged both. ### Tested Windows 11 26200, WinLibs GCC 16.2.0, AMD Ryzen AI 9 HX PRO 375 (Radeon 890M), `build-full`, based on `main` `f5b7e1d1ac` after rebasing: - `host_cpu`, `host_cpu_feature_classifier`, `amd64_only_windows`, `cli_args` and `amd64_only_converter` pass. `host_cpu_record` hit a local Windows `PermissionError` reading the converted file, so CI must reconfirm it. - `iced-x86` 1.22 sweep of every valid VEX.L=1 encoding finds no instruction that this classifier records as AVX1 while iced reports AVX2. - New end-to-end `host_cpu_record`: converts a fixture with a kept FMA and a lowered `VPADDD ymm` to Linux and Windows with `--to-avx`. Both records contain the magic and exactly the FMA and RDSEED bits; a plain conversion contains no record, and the Linux header points into a `PT_LOAD`. - New unit tests cover every classifier family and retained-extension encoding, the converter union and the subtraction of lowered instructions, and `CheckHostCpu` with an empty record, a partial record, each new bit and a baseline failure. - `python tools/debt_fold.py --check` and `python tools/check_conventions.py --base origin/main` pass. `python tools/pr_overlap.py --branch feat/relinker-to-avx-host-cpu` finds no open PR implementing these functions; it reports file-level overlap with older relinker PRs (#11525, #12678, #15245, #19569, #10861) that touch the same conversion files for unrelated reasons. - Not tested on a Sandy Bridge or Ivy Bridge host: no such hardware was available. The record was validated as bytes in the output and through the unit tests, not by starting a title on a CPU without AVX2. No decrypted title binary was available here, so the record was not produced from a retail title; the fixture covers FMA, AVX2 and RDSEED. ### 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: #22530 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-21 11:10:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:10:57Z.

Review: COMMENTED


Reviewed — comments

The review found a concrete host CPU feature classification gap that can let an AVX2 instruction run on a host without AVX2.

What I ran

Reviewed head 28ac60476a5f150bd0a2bdc9db8f15f455505fa4. I read the prepared description, commits, diff and manifest, and targeted classifier source. I did not run commands or tests.

Results

Check Result Note
Diff and targeted source review passed Classifier gap found
Tests not run No execution environment used

Findings

Blocking

None verified.

Non-blocking

  • The 128-bit AVX2-only opcode list omits AVX2 integer VPACKUSDW (VEX.128.66.0F38.WIG 2B /r). The classifier returns no AVX2 bit for this instruction, so a retained occurrence can be absent from the record and pass the start-up check on a host without AVX2. Add the opcode to isAvx2Vector128 and cover it with a classifier test. Evidence: core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:78.

Not verified

I read all changed files listed in the manifest as included, including classifier, conversion and test changes. No changed files were excluded. Tests and builds were not run; the author-reported CI and hardware results were not independently verified. I did not inspect unrelated repository context.

To get this to a good state

Nothing is required. The classifier coverage point above is optional feedback.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004817641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6004817641). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T11:10:57Z. **Review:** COMMENTED --- # Reviewed — comments The review found a concrete host CPU feature classification gap that can let an AVX2 instruction run on a host without AVX2. ## What I ran Reviewed head `28ac60476a5f150bd0a2bdc9db8f15f455505fa4`. I read the prepared description, commits, diff and manifest, and targeted classifier source. I did not run commands or tests. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Classifier gap found | | Tests | not run | No execution environment used | ## Findings ### Blocking None verified. ### Non-blocking - The 128-bit AVX2-only opcode list omits AVX2 integer `VPACKUSDW` (`VEX.128.66.0F38.WIG 2B /r`). The classifier returns no AVX2 bit for this instruction, so a retained occurrence can be absent from the record and pass the start-up check on a host without AVX2. Add the opcode to `isAvx2Vector128` and cover it with a classifier test. Evidence: `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:78`. ## Not verified I read all changed files listed in the manifest as included, including classifier, conversion and test changes. No changed files were excluded. Tests and builds were not run; the author-reported CI and hardware results were not independently verified. I did not inspect unrelated repository context. ## To get this to a good state Nothing is required. The classifier coverage point above is optional feedback.
PrivacyOnion commented 2026-11-21 11:22:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T11:22:27Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 28ac60476a:

  • Conventions: tools/check_conventions.py passed.
  • Build: amd64_only_converter_tests, cli_args_tests, host_cpu_feature_classifier_tests, host_cpu_tests built cleanly.
  • CTest (host_cpu, host_cpu_feature_classifier, cli_args, amd64_only_converter):
    1/4 Test #5935: host_cpu .........................   Passed    0.03 sec
    2/4 Test #6258: host_cpu_feature_classifier ......   Passed    0.01 sec
    3/4 Test #6274: cli_args .........................   Passed    0.02 sec
    4/4 Test #6288: amd64_only_converter .............   Passed    0.08 sec
    100% tests passed, 0 tests failed out of 4
    
  • Negative control: with core/libs/prx/libc/include/ApplicationHeap.hpp, core/libs/prx/libc/src/ApplicationProcessParameters.cpp, core/libs/prx/libkernel/System/include/HostCpu.hpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/cli/src/CliArgs.cpp, core/relinker/codegen/include/codegen/CodegenTypes.hpp, core/relinker/codegen/src/Amd64OnlyConverter.cpp, core/relinker/elfpatcher/include/elfpatcher/general/ElfConstants.hpp, core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.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/HostCpuFeatureClassifier.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified core/libs/prx/libc/src/ApplicationProcessParameters.cpp ApplicationHostCpuFeatures_nid_no_patch against buffer boundaries and dl_iterate_phdr mapping checks on Linux/Windows
    • Checked core/libs/prx/libkernel/System/src/HostCpu.cpp HostCpuFeatures and CheckHostCpu logic with and without recorded features
    • Analyzed core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp instruction classification rules (VEX map/prefix matching, 256-bit AVX1 vs AVX2 opcodes, FMA, F16C, BMI1/2, MOVBE, LZCNT)
    • Inspected core/relinker/codegen/src/Amd64OnlyConverter.cpp integration to ensure lowered instructions are excluded from RequiredHostCpuFeatures
    • Verified core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp and LinuxElfPatcher.cpp PT_OS_HOSTCPU segment creation and slot bounds

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004868034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6004868034). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T11:22:27Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `28ac60476a`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `amd64_only_converter_tests`, `cli_args_tests`, `host_cpu_feature_classifier_tests`, `host_cpu_tests` built cleanly. - **CTest** (`host_cpu`, `host_cpu_feature_classifier`, `cli_args`, `amd64_only_converter`): ``` 1/4 Test #5935: host_cpu ......................... Passed 0.03 sec 2/4 Test #6258: host_cpu_feature_classifier ...... Passed 0.01 sec 3/4 Test #6274: cli_args ......................... Passed 0.02 sec 4/4 Test #6288: amd64_only_converter ............. Passed 0.08 sec 100% tests passed, 0 tests failed out of 4 ``` - **Negative control**: with `core/libs/prx/libc/include/ApplicationHeap.hpp`, `core/libs/prx/libc/src/ApplicationProcessParameters.cpp`, `core/libs/prx/libkernel/System/include/HostCpu.hpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/cli/src/CliArgs.cpp`, `core/relinker/codegen/include/codegen/CodegenTypes.hpp`, `core/relinker/codegen/src/Amd64OnlyConverter.cpp`, `core/relinker/elfpatcher/include/elfpatcher/general/ElfConstants.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.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/HostCpuFeatureClassifier.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified core/libs/prx/libc/src/ApplicationProcessParameters.cpp ApplicationHostCpuFeatures_nid_no_patch against buffer boundaries and dl_iterate_phdr mapping checks on Linux/Windows - Checked core/libs/prx/libkernel/System/src/HostCpu.cpp HostCpuFeatures and CheckHostCpu logic with and without recorded features - Analyzed core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp instruction classification rules (VEX map/prefix matching, 256-bit AVX1 vs AVX2 opcodes, FMA, F16C, BMI1/2, MOVBE, LZCNT) - Inspected core/relinker/codegen/src/Amd64OnlyConverter.cpp integration to ensure lowered instructions are excluded from RequiredHostCpuFeatures - Verified core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp and LinuxElfPatcher.cpp PT_OS_HOSTCPU segment creation and slot bounds Looks Good To Me
PrivacyOnion commented 2026-11-21 17:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T17:29:44Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: amd64_only_converter_tests, cli_args_tests, host_cpu_feature_classifier_tests, host_cpu_tests built cleanly.
  • CTest (host_cpu, host_cpu_feature_classifier, cli_args, amd64_only_converter):
    1/4 Test #5963: host_cpu .........................   Passed    0.03 sec
    2/4 Test #6304: cli_args .........................   Passed    0.02 sec
    3/4 Test #6288: host_cpu_feature_classifier ......   Passed    0.01 sec
    4/4 Test #6318: amd64_only_converter .............   Passed    0.09 sec
    100% tests passed, 0 tests failed out of 4
    
  • Negative control: with core/libs/prx/libc/include/ApplicationHeap.hpp, core/libs/prx/libc/src/ApplicationProcessParameters.cpp, core/libs/prx/libkernel/System/include/HostCpu.hpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/cli/src/CliArgs.cpp, core/relinker/codegen/include/codegen/CodegenTypes.hpp, core/relinker/codegen/src/Amd64OnlyConverter.cpp, core/relinker/elfpatcher/include/elfpatcher/general/ElfConstants.hpp, core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.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/HostCpuFeatureClassifier.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified ApplicationHostCpuFeatures_nid_no_patch dl_iterate_phdr parsing on Linux/Apple: validates p_type == 0x61000002, checks segment mapping within PT_LOAD boundaries, checks RecordSize (16 bytes), verifies magic APS5HCP1, and ensures reserved bits (~All) are zero.
    • Verified Windows PE implementation in ApplicationProcessParameters.cpp: searches section headers for .hostcpu, validates VirtualSize == 16, boundary against imageSize, magic match, and non-duplicate section logic.
    • Verified HostCpuFeatures and CheckHostCpu handling in libkernel HostCpu.cpp: correctly masks required status against recorded bits for Lzcnt, Bmi1, Bmi2, Movbe, Avx2, Fma, and F16c, and keeps baseline requirements intact when no record is present.
    • Verified HostCpuFeatureClassifier.cpp instruction decoding and classifications for VEX 256-bit AVX1 vs AVX2, VEX 128-bit AVX2 forms (including VPACKUSDW), FMA, F16C, BMI1/2, MOVBE, and LZCNT legacy prefix / opcode rules.
    • Verified Amd64OnlyConverter.cpp pipeline integration: matches are correctly classified, and instructions lowered via substitution, trampoline, or stub bodies are inserted into lowered set and excluded from RequiredHostCpuFeatures.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6006969130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6006969130). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T17:29:44Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e88c95e016`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `amd64_only_converter_tests`, `cli_args_tests`, `host_cpu_feature_classifier_tests`, `host_cpu_tests` built cleanly. - **CTest** (`host_cpu`, `host_cpu_feature_classifier`, `cli_args`, `amd64_only_converter`): ``` 1/4 Test #5963: host_cpu ......................... Passed 0.03 sec 2/4 Test #6304: cli_args ......................... Passed 0.02 sec 3/4 Test #6288: host_cpu_feature_classifier ...... Passed 0.01 sec 4/4 Test #6318: amd64_only_converter ............. Passed 0.09 sec 100% tests passed, 0 tests failed out of 4 ``` - **Negative control**: with `core/libs/prx/libc/include/ApplicationHeap.hpp`, `core/libs/prx/libc/src/ApplicationProcessParameters.cpp`, `core/libs/prx/libkernel/System/include/HostCpu.hpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/cli/src/CliArgs.cpp`, `core/relinker/codegen/include/codegen/CodegenTypes.hpp`, `core/relinker/codegen/src/Amd64OnlyConverter.cpp`, `core/relinker/elfpatcher/include/elfpatcher/general/ElfConstants.hpp`, `core/relinker/elfpatcher/include/elfpatcher/general/IElfPatcher.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/HostCpuFeatureClassifier.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified ApplicationHostCpuFeatures_nid_no_patch dl_iterate_phdr parsing on Linux/Apple: validates p_type == 0x61000002, checks segment mapping within PT_LOAD boundaries, checks RecordSize (16 bytes), verifies magic APS5HCP1, and ensures reserved bits (~All) are zero. - Verified Windows PE implementation in ApplicationProcessParameters.cpp: searches section headers for .hostcpu, validates VirtualSize == 16, boundary against imageSize, magic match, and non-duplicate section logic. - Verified HostCpuFeatures and CheckHostCpu handling in libkernel HostCpu.cpp: correctly masks required status against recorded bits for Lzcnt, Bmi1, Bmi2, Movbe, Avx2, Fma, and F16c, and keeps baseline requirements intact when no record is present. - Verified HostCpuFeatureClassifier.cpp instruction decoding and classifications for VEX 256-bit AVX1 vs AVX2, VEX 128-bit AVX2 forms (including VPACKUSDW), FMA, F16C, BMI1/2, MOVBE, and LZCNT legacy prefix / opcode rules. - Verified Amd64OnlyConverter.cpp pipeline integration: matches are correctly classified, and instructions lowered via substitution, trampoline, or stub bodies are inserted into lowered set and excluded from RequiredHostCpuFeatures. Looks Good To Me
ocr1n commented 2026-11-21 19:04:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ocr1n on 2026-11-21T19:04:16Z.

Review: CHANGES_REQUESTED


On e88c95e016, --to-avx marks four instructions emitted by GCC for Sandy Bridge as requiring AVX2. That makes the startup check reject a supported CPU in exactly the use case in #22530. I put the correction and regression tests in a single commit on top of this PR. Apply or inspect the patch.

I converted the register and memory forms of each instruction separately. All eight fixtures produced an AVX2 mask of 0x10 in both ELF and PE. With the patch, all eight produce 0. A retained AVX2 gather, FMA and BMI2 instruction still produce 0x10, 0x20 and 0x04, respectively.

GCC 13.3 with -O2 -march=sandybridge emitted all four register forms. I checked their arithmetic under QEMU 8.2.2 with -cpu SandyBridge (CPUID reports AVX=1, AVX2=0). I also copied the generated ELF records into a Linux harness linked with this PR’s HostCpu.cpp and ApplicationProcessParameters.cpp. The original records produced “lacks AVX2” for all four. With the corrected records the harness ran to completion, and startup still rejected each of the three unsupported-instruction controls.

Both new regression expectations failed on this PR head. With the patch, all 1,061 relinker-only CTests passed on Ubuntu 24.04 under WSL2, along with the conventions check. Windows coverage was inspection of the generated PE records. No game title or physical Sandy Bridge machine was used.

AI-assisted: yes (OpenAI Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6007518381 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6007518381). Originally posted by [ocr1n](https://github.com/ocr1n) on 2026-11-21T19:04:16Z. **Review:** CHANGES_REQUESTED --- On `e88c95e016`, `--to-avx` marks four instructions emitted by GCC for Sandy Bridge as requiring AVX2. That makes the startup check reject a supported CPU in exactly the use case in #22530. I put the correction and regression tests in a single commit on top of this PR. [Apply or inspect the patch](https://github.com/ocr1n/AnyPS5/commit/1de897e05077444190af12cd17fd860f3f9d45d8). I converted the register and memory forms of each instruction separately. All eight fixtures produced an AVX2 mask of `0x10` in both ELF and PE. With the patch, all eight produce `0`. A retained AVX2 gather, FMA and BMI2 instruction still produce `0x10`, `0x20` and `0x04`, respectively. GCC 13.3 with `-O2 -march=sandybridge` emitted all four register forms. I checked their arithmetic under QEMU 8.2.2 with `-cpu SandyBridge` (CPUID reports AVX=1, AVX2=0). I also copied the generated ELF records into a Linux harness linked with this PR’s `HostCpu.cpp` and `ApplicationProcessParameters.cpp`. The original records produced “lacks AVX2” for all four. With the corrected records the harness ran to completion, and startup still rejected each of the three unsupported-instruction controls. Both new regression expectations failed on this PR head. With the patch, all 1,061 relinker-only CTests passed on Ubuntu 24.04 under WSL2, along with the conventions check. Windows coverage was inspection of the generated PE records. No game title or physical Sandy Bridge machine was used. AI-assisted: yes (OpenAI Codex).
MarcZX10 commented 2026-11-22 04:15:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T04:15:41Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent the classifier from treating invalid or incomplete instruction encodings as evidence that the host CPU feature is required.

What I ran

  • Inspected the prepared diff for head e88c95e01607d3a8f2ddb67e175a76f23407cd5b and targeted repository source using repo_read.py.
  • No build or tests were run during this review.

Results

Check Result Note
Source review failed Verified classifier defect
Build and tests not run No commands executed

Findings

Blocking

  • core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:154 and core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:156: the legacy fallback classifies TZCNT/LZCNT from F3 0F BC/BD and MOVBE from 0F 38 F0/F1 without validating the remaining encoding. Since each scanned instruction is passed with its decoded length, a truncated encoding can be labeled as requiring one of these features. The converter then unions those bits into the output record, and libkernel rejects hosts lacking the recorded feature even if the instruction is not valid code and would not execute. Validate the full instruction encoding before recording a requirement, or make this fallback conservative for incomplete or invalid encodings.

Non-blocking

None.

Not verified

  • No tests or build were run. The PR description reports test results, but they were not independently reproduced.
  • The changed source files read were core/libs/prx/libc/src/ApplicationProcessParameters.cpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp, core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, and core/relinker/codegen/include/codegen/x86/VexEncoding.hpp. The prepared diff was inspected; other changed files were not read from their full head contents.
  • Excluded files were not reviewed; the files.json listing was unavailable through the reader.

To get this to a good state

Validate legacy instruction encodings before including their feature bits in the record, then add or update focused classifier tests and rerun the relevant checks on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010275350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6010275350). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T04:15:41Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent the classifier from treating invalid or incomplete instruction encodings as evidence that the host CPU feature is required. ## What I ran - Inspected the prepared diff for head `e88c95e01607d3a8f2ddb67e175a76f23407cd5b` and targeted repository source using `repo_read.py`. - No build or tests were run during this review. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Verified classifier defect | | Build and tests | not run | No commands executed | ## Findings ### Blocking - `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:154` and `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:156`: the legacy fallback classifies TZCNT/LZCNT from `F3 0F BC/BD` and MOVBE from `0F 38 F0/F1` without validating the remaining encoding. Since each scanned instruction is passed with its decoded length, a truncated encoding can be labeled as requiring one of these features. The converter then unions those bits into the output record, and libkernel rejects hosts lacking the recorded feature even if the instruction is not valid code and would not execute. Validate the full instruction encoding before recording a requirement, or make this fallback conservative for incomplete or invalid encodings. ### Non-blocking None. ## Not verified - No tests or build were run. The PR description reports test results, but they were not independently reproduced. - The changed source files read were `core/libs/prx/libc/src/ApplicationProcessParameters.cpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp`, `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp`, `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`, and `core/relinker/codegen/include/codegen/x86/VexEncoding.hpp`. The prepared diff was inspected; other changed files were not read from their full head contents. - Excluded files were not reviewed; the `files.json` listing was unavailable through the reader. ## To get this to a good state Validate legacy instruction encodings before including their feature bits in the record, then add or update focused classifier tests and rerun the relevant checks on the new head.
MarcZX10 commented 2026-11-22 13:33:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:33:55Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: correct AVX1/AVX2 classification so the host CPU record does not miss retained instructions that require AVX2.

What I ran

Reviewed head 58eb599f2fe4c40f4a605d30b5a9becc38b0ff9f from the prepared diff and repository files read through repo_read.py. No commands or tests were run in this review; the test results in the PR description are author-reported.

Results

Check Result Note
Diff and targeted source review passed Reviewed the classifier, conversion flow, record parsing and output layout.
Tests in this review not run No tests were run.
Author-reported tests not run Description reports 12/12 selected tests passed.

Findings

Blocking

  • core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:16: The AVX1 allowlist treats all VEX.256 forms of several opcode ranges as AVX1 without accounting for mandatory prefix. For example, VEX.256 VPINSRW (VEX.66.0F C4) is AVX2, but opcode C4 matches the Prefix66 range at lines 24–30 and is classified as AVX1. If this instruction survives lowering, the record omits AVX2 and libkernel can allow startup on a host that cannot execute it. Restrict the allowlist entries to the exact opcode/prefix combinations defined by AVX, and add classifier cases for VEX.256 instructions that require AVX2.

Non-blocking

None.

Not verified

  • No tests or build commands were run. The PR description reports Windows 11 tests and byte-level record checks; those were not independently run here.
  • Sandy Bridge/Ivy Bridge startup behavior and behavior on a physical console were not verified.
  • Read the prepared description, commits, manifest and diff, plus targeted ranges of ApplicationProcessParameters.cpp, HostCpuFeatureClassifier.cpp, WindowsPePatcher.cpp, HostCpu.cpp, Conversion.cpp, LinuxElfPatcher.cpp, and ProgramHeaderLayoutBuilder.cpp. All 27 files listed as reviewed in the manifest were included in the bundle, but the full text of every changed file was not read. files.json exclusions were not inspected.

To get this to a good state

Correct the AVX1 opcode/prefix allowlist and add a regression test for a retained AVX2-only VEX.256 form such as VPINSRW; rerun the classifier and conversion tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012509324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6012509324). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T13:33:55Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: correct AVX1/AVX2 classification so the host CPU record does not miss retained instructions that require AVX2. ## What I ran Reviewed head `58eb599f2fe4c40f4a605d30b5a9becc38b0ff9f` from the prepared diff and repository files read through `repo_read.py`. No commands or tests were run in this review; the test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Reviewed the classifier, conversion flow, record parsing and output layout. | | Tests in this review | not run | No tests were run. | | Author-reported tests | not run | Description reports 12/12 selected tests passed. | ## Findings ### Blocking - `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:16`: The AVX1 allowlist treats all VEX.256 forms of several opcode ranges as AVX1 without accounting for mandatory prefix. For example, VEX.256 `VPINSRW` (`VEX.66.0F C4`) is AVX2, but opcode `C4` matches the `Prefix66` range at lines 24–30 and is classified as AVX1. If this instruction survives lowering, the record omits AVX2 and libkernel can allow startup on a host that cannot execute it. Restrict the allowlist entries to the exact opcode/prefix combinations defined by AVX, and add classifier cases for VEX.256 instructions that require AVX2. ### Non-blocking None. ## Not verified - No tests or build commands were run. The PR description reports Windows 11 tests and byte-level record checks; those were not independently run here. - Sandy Bridge/Ivy Bridge startup behavior and behavior on a physical console were not verified. - Read the prepared description, commits, manifest and diff, plus targeted ranges of `ApplicationProcessParameters.cpp`, `HostCpuFeatureClassifier.cpp`, `WindowsPePatcher.cpp`, `HostCpu.cpp`, `Conversion.cpp`, `LinuxElfPatcher.cpp`, and `ProgramHeaderLayoutBuilder.cpp`. All 27 files listed as `reviewed` in the manifest were included in the bundle, but the full text of every changed file was not read. `files.json` exclusions were not inspected. ## To get this to a good state Correct the AVX1 opcode/prefix allowlist and add a regression test for a retained AVX2-only VEX.256 form such as `VPINSRW`; rerun the classifier and conversion tests on the updated head.
MarcZX10 commented 2026-11-22 14:22:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T14:22:24Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes show no verified blocking defect; the full changed-file review and programmatic checks were not completed.

What I ran

  • Reviewed prepared diff and targeted source at head 096b707771c9491170a619bf6bc082e946383ae6 using repo_read.py.
  • No tests or build checks were run.

Results

Check Result Note
Targeted source review passed No blocker verified in inspected code
Tests and build not run Author-reported results were not independently run
Full changed-file review not run Several changed files were not read

Findings

Blocking

None verified in the inspected code.

Non-blocking

  • Complete review of the classifier, output patchers, and record parsing would provide stronger confidence in the new cross-platform behavior.

Not verified

  • Read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch; targeted portions of core/libs/prx/libc/src/ApplicationProcessParameters.cpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/libs/tests/HostCpu.cpp, core/relinker/codegen/src/Amd64OnlyConverter.cpp, core/relinker/codegen/src/x86/HostCpuFeatureClassifier.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, core/relinker/relinker/src/pipeline/Conversion.cpp, and core/relinker/relinker/tests/test_hostcpu_record.py.
  • Excluded from direct reading: the remaining changed files listed in review/manifest.json; the targeted files above were not all read in full. review/files.json was unavailable through the reader.
  • Host CPU record behavior on physical hardware, supported host operating systems, and the author-reported test runs were not independently confirmed.

To get this to a good state

Nothing is required. Optional: complete review of the remaining changed files and run the relevant checks.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012713138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6012713138). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T14:22:24Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes show no verified blocking defect; the full changed-file review and programmatic checks were not completed. ## What I ran - Reviewed prepared diff and targeted source at head `096b707771c9491170a619bf6bc082e946383ae6` using `repo_read.py`. - No tests or build checks were run. ## Results | Check | Result | Note | |---|---|---| | Targeted source review | passed | No blocker verified in inspected code | | Tests and build | not run | Author-reported results were not independently run | | Full changed-file review | not run | Several changed files were not read | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking - Complete review of the classifier, output patchers, and record parsing would provide stronger confidence in the new cross-platform behavior. ## Not verified - Read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`; targeted portions of `core/libs/prx/libc/src/ApplicationProcessParameters.cpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/libs/tests/HostCpu.cpp`, `core/relinker/codegen/src/Amd64OnlyConverter.cpp`, `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.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`, `core/relinker/relinker/src/pipeline/Conversion.cpp`, and `core/relinker/relinker/tests/test_hostcpu_record.py`. - Excluded from direct reading: the remaining changed files listed in `review/manifest.json`; the targeted files above were not all read in full. `review/files.json` was unavailable through the reader. - Host CPU record behavior on physical hardware, supported host operating systems, and the author-reported test runs were not independently confirmed. ## To get this to a good state Nothing is required. Optional: complete review of the remaining changed files and run the relevant checks.
MarcZX10 commented 2026-11-23 09:26:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T09:26:29Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review found no verified defects in the inspected implementation.

What I ran

Reviewed head b903995898003f34f30164555b361d49ef16fdc7. No commands or tests were run. Read the prepared description, commit list, diff, manifest, and all changed source and test files listed as reviewed; files.json had no excluded changed files.

Results

Check Result Note
Code review passed Targeted implementation and call paths inspected
Tests not run Author-reported tests were not independently run
Runtime compatibility not run No physical console or older CPU validation

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds and tests were not run. The behavior was not validated on a Sandy Bridge or Ivy Bridge host, on a physical console, or by starting a title that uses the emitted metadata. These limits also apply to the end-to-end fixture test, whose author-reported Windows run encountered a local file permission error. The changed files were read; no changed files were excluded by rule.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6019169770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6019169770). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T09:26:29Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review found no verified defects in the inspected implementation. ## What I ran Reviewed head `b903995898003f34f30164555b361d49ef16fdc7`. No commands or tests were run. Read the prepared description, commit list, diff, manifest, and all changed source and test files listed as reviewed; `files.json` had no excluded changed files. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Targeted implementation and call paths inspected | | Tests | not run | Author-reported tests were not independently run | | Runtime compatibility | not run | No physical console or older CPU validation | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Builds and tests were not run. The behavior was not validated on a Sandy Bridge or Ivy Bridge host, on a physical console, or by starting a title that uses the emitted metadata. These limits also apply to the end-to-end fixture test, whose author-reported Windows run encountered a local file permission error. The changed files were read; no changed files were excluded by rule. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-25 04:24:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T04:24:50Z.

Review: DISMISSED


Reviewed — comments

The new record captures several retained CPU extensions, but it does not capture every extension the converter may leave in the output, so this review cannot recommend approval.

What I ran

Reviewed head 422d7b67ae70f4fbea8f1eddf361f34f85fe92ad against the prepared diff and targeted source files using repo_read.py. No commands or tests were run; the reader-only session does not provide command execution.

Results

Check Result Note
Prepared diff and targeted source review passed Core data flow inspected
Test execution not run No command execution available
Physical CPU compatibility not run No Sandy or Ivy Bridge host

Findings

Blocking

  • The record only tracks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA and F16C. However, --to-avx can leave unsupported AMD-only instructions in the output, and the classifier returns zero for unknown VEX forms and legacy extensions outside those bits. For example, the matcher recognizes RDSEED (core/relinker/codegen/include/codegen/x86/Amd64OnlySubstitutionTable.hpp:41), while the classifier’s feature mapping ends at its known families and otherwise returns zero (core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:127-134). The runtime therefore may accept a host without an extension required by a retained instruction, leading to an illegal instruction after startup. Track these retained requirements or reject output that cannot be represented by the record. Changed lines: core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:127-134.

Non-blocking

None.

Not verified

  • Tests reported in the PR description were not independently run.
  • Physical-console and older-CPU behavior was not tested.
  • Read all 25 changed files listed in the manifest; no files were excluded by the manifest. The repository reader script itself was not inspected.

To get this to a good state

Extend the recorded feature model or reject conversions when a retained instruction’s CPU requirement cannot be represented, then rerun the relevant classifier, converter, and output-record tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6051839646 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6051839646). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T04:24:50Z. **Review:** DISMISSED --- # Reviewed — comments The new record captures several retained CPU extensions, but it does not capture every extension the converter may leave in the output, so this review cannot recommend approval. ## What I ran Reviewed head `422d7b67ae70f4fbea8f1eddf361f34f85fe92ad` against the prepared diff and targeted source files using `repo_read.py`. No commands or tests were run; the reader-only session does not provide command execution. ## Results | Check | Result | Note | |---|---|---| | Prepared diff and targeted source review | passed | Core data flow inspected | | Test execution | not run | No command execution available | | Physical CPU compatibility | not run | No Sandy or Ivy Bridge host | ## Findings ### Blocking - The record only tracks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA and F16C. However, `--to-avx` can leave unsupported AMD-only instructions in the output, and the classifier returns zero for unknown VEX forms and legacy extensions outside those bits. For example, the matcher recognizes RDSEED (`core/relinker/codegen/include/codegen/x86/Amd64OnlySubstitutionTable.hpp:41`), while the classifier’s feature mapping ends at its known families and otherwise returns zero (`core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:127-134`). The runtime therefore may accept a host without an extension required by a retained instruction, leading to an illegal instruction after startup. Track these retained requirements or reject output that cannot be represented by the record. Changed lines: `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:127-134`. ### Non-blocking None. ## Not verified - Tests reported in the PR description were not independently run. - Physical-console and older-CPU behavior was not tested. - Read all 25 changed files listed in the manifest; no files were excluded by the manifest. The repository reader script itself was not inspected. ## To get this to a good state Extend the recorded feature model or reject conversions when a retained instruction’s CPU requirement cannot be represented, then rerun the relevant classifier, converter, and output-record tests on the updated head.
MarcZX10 commented 2026-11-25 16:22:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T16:22:39Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change based on the implementation paths inspected; the added host CPU record appears to track retained feature requirements and preserve the baseline checks.

What I ran

  • Reviewed head e8dfc190212dfcb88ae819904930ad02fb3a18f3 against base main using the prepared diff and repo_read.py.
  • No commands or tests were run by me. The test and CI results in the PR description are author-reported.

Results

Check Result Note
Changed-code review passed Inspected classifier, feature checks, conversion aggregation, and patcher paths
Automated tests not run PR description reports tests; not independently verified
Physical CPU behavior not run No test on a host without AVX2

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

I did not read every file listed as reviewed in the manifest, so this is not a complete file-by-file approval. In particular, I did not inspect all tests, CLI and documentation changes, or all patcher and layout code. The changed-file summary in the manifest shows 22 files, all marked included; the final portion identifies docs/user/USAGE.md and the new debt note. files.json was not available through the reader. CI results and the PR's reported hardware validation remain unverified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6061079417 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6061079417). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T16:22:39Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change based on the implementation paths inspected; the added host CPU record appears to track retained feature requirements and preserve the baseline checks. ## What I ran - Reviewed head `e8dfc190212dfcb88ae819904930ad02fb3a18f3` against base `main` using the prepared diff and `repo_read.py`. - No commands or tests were run by me. The test and CI results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed-code review | passed | Inspected classifier, feature checks, conversion aggregation, and patcher paths | | Automated tests | not run | PR description reports tests; not independently verified | | Physical CPU behavior | not run | No test on a host without AVX2 | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified I did not read every file listed as reviewed in the manifest, so this is not a complete file-by-file approval. In particular, I did not inspect all tests, CLI and documentation changes, or all patcher and layout code. The changed-file summary in the manifest shows 22 files, all marked included; the final portion identifies `docs/user/USAGE.md` and the new debt note. `files.json` was not available through the reader. CI results and the PR's reported hardware validation remain unverified. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-25 17:49:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T17:49:14Z.

Review: COMMENTED


Reviewed — no blocking findings

The supplied change metadata and diff were not accessible through the available tools, so I could not verify the change or justify a formal decision.

What I ran

No repository commands were run. The required reader invocation and review-folder files were unavailable.

Results

Check Result Note
Change review not run Review inputs unavailable
Tests not run No commands run

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The PR description, commits, diff, manifest, changed files, and repository context were not read. Files read: none. Files listed as reviewed: not available to compare.

To get this to a good state

Provide access to the prepared review folder and pinned repository reader so the change can be reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6062355940 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6062355940). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T17:49:14Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The supplied change metadata and diff were not accessible through the available tools, so I could not verify the change or justify a formal decision. ## What I ran No repository commands were run. The required reader invocation and review-folder files were unavailable. ## Results | Check | Result | Note | |---|---|---| | Change review | not run | Review inputs unavailable | | Tests | not run | No commands run | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The PR description, commits, diff, manifest, changed files, and repository context were not read. Files read: none. Files listed as reviewed: not available to compare. ## To get this to a good state Provide access to the prepared review folder and pinned repository reader so the change can be reviewed.
MarcZX10 commented 2026-11-25 18:07:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:07:58Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the missing non-VEX host-feature classifications so --to-avx records every retained extension.

What I ran

  • Reviewed head b76859268c8e0f6da43f50fdc68f09bd3d26c919; base is main.
  • No build or tests were run. The description reports selected tests and an encoding sweep; those are author-reported, not runs performed in this review.
  • Read description.md, commits.md, manifest.json, and all 1,749 lines of diff.patch. Read changed source in ApplicationProcessParameters.cpp, HostCpu.cpp, Amd64OnlyConverter.cpp, HostCpuFeatureClassifier.cpp, LinuxElfPatcher.cpp, WindowsPePatcher.cpp, and Conversion.cpp; read files.json equivalent via the review-folder listing. All changed files were included in the prepared folder. Other changed files were not read in full.

Results

Check Result Note
Source review failed One feature-classification defect
Build and tests not run No execution environment available
Description claims not run Only checked against inspected source

Findings

Blocking

  • core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:102 — The VEX classifier does not record AVX-VNNI, AVX-IFMA, or AVX-VNNI-INT8/AVX-NE-CONVERT instructions. These extensions use VEX encodings, but their opcode forms are not in the BMI/FMA/F16C/AVX2 checks and fall through to 0 for VEX.128 or AVX1 classification for selected VEX.256 forms. The converter aggregates this mask for retained instructions, and libkernel then uses it to decide which CPU features are required, so a host lacking one of these extensions can pass startup and fault when such an instruction executes. Add bits and runtime CPUID checks for these supported instruction families, or conservatively classify their encodings as requiring an existing unsupported feature that causes startup rejection.

Non-blocking

None.

Not verified

  • Did not run the relinker build, unit tests, or end-to-end conversion fixture. The author reports tests on Windows 11 and a classifier sweep; these results were not independently confirmed.
  • Did not inspect every changed file's full text or validate behavior on Linux, Windows, macOS, or physical CPUs.
  • The description's claim that all retained host extensions are recorded is not supported by the classifier paths inspected.

To get this to a good state

  • Correct the classifier/runtime handling for the missing VEX instruction families, add regression coverage, and rerun the classifier and end-to-end record tests on the updated head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6062618670 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6062618670). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T18:07:58Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the missing non-VEX host-feature classifications so `--to-avx` records every retained extension. ## What I ran - Reviewed head `b76859268c8e0f6da43f50fdc68f09bd3d26c919`; base is `main`. - No build or tests were run. The description reports selected tests and an encoding sweep; those are author-reported, not runs performed in this review. - Read `description.md`, `commits.md`, `manifest.json`, and all 1,749 lines of `diff.patch`. Read changed source in `ApplicationProcessParameters.cpp`, `HostCpu.cpp`, `Amd64OnlyConverter.cpp`, `HostCpuFeatureClassifier.cpp`, `LinuxElfPatcher.cpp`, `WindowsPePatcher.cpp`, and `Conversion.cpp`; read `files.json` equivalent via the review-folder listing. All changed files were included in the prepared folder. Other changed files were not read in full. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | One feature-classification defect | | Build and tests | not run | No execution environment available | | Description claims | not run | Only checked against inspected source | ## Findings ### Blocking - `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp:102` — The VEX classifier does not record AVX-VNNI, AVX-IFMA, or AVX-VNNI-INT8/AVX-NE-CONVERT instructions. These extensions use VEX encodings, but their opcode forms are not in the BMI/FMA/F16C/AVX2 checks and fall through to `0` for VEX.128 or AVX1 classification for selected VEX.256 forms. The converter aggregates this mask for retained instructions, and libkernel then uses it to decide which CPU features are required, so a host lacking one of these extensions can pass startup and fault when such an instruction executes. Add bits and runtime CPUID checks for these supported instruction families, or conservatively classify their encodings as requiring an existing unsupported feature that causes startup rejection. ### Non-blocking None. ## Not verified - Did not run the relinker build, unit tests, or end-to-end conversion fixture. The author reports tests on Windows 11 and a classifier sweep; these results were not independently confirmed. - Did not inspect every changed file's full text or validate behavior on Linux, Windows, macOS, or physical CPUs. - The description's claim that all retained host extensions are recorded is not supported by the classifier paths inspected. ## To get this to a good state - Correct the classifier/runtime handling for the missing VEX instruction families, add regression coverage, and rerun the classifier and end-to-end record tests on the updated head.
MarcZX10 commented 2026-11-25 20:35:22 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — no blocking findings

I did not verify a blocking defect, but the review is incomplete because several changed files were not read.

What I ran

Reviewed head 4afb5db7993a3e0611771fcf45252ff074ac8046. I ran no commands or tests. The author-reported test results in the description were not independently verified.

Results

Check Result Note
Code review not run Review incomplete
Tests not run Author-reported results only
Negative control not run Not performed

Negative control

Could not run a negative control.

Findings

Blocking

None verified in the files read.

Non-blocking

Before treating this as approval, review the remaining changed files; the review did not cover every changed file.

Not verified

Read the prepared description, commits, manifest and diff, plus the full head contents of core/libs/prx/libc/src/ApplicationProcessParameters.cpp, core/libs/prx/libkernel/System/src/HostCpu.cpp, core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp, core/relinker/codegen/src/Amd64OnlyConverter.cpp, core/relinker/codegen/src/x86/X64InstructionDecoder.cpp, core/relinker/codegen/tests/HostCpuFeatureClassifierTests.cpp, and portions of core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp, core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp, and core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp. Other changed files were not read. No files were excluded from the listing returned by the review reader. The CI results, runtime behavior on a host without AVX2, and physical-console behavior were not verified.

To get this to a good state

Nothing is required. Optional: complete review of the remaining changed files before making a formal approval decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6064602817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6064602817). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T20:35:22Z. **Review:** COMMENTED --- # Reviewed — no blocking findings I did not verify a blocking defect, but the review is incomplete because several changed files were not read. ## What I ran Reviewed head `4afb5db7993a3e0611771fcf45252ff074ac8046`. I ran no commands or tests. The author-reported test results in the description were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Code review | not run | Review incomplete | | Tests | not run | Author-reported results only | | Negative control | not run | Not performed | ## Negative control Could not run a negative control. ## Findings ### Blocking None verified in the files read. ### Non-blocking Before treating this as approval, review the remaining changed files; the review did not cover every changed file. ## Not verified Read the prepared description, commits, manifest and diff, plus the full head contents of `core/libs/prx/libc/src/ApplicationProcessParameters.cpp`, `core/libs/prx/libkernel/System/src/HostCpu.cpp`, `core/relinker/codegen/src/x86/HostCpuFeatureClassifier.cpp`, `core/relinker/codegen/src/Amd64OnlyConverter.cpp`, `core/relinker/codegen/src/x86/X64InstructionDecoder.cpp`, `core/relinker/codegen/tests/HostCpuFeatureClassifierTests.cpp`, and portions of `core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp`, `core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp`, and `core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp`. Other changed files were not read. No files were excluded from the listing returned by the review reader. The CI results, runtime behavior on a host without AVX2, and physical-console behavior were not verified. ## To get this to a good state Nothing is required. Optional: complete review of the remaining changed files before making a formal approval decision.
ligmaSec commented 2026-12-03 10:53:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T10:53:51Z.

Review: COMMENTED


Configured and built the submitted head on Linux with ANYPS5_RELINKER_ONLY=ON. The host_cpu_feature_classifier, cli_args, and amd64_only_converter CTests all passed. The test scope covered classification and relinker argument and converter behavior. It did not exercise the generated CPU requirement record through a native guest launch.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6168345590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24915#pullrequestreview-6168345590). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T10:53:51Z. **Review:** COMMENTED --- Configured and built the submitted head on Linux with `ANYPS5_RELINKER_ONLY=ON`. The `host_cpu_feature_classifier`, `cli_args`, and `amd64_only_converter` CTests all passed. The test scope covered classification and relinker argument and converter behavior. It did not exercise the generated CPU requirement record through a native guest launch. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/24915:upstream-pr/24915'
git switch 'upstream-pr/24915'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/24915'
git switch 'upstream-pr/24915'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/24915'
git switch 'upstream-pr/24915'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/24915'
git switch 'main'
git merge --squash 'upstream-pr/24915'
git switch 'main'
git merge --ff-only 'upstream-pr/24915'
git switch 'main'
git merge 'upstream-pr/24915'
git push origin 'main'
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!24915
No description provided.