Skip to content

app, docs: check required console CPU features before starting - #19

Merged
simnJS merged 1 commit into
MiamiGame:mainfrom
PrivacyOnion:app/cpu-preflight
Nov 24, 2026
Merged

simnJS merged 1 commit into
MiamiGame:mainfrom
PrivacyOnion:app/cpu-preflight

Conversation

@PrivacyOnion

@PrivacyOnion PrivacyOnion commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Check that the host CPU supports the required baseline console ISA features (SSE4.1, SSE4.2, POPCNT, AVX, AVX2, FMA, F16C, BMI1, BMI2, LZCNT, MOVBE) before xtp run --execute starts a title. If any are missing, stop early with a clear message listing them and explaining how to override the check with XTP_SKIP_CPU_CHECK=1.

Console-only instructions that xtp-loader already emulates (CLZERO, MONITORX/MWAITX, RDPRU, RDPID, CLWB, SSE4a) are excluded from the check.

Fixes: #13
Depends on: none

Area

  • apps/xtp (apps/xtp/src/preflight.rs, apps/xtp/src/run.rs, apps/xtp/src/main.rs)
  • README.md (document XTP_SKIP_CPU_CHECK=1)

Tests

  • cargo xtask pr-check passes on my machine
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on the title: no

Unit tests in apps/xtp/src/preflight.rs inject a feature probe to verify:

  • all features present produces no error;
  • missing AVX2 fails with a message naming AVX2 and XTP_SKIP_CPU_CHECK;
  • multiple missing features are all listed in order;
  • skip = true bypasses missing features;
  • features emulated by xtp-loader are not in the required list.

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:

Written from scratch for XTP using crates/xtp-loader/src/crash.rs / insn.rs and standard Rust std::arch::is_x86_feature_detected!. I did not read xcl's launcher.rs.

AI assistance: Antigravity assisted with implementation and unit tests; all changes were reviewed and verified locally with cargo xtask pr-check.

Checklist

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

@github-actions github-actions Bot added area/app apps/ area/docs docs/, Markdown size/M 100 to 399 changed lines labels Nov 24, 2026
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
7 of 9 tasks

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @PrivacyOnion, this is a clean, well-scoped implementation of #13.

  • Detection goes through is_x86_feature_detected!, which already checks OSXSAVE/XGETBV for AVX, AVX2 and FMA, so OS support for the AVX state is covered without any unsafe.
  • The excluded set matches what xtp-loader emulates today.
  • The injected-probe tests meet the issue's acceptance criteria.
  • The check has no interaction with the Series S default, and it does not conflict with #20.

Before merge (description only):

  1. Please say in the description whether an AI tool wrote any part of the change (CONTRIBUTING, Provenance). That is allowed; it just has to be stated.
  2. Issue #13 points to xcl's launcher.rs as the behaviour reference. If you read it, please say so under Provenance (rule 6: "say in the pull request what you read"). The code itself is clearly your own.
  3. Green CI (fmt, clippy, clippy-diagnostics, test, policy, conventions). The runs for this head are now approved.

Optional, happy to take these as follow-ups:
4. In the module doc, say where the list comes from (x86-64-v3 plus SSE4.x and POPCNT), and that other Zen 2 extensions are deliberately not checked (SHA, ADX, RDSEED, CLFLUSHOPT, XSAVEC, AES, PCLMULQDQ). Intel 4th to 10th gen lack SHA-NI, and there is no evidence the title uses it, so leaving SHA out is the right call for now.
5. When XTP_SKIP_CPU_CHECK is set, still probe and print the missing features in the warning; that helps triage a later illegal-instruction crash. Consider accepting any value, as XTP_SKIP_INTRO and XTP_WATCHDOG_HOOK do.
6. Mention in the error that running anyway will likely stop with an illegal instruction (see crashes.log).
7. emulated_features_are_not_required cannot fail as written. Either drop it, or tie it to a list exported by xtp-loader.
8. Nits:

  • "SSE4a (extrq/insertq)" in the doc;
  • app, docs: as the title, since the README changes;
  • the description has stray BEL characters where `apps/xtp` was (PowerShell's `a escape).

Once 1 to 3 are done, this is an approval.

@PrivacyOnion PrivacyOnion changed the title app: check required console CPU features before starting app, docs: check required console CPU features before starting Nov 24, 2026
@PrivacyOnion

Copy link
Copy Markdown
Contributor Author

Updated the PR title (�pp, docs: ...) and description: fixed the stray PowerShell escape characters, stated that xcl's launcher.rs was not read, and added the AI assistance: disclosure.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update: the description now states the AI assistance and what was read, and CI is green on b65624d (fmt, both clippy runs, tests, policy, conventions). Approving and merging. The optional items (module doc on where the feature list comes from, probing even when the check is skipped, the error hint, the test that cannot fail) are welcome as a follow-up.

@simnJS
simnJS merged commit 796e848 into MiamiGame:main Nov 24, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/app apps/ area/docs docs/, Markdown size/M 100 to 399 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPU feature check before the title starts

2 participants