cpu: lift x87 environment and state save/restore leaf functions to C++ #2673
Open
Ammmae0x wants to merge 5 commits from
upstream-pr/2681 into main
pull from: upstream-pr/2681
merge into: R0Y00:main
R0Y00:main
R0Y00:codex/indirect-large-backed-views
R0Y00:codex/word3-preflight-check
R0Y00:codex/vertex-table-two-records
R0Y00:codex/live-index-alias
R0Y00:codex/copied-vertex-buffer-srv
R0Y00:codex/windows-stage-test-output
R0Y00:codex/preserve-live-srv-retirement
R0Y00:codex/share-render-target-tracking
R0Y00:codex/sgd5-negative-offset-fixture
R0Y00:coverage-dashboard
R0Y00:codex/mesh-loose-root
R0Y00:codex/mesh86-cache-padding
R0Y00:codex/xmem-scatter-preflight
R0Y00:codex/mesh-depth-ps
R0Y00:codex/indirect-dispatch-refresh
R0Y00:codex/compute-container-index
R0Y00:codex/startup-compute-formatted-load
R0Y00:codex/compute-indirect-producer
R0Y00:codex/compute-atomic-soffset
R0Y00:codex/mesh-dual-handoff
R0Y00:codex/startup-run-sh-watcher-control
R0Y00:codex/queue31-page-alias
R0Y00:codex/indexed-indirect-compute-root
R0Y00:codex/typed-buffer-view-metadata
R0Y00:codex/translated-indexed-address-alias
R0Y00:codex/fixed-mesh-create-result
R0Y00:codex/xmem-section-lease
R0Y00:codex/startup-slot86-mesh-cache
R0Y00:codex/restore-mesh-barrier-iteration
R0Y00:codex/translated-indirect-upload-index
R0Y00:codex/xapu-completion-opt-in
R0Y00:codex/translated-indexed-rect
R0Y00:codex/translated-indexed-indirect
R0Y00:codex/startup-mesh-lds-integration
R0Y00:codex/startup-console-ms24
R0Y00:codex/startup-slot57-mesh-request
R0Y00:codex/indirect-copy-provenance
R0Y00:codex/present-color-producer-trace
R0Y00:codex/compute-dispatch-binding-trace
R0Y00:codex/translated-indirect-table-buffers
R0Y00:codex/indirect-copy-provenance-base
R0Y00:codex/mix-half-literal-source
R0Y00:codex/translated-indirect-draw
R0Y00:codex/xmem-scatter-diagnostics
R0Y00:codex/slot148-recording-upload
R0Y00:codex/slot70-loading-art-verified
R0Y00:codex/command-list-upload-arena
R0Y00:codex/recover-failed-command-list
R0Y00:codex/startup-heap-timing-notes
R0Y00:codex/align-audio-input-timeline
R0Y00:codex/synthetic-depth-export-control
R0Y00:codex/startup-texture1d-on-windows
R0Y00:codex/1629-packed-position-fixture
R0Y00:codex/cpu-srv-refresh
R0Y00:codex/stream-root-srv-draw
R0Y00:codex/audio-mixer-timer
R0Y00:codex/startup-reload-published-shader
R0Y00:codex/priority-integrate-1284
R0Y00:codex/guest-sixteen-page-record
R0Y00:codex/aot-placed-dxr-batch
R0Y00:codex/guest-directory-selection
R0Y00:codex/gamesave-enumerate-read
R0Y00:codex/readme-archive-to-pixels
R0Y00:codex/pe-placed-view-draw
R0Y00:codex/archive-directory-gpu
R0Y00:codex/slot133-dxr-build
R0Y00:codex/materialize-placed-vertex-view
R0Y00:codex/dstorage-directory-offsets
R0Y00:codex/xg-nine-bc-copy
R0Y00:codex/xg-slot10-bc64-arrays
R0Y00:codex/dxr-guest-address-readback
R0Y00:codex/gpu-va-high-bits
R0Y00:codex/clarify-diagnostic-startup-scope
R0Y00:codex/xg-six-levels
R0Y00:codex/typed-derived-blend
R0Y00:codex/english-legal-text-progress
R0Y00:codex/address-bc-4ks
R0Y00:codex/dstorage-bounded-file-read
R0Y00:codex/wide-srv-offsets-menu
R0Y00:codex/startup-memory-srv
R0Y00:codex/bound-view-tail
R0Y00:codex/language-selector-readback
R0Y00:codex/setup-menu-progress
R0Y00:codex/cpu-plane-refresh
R0Y00:codex/startup-ubyte-vertex
R0Y00:codex/presenter-window-selection
R0Y00:codex/startup-uniform-buffer-lane
R0Y00:codex/intro-loop-timing
R0Y00:codex/static-clzero-loops
R0Y00:codex/document-rtx-intro
R0Y00:codex/startup-insertq
R0Y00:codex/nv12-startup-texture
R0Y00:codex/stream-stage-draw
R0Y00:codex/startup-null-uav-format
R0Y00:codex/startup-draw-capture
R0Y00:codex/shorten-windows-checks
R0Y00:codex/dstorage-rfc1950
R0Y00:codex/startup-dump-fence
R0Y00:codex/pr1135-review-base
R0Y00:codex/startup-stream-requests
R0Y00:codex/startup-chroma-view
R0Y00:codex/readme-graphics-pipeline-streams
R0Y00:codex/static-crt-free-tls
R0Y00:codex/arc-140t-rtx-5080-laptop-gpu-reports
R0Y00:codex/main-startup-progress-entry
R0Y00:codex/signed-dxil-catalogue
R0Y00:codex/reloc-free-preferred-base
R0Y00:codex/quad-dpp-bit-mask
R0Y00:codex/raw-srv-bounds
R0Y00:codex/rx9070-31044-hardware-report
R0Y00:codex/gpu-page-source-provenance
R0Y00:codex/runtime-placeholder-interior
R0Y00:codex/gpu-copy-queue-tile-order
R0Y00:codex/pe-pin-external-providers
R0Y00:codex/xmem-placeholder-reservations
R0Y00:codex/xmem-shared-physical-pages
R0Y00:codex/pe-package-startup
R0Y00:codex/xmem-tools-memory-query
R0Y00:codex/cpu-stack-output-import
R0Y00:codex/pe-load-security-cookie
R0Y00:codex/record-three-bvh-retests
R0Y00:codex/cpu-rbp-frame-anchor
R0Y00:codex/xmem-default-startup
R0Y00:codex/record-rtx-3050-ti-9597
R0Y00:codex/docs-readme-start-here
R0Y00:codex/check-compute-mad24-truncation
R0Y00:codex/docs-discord-community
R0Y00:codex/bound-rcx-branch-mutants
R0Y00:codex/rtx5060ti-bvh-62114
R0Y00:codex/837-neutral-readme-disclaimer
R0Y00:codex/record-rtx-3070-ti
R0Y00:codex/title-neutral-public-wording
R0Y00:codex/exe-shadow-frame-submissions
R0Y00:codex/exe-shadow-runtime-chain
R0Y00:codex/readme-polish
R0Y00:codex/gpu-coverage-nov23
R0Y00:codex/spirv-minlod
R0Y00:codex/shadow-shim-device
R0Y00:codex/exe-two-shadow-frames
R0Y00:codex/shim-dispatch-cleanup
R0Y00:codex/fix-spirv-cache-probe
R0Y00:codex/sampler-use
R0Y00:codex/ballot-bit-extract
R0Y00:codex/packed-fma-release
R0Y00:codex/cpu-packed-fma-o2
R0Y00:codex/publish-coverage-dashboard
R0Y00:codex/mesh-cbv-binding-order
R0Y00:codex/spirv-window-fixture
R0Y00:codex/ps-e32-float-uint
R0Y00:codex/ps-cbuffer-reads
R0Y00:codex/fixed-profile-rescan
R0Y00:codex/shim-compute-integration
R0Y00:codex/readme-visible-coverage
R0Y00:codex/readme-research-navigation
R0Y00:codex/integrate-pr-256
R0Y00:codex/indexed-mesh
R0Y00:codex/sampled-coverage
R0Y00:codex/first-ms
R0Y00:codex/dual-ps
R0Y00:codex/ps-attribute
R0Y00:codex/compute-first
R0Y00:codex/ps-export
R0Y00:codex/readme-research-status
R0Y00:codex/ps-layout
R0Y00:codex/blast-window
R0Y00:codex/chart-caption
R0Y00:codex/reviewer-roles
R0Y00:codex/blast-aot
R0Y00:codex/archive-program
R0Y00:codex/crc-stream-program
R0Y00:codex/exe-image-data-chain
R0Y00:codex/local-cpu-fixture-coverage
R0Y00:codex/exe-bound-frame-chain
R0Y00:codex/exe-mapped-comparison
R0Y00:codex/contribution-dependencies
R0Y00:codex/exe-entry-aot
R0Y00:codex/bink-frame-heap-integration
R0Y00:docs/hardware-seven-reports
R0Y00:codex/bink-custom-heap
R0Y00:codex/bink-heap-callers
R0Y00:codex/discussions-entry-points
R0Y00:codex/gpu-community-batch-64
R0Y00:codex/ffx-scratch-writers
R0Y00:codex/generic-project-documentation
R0Y00:codex/ffx-dispatch-rcas
R0Y00:codex/four-windows-gpu-reports
R0Y00:codex/title-neutral-project-wording
R0Y00:codex/community-coverage-provenance
R0Y00:codex/rcas-packed-texels
R0Y00:codex/community-gpu-retests
R0Y00:codex/community-build-and-gpu-reports
R0Y00:codex/ffx-provider-loop
R0Y00:codex/ffx-recurrent-views
R0Y00:codex/ffx-recurrent-resource
R0Y00:codex/amd-wave64-reports
R0Y00:codex/ffx-backend-slots
R0Y00:codex/upscaler-device-init
R0Y00:codex/ffx-context-lifecycle
R0Y00:codex/ffx-version-query
R0Y00:codex/ffx-provider-contract
R0Y00:codex/typed-object-callback
R0Y00:codex/cpu-ordinal-import
R0Y00:codex/chained-cpu-ranges
R0Y00:codex/cpu-import-call
R0Y00:codex/cpu-direct-call
R0Y00:codex/cpu-leaf-aot
R0Y00:codex/community-project-status
R0Y00:codex/script-state-path-replay
R0Y00:codex/script-state-evidence
R0Y00:codex/bc7-resident-tail
R0Y00:codex/bcpack-mip-tail
R0Y00:codex/bc7-texture-draw
R0Y00:codex/asset-ranges
R0Y00:codex/pixel-constants
R0Y00:codex/pixel-aot
R0Y00:codex/pre-exe-workloads
R0Y00:codex/root-signature-device-coverage
R0Y00:engineering/packed-bvh-leaves
R0Y00:engineering/bvh-build-and-update
R0Y00:engineering/intake-root-roundtrip
R0Y00:community/gpu-check-release
R0Y00:community/english-contributor-entry
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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
R0Y00/Xbox2Windows!2673
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2681"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T01:47:55Z.
Change
Add a pure-integer portable x64-to-C++ leaf lifter (
tools/cpu_x87_env_aot.py) and source-built MASM/CTest differential suite (tests/cpu/x87_env_aot.{asm,def,_check.py}, CTestcpu_aot_x87_env) covering the 7 uncovered x87 environment/state mnemonics in flat[rcx|rdx|r8]28/108-byte 32-bit protected-mode forms:FDECSTP,FNSTENV,FSTENV(WAIT+FNSTENV),FLDENV,FNSAVE,FSAVE(WAIT+FNSAVE), andFRSTOR.FDECSTPdecrementsTOP = (TOP - 1) & 7and clearsFSW.C1;FNSTENV/FSTENVsave the 28-byte environment and maskFCW[5:0];FLDENVrestores the 28-byte environment and recomputes non-empty tags;FNSAVE/FSAVEstore the 28-byte environment plus logicalST(0)..ST(7)((TOP+i)&7) and runFNINIT;FRSTORrestores all 108 bytes.WAITstrictly to immediately preceding 28-byteFNSTENVor 108-byteFNSAVE, and rejects 16-bit operand-sizeo16(14/94-byte) forms, displaced/indexed/RIP-relative memory, non-[r8]stores, stack overflow/underflow, non-empty/unknown stack atret, SSE/VEX/EVEX encodings, prefixes, branches, and undefinedaxreads.cpu_aot_x87_envwithFORM_COVERAGE_RECORD(; coverage: record cpu_aot_x87_env), recording all 18 mnemonics includingfstenvandfsaveonWAIT+fnstenv/fnsavepairs.Verification
8867a115(based onupstream/main72879797)cmake --preset dev+cmake --build --preset dev --target cpu_x87_env_aot_original cpu_x87_env_aot_original_lifted cpu_x87_env_aot_altered cpu_x87_env_aot_altered_lifted-> 0 errors, 0 warningsctest --preset dev -N->Total Tests: 2166(cpu_aot_x87_envregistered)ctest --preset dev --output-on-failure -R "^cpu_aot_x87_env$" -E "cpu_native_archive_"->1/1 Passed(0.43s);out\build\dev\form_coverage\cpu_aot_x87_env.txtrecorded 18 forms (includingfdecstp,fldenv,fnsave,fnstenv,frstor,fsave,fstenv)cmake --preset release+cmake --build --preset release --target cpu_x87_env_aot_original cpu_x87_env_aot_original_lifted cpu_x87_env_aot_altered cpu_x87_env_aot_altered_lifted-> 0 errors, 0 warningsctest --preset release --output-on-failure -R "^cpu_aot_x87_env$" -E "cpu_native_archive_"->1/1 Passed(0.49s);out\build\release\form_coverage\cpu_aot_x87_env.txtrecorded 18 formsout\pe-env\Scripts\python.exe -B tests\form_coverage_check.py->form coverage checks passed(exit 0)out\pe-env\Scripts\python.exe -B tests\docs_links_check.py->Self-test passed. Checked 19 Markdown files and 510 links.(exit 0)out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py->Self-test passed. Checked 1894 tracked source, script and build/CI files: no bidirectional controls.(exit 0)x87_fdecstpTOP decrement direction,x87_fnstenvFCW[5:0]masking,O16_ENV_CODES16-bit guard).o16forms, invalidWAIT, overflow/underflow, non-empty stack atret, displaced/indexed/non-[r8]memory, SSE/VEX/EVEX), CLI atomic-write/path-guard negative checks, MXCSR DAZ/FTZ isolation across 4 modes, 5 mutant checks, and 7ALTER_X87_ENVdiverging exports.Evidence and follow-up
All assembly fixtures in
tests/cpu/x87_env_aot.asmare source-built MASM x64 routines authored under the repository MIT license; differential comparisons check deterministic architectural fields (avoiding host RIP-dependent native FIP/FDP after native loads).Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:06:59Z.
Review: COMMENTED
Review of head
e59e5de9(comment only).What I checked:
cpu_aot_x87_exp_logregistration (original/altered fixtures,FORM_COVERAGE_RECORD); the export list matches the.def.Commands executed locally (Linux):
python3 -I -m py_compile tools/cpu_x87_env_aot.py tests/cpu/x87_env_aot_check.pyokpython3 tests/docs_links_check.pyokpython3 tests/bidi_controls_check.pyokgit diff --check origin/main...HEADcleanThe differential and mutant checks need the Windows source build; they are covered by the Win2025 run, which I will report separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:15:43Z.
Win2025 (WARP) result for head
e59e5de9: the new test fails, so this is not ready to merge.cpu_aot_x87_env(dev build) fails incheck_differential:The translator and refusal controls pass (10 sequences accepted, 44 rejection controls). The mismatch is the saved FOP field in the FNSTENV image after FDECSTP when TOP wraps: the native CPU and the lifted code store different values. Either the lifter should model the last-opcode field as the hardware does, or the check should exclude
fopfor this case (like it already does forfipviacheck_fip=False). Release was not reached.Command:
python3 x2w_pipe.py win2025 2681 --wait 7200 --keep-release --regex cpu_aot_x87_envAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T06:45:06Z.
Review: CHANGES_REQUESTED
AMD result for head
e59e5de9.The new test fails on AMD.
ctest --preset dev --no-tests=error -R '^cpu_aot_x87_env$' -Vfails on an AMD Ryzen 7 9800X3D (Windows 11 build 26300) with the same assertion as the Win2025 run:fdecstp_wrap_top_0: fop mismatch nat=0x1f6 lif=0x3ab(check.py:437). The failure is deterministic.Further issues, each measured locally:
Entry state. The lifted function starts from FNINIT state (CW 0x037F), but the lifter accepts reads before any init.
fnstcw word ptr [r8]; retlifts to a store of 0x037F, while the native code stores 0x027F: the Windows x64 default, which the existing x87 profile also fixes (cpu_aot_x87_fnstcw). Please refuse reads of CW, SW or the environment beforefninit/fldcw/fldenv/frstor, or model 0x027F.Unmasked exceptions. The CW can come from memory (
fldcw [rdx], FLDENV, FRSTOR), so the claim that masked exceptions can't raise #MF isn't proven.op_fstenv_pushedraises a float invalid-operation exception, and the lifted export returns normally.op_frstor_fdecstp_fnsaveraises at FDECSTP, and the lifted export returns.Please require a statically masked CW (and SW.ES=0 after FLDENV/FRSTOR), or refuse these cases.
FNINIT doesn't clear the register contents, only the tags. After a call that leaves 1.0 in a physical register,
op_fdecstp_wrap_envwith TW=0xCFFF gives native 0xCFFF and lifted 0xDFFF. Thetw == 0xF7FFassertion and its comment ("Physical regs were zeroed by fninit") only hold because of what ran earlier in the process.Undefined condition codes. The SDM leaves C0/C2/C3 undefined after FDECSTP, and C0-C3 undefined after FSTENV/FNSTENV. The current x87 profile refuses readers of undefined condition codes. Please refuse them here too, or state the measured profile.
FCS and FDS are never compared. Native AMD stores FCS=0x33 after a non-control instruction.
Docs. There's no
docs/experiments.mdentry, and thecpu_x87_environment_controlsparagraph still says no native fixture exists for these forms.Neighbours and mutants:
ctest --preset dev -R '^cpu_': 305 passed, 1 skipped (cpu_aot_sysdesc), 1 failed (this test).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T06:23:49Z.
On the same
e59e5de9tree, Windows 11 build 26200 Release on an Intel i9-14900HX passes cpu_aot_x87_env, including 129 differential cases, 12 MXCSR isolation checks and the mutations. The earlier Win2025 native FOP mismatch remains a real cross-host difference. Intel documents that the saved FOP depends on fopcode compatibility mode and an unmasked exception in the default mode. A raw FOP comparison after a masked, non-control instruction is therefore insufficient to establish the portable behavior. Please specify which metadata profile this lifter implements and preserve strict comparisons for the architectural state. Separate the explicit FLDENV/FRSTOR metadata round-trip from native FOP produced by FDECSTP, and keep a distinguishing control for whichever FOP behavior the profile guarantees.Intel SDM, Volume 1, x87 FPU Opcode Register
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T16:03:32Z.
Updated PR #2681 (commit
520b61c0) to address the Win2025, @R0Y00, and @MasterDomino review findings:preserved-metadataprofile intools/cpu_x87_env_aot.py,tests/cpu/x87_env_aot_check.py, anddocs/experiments.md. Separated strict 28-byteFLDENV/FRSTORround-trips (includingfcsandfdsinassert_env28_deterministic) fromFDECSTP/FLD/FSTPnative comparisons (where Intel default mode preservesFOP/FCSwhile AMD/compat parts updateFOP=0x1F6/FCS=0x33), strictly assertingpreserved-metadataon lifted outputs and adding two compiled C++ profile-distinguishing mutant controls (mut_fdecstp_updates_fop_wrap,mut_fdecstp_updates_fop_frstor).FCW(FNSTCW) beforeFNINIT/FLDCW/FLDENV/FRSTOR, reads ofFSW/env (FNSTSW/FNSTENV/FNSAVE/FDECSTP) beforeFNINIT/FLDENV/FRSTOR, andFSWreaders afterFNSTENV/FSTENVbefore re-init (documenting the measuredFDECSTPC1=0/ preservedC0,C2,C3profile). DefaultedX87State.cwto0x027F.FNINITregister-state safety: Added runtimex87_trap()(__ud2()) viax87_check_mfbeforeWAIT/FDECSTP/FLD*/FSTP*and onSW.ES!=0or unmasked pending exceptions inFLDENV/FRSTOR. Removed false register zeroing fromx87_fninitand trackedregs_definedsoFLDENVwith non-emptyFTWon uninitialized physical registers traps cleanly (verified with 40xC000001Dtrap controls plustw=0xFFFFafter leaving1.0natively).cpu_x87_env_aot_mutants(8 compiled C++ mutant controls) and updateddocs/experiments.md(bothcpu_x87_environment_controlsand the newcpu_aot_x87_enventry).Verified on Windows 11 x64 (13th Gen Intel Core i7-13620H) on both
--preset devand--preset release(ctest -R "^cpu_aot_x87_env$" -V): 10 accepted, 54 rejection controls, 130 differential/roundtrip/altered cases (nativeFDECSTPFOP=preserved), 4 runtime trap controls, 12 MXCSR isolation checks, 8 compiled C++ mutants, and 7 altered-build controls passed, plusdocs_links_check.py,bidi_controls_check.py, andform_coverage_check.py(all exit 0).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:55:30Z.
Review: APPROVED
Independently reviewed
520b61c0integrated overmain4b0350ea(treed0beff29), on the AMD part that failed one59e5de9. The merge is clean andgit diff --cached --check origin/mainis clean.AMD run on the current head. The host is an AMD Ryzen 7 9800X3D on Windows 11 build 26200, the same CPU model as MasterDomino's failing run.
Both presets pass, with no skips:
10 x87 env sequences accepted; 54 rejection controls passed;130 differential/state/roundtrip/altered cases matched (native FDECSTP FOP=updated(fop=0x1f6,fcs=0x33)); 4 runtime trap controls passed; 12 MXCSR DAZ/FTZ isolation checks passed; 8 compiled C++ mutant controls + 7 altered-build controls caught;cpu_(aot_x87|x87)tests pass.The check classifies this host's FDECSTP as the updating profile, where the i7-13620H in the description reports
preserved. The lifted code is held topreserved-metadatain both cases.form_coverage_check,docs_links_check(121 files, 625 links) andbidi_controls_checkpass.Earlier findings, checked at this head.
preserved-metadataprofile. The FLDENV/FRSTOR round-trips comparefcs,fop,fdpandfdsstrictly. FDECSTP's native FOP is only classified, and must be one consistent profile per host.mut_fdecstp_updates_fop_wrapandmut_fdecstp_updates_fop_frstortell the profiles apart.fnstcw [r8]; retand the SW/environment reads before init are refused (fnstcw_before_initand its siblings), andX87State.cwdefaults to0x027F.__ud2).op_fstenv_pushedwith CW=0x037E and an f64 SNaN, andop_frstor_fdecstp_fnsavewith CW=0x037E and SW=0x0081, now raise0xC000001Dbefore writing output. Native code raises the float exception instead, so the code differs, but neither returns normally.x87_fninitno longer zeroes registers. FLDENV with a non-empty tag on a register this function never defined traps (uninit_reg_fldenv_tw_cfff).0x4501), and it matches on this AMD part as well as on the Intel hosts.assert_env28_deterministic. FDS is still not pinned, though; see the first note below.cpu_aot_x87_enventry, and thecpu_x87_environment_controlsparagraph is updated.Mutants of my own in
tools/cpu_x87_env_aot.py. Each was applied alone, the lifted and mutant targets rebuilt indev, the test run, and the source restored afterwards (git diff --quietclean).x87_check_mfnever trapsfnstcw-before-init refusal removedFCW[5:0]fcsstored as 0fdsstored as 0X87State.cwdefault0x027F→0x037FNon-blocking.
fds=0. A probe through the PR's exports gives the same FDS from native and liftedop_fldenv_fnstenv:fcs=0x1234 fds=0x5678,fds=0x2bandfcs=0x33round-trip unchanged. One round-trip input with a non-zero FDS would kill the surviving mutant.op_fldenv_fnstenvandop_frstor_fnsavewith SW.ES=1 return normally, while the lifted code traps. This is what MasterDomino asked for ("SW.ES=0 after FLDENV/FRSTOR"). The only FRSTOR trap case is followed by FDECSTP, which traps anyway, so the FRSTOR check itself is unpinned. A sentence in the profile docs saying that these traps go beyond the hardware would make this explicit.Verdict: approve on
520b61c0. MasterDomino's changes request one59e5de9still stands, so I am not merging.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU tests ran.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on520b61c0.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:18:19Z.
Review of head
520b61c0, trial-merged intomain1f07b2c1(git merge-tree --write-treerc=0, no conflicts). Thanks for the thorough update. The FOP profile, the entry-state refusals, the #MF trap, the FNINIT register handling and the docs all look addressed to me. There are two things I'd ask you to fix before this merges.1. The FCS/FDS round-trip depends on the host (blocking). The lifter stores the loaded
st.fcsandst.fds, and the docs say that thefldenv→fnstenvandfrstor→fnsaveround-trips comparefcsandfdsstrictly. But every check input uses zero:grep -oE 'fcs=[0-9a-fx]+|fds=[0-9a-fx]+' tests/cpu/x87_env_aot_check.py | sort | uniq -c→7 fcs=0,7 fds=0. So the comparison can't see a difference.I ran a native probe on an Intel i7-10700KF (Linux x86-64, gcc inline asm
fninit; fldenv m28; fnstenv m28; fninit). It reports CPUID.(EAX=7,ECX=0):EBX[13]=1 (FCS/FDS deprecated). Loadingfcs=0x1234 fds=0x5678givesfcs=0 fds=0back, whilefip=0x11223344,fop=0x155andfdp=0x55667788come back unchanged. The AMD review above saw these values preserved.That means the non-zero FDS input suggested above, which would kill the surviving
fdsmutant, would fail on Intel parts like this one. Could you treat FCS/FDS the way you treat FOP? Classify the host with a non-zero-selector round-trip, hold the lifted code to the named profile, and add a control that tells the two behaviours apart. The other option is to narrow the docs claim and refuse non-zero selectors.2. C0–C3 loaded by FLDENV/FRSTOR are accepted through WAIT, FLDCW, FNSTCW and FNSTSW (should fix). On the merged tree,
lift_codeacceptsfldenv; wait; fnstenv,fldenv; fldcw; fnstenv,fldenv; fnstcw; fnstenv,frstor; fnstsw ax; fnsaveandfrstor; wait; fnsave. The SDM leaves C0–C3 undefined after all four instructions.tools/x87_lower.pyrejects these sequences ("including WAIT ..., FNSTCW and FNSTSW itself"), and the editedcpu_x87_environment_controlsparagraph still says thatfstenvandfsaveare rejected.The same Intel host preserves C0–C3 (
sw=0x4700in givessw=0x4700out for all four), but no fixture case covers these paths. Please either state that measured profile and add one FLDENV→WAIT→FNSTENV case with C0–C3 set, or mark C0–C3 unknown after these four instructions.A smaller point: the docs call the preserved FOP "Intel default fopcode compatibility behavior". In that mode the SDM only defines FOP after an unmasked exception, so "measured on the i7-13620H" would be more accurate.
On the merged tree, these pass:
docs_links_check,bidi_controls_check,form_coverage_checkand the translator controls (10 x87 env sequences accepted; 54 rejection controls passed). Removingcc_known = Falseafter FNSTENV makes the translator check fail (translator accepted rejected sequence). CI is green, but the Windows job runsctest --preset pr(100% tests passed out of 40) and doesn't includecpu_aot_x87_env. I didn't run the native/lifted DLL differential here, because I have no Windows host.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-28T11:12:16Z.
Addressed all items from JohnConnorNPC and pigalot in
90ce1e69(merged withupstream/mainec71c290):FCS/FDSround-trip profile (tests/cpu/x87_env_aot_check.py):op_fldenv_fnstenv,op_fldenv_wait_fnstenv,op_frstor_fnsave,op_fdecstp_wrap_env, andop_frstor_fdecstp_fnsaveto supply non-zeroFCS/FDSselectors (0x1234/0x5678,0x002B/0x0033).preserved-metadatamodel strictly assertsFCS/FDSpreservation, while_classify_fcs_fdsclassifies native hardware consistently (preservedvsdeprecated-zeroonCPUID.(EAX=7,ECX=0):EBX[13]=1parts).mut_fldenv_zero_fcs_fdstoMUTANT_SPECSso zeroingFCS/FDSis caught even ondeprecated-zerohosts.C0..C3acrossWAIT/FLDCW/FNSTCW/FNSTSW AX) & eagerFRSTORtrap:op_fldenv_wait_fnstenv(tests/cpu/x87_env_aot.asm,.def,CMakeLists.txt) verifyingSW=0x4700(C0..C3) is preserved acrossFLDENV -> WAIT -> FNSTENV.WAIT/FLDCW/FNSTCW/FNSTSW AXC0..C3preservation profile and eagerFLDENV/FRSTOR#MF/SW.EStrap behavior intools/cpu_x87_env_aot.pyanddocs/experiments.md(includingmeasured on the i7-13620Hwording).sw_es_frstoronop_frstor_fnsavedirectly incheck_runtime_traps(withoutFDECSTP).Verified on Windows in both
devandrelease(/O2):cpu_aot_x87_env&cpu_x87_environment_controlspassed (12accepted,54rejections,132differential cases withFOP=preservedandFCS/FDS=deprecated-zero,5runtime traps,12MXCSR checks,9C++ mutants,7altered-build controls),form_coverage_check.py/docs_links_check.py/bidi_controls_check.pyexited 0, and 3/3 spot-mutations were caught.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T11:22:47Z.
Review: APPROVED
Retested
90ce1e69integrated overmainee3347d3(treec9238d3d). The merge is clean andgit diff --cached --check origin/mainis clean. The author's merge ofmain(60b5a24a) has an emptygit show --remerge-diff, so I read60b5a24a..90ce1e69as the change since my approval on520b61c0.Run on the AMD host. AMD Ryzen 7 9800X3D, the CPU model of MasterDomino's failing run on
e59e5de9.Both presets pass, with no skips:
12 x87 env sequences accepted; 54 rejection controls passed;132 differential/state/roundtrip/altered cases matched (native FDECSTP FOP=updated(fop=0x1f6,fcs=0x33), FCS/FDS=preserved); 5 runtime trap controls passed; 12 MXCSR DAZ/FTZ isolation checks passed; 9 compiled C++ mutant controls + 7 altered-build controls caught;cpu_(aot_x87|x87)tests pass.This host classifies as FCS/FDS
preserved, where the author's i7-13620H reportsdeprecated-zero. So the two profiles of each classification (FOP and FCS/FDS) have now both been seen passing.docs_links_check(155 files, 678 links),bidi_controls_checkandform_coverage_checkpass.Findings since
520b61c0, checked at this head.0x1234/0x5678,0x002B/0x0033). The lifted output is held to the loaded values; the native output is classified aspreservedordeprecated-zero, anything else fails, and the host must give one profile across all cases.mut_fldenv_zero_fcs_fdstells the two behaviours apart.docs/experiments.md, andop_fldenv_wait_fnstenvcomparesSW=0x4700natively across WAIT. That is the case he asked for. FLDCW, FNSTCW and FNSTSW AX have no native case; see the note below.fds stored as 0mutant that survived on520b61c0is now killed.sw_es_frstorpins the FRSTOR check without FDECSTP. The mutant that survived on520b61c0is now killed.Mutants of my own in
tools/cpu_x87_env_aot.py. Each was applied alone, the five targets rebuilt indev, the test run, and the source restored afterwards (git diff --quietclean, test passes again).fdsstored as 0fdecstp_wrap_top_0: preserved-metadata mismatch)fcsstored as 0fdsloaded as 0sw_es_frstor: lifted op_frstor_fnsave returned instead of trapping)sw_es_fldenv)fldenv_wait_fnstenv_0x4700: sw mismatch nat=0x4700 lif=0x0)No equivalent mutants in this round.
Non-blocking.
frstor_cw_sw_fnsavesequence is only a translator acceptance case, so the three surviving mutants above pass. The docs sentence "wait,fldcw,fnstcw, andfnstsw axpreserveC0..C3(verified byop_fldenv_wait_fnstenvwithSW = 0x4700)" reads as if that export covers all four; it covers WAIT. One native export such asfrstor; fldcw; fnstcw; fnstsw ax; fnsavewith C0–C3 set would pin the other three, or the sentence could name WAIT as the only fixture-checked one.Verdict: approve on
90ce1e69. MasterDomino's changes request one59e5de9still stands on the PR, so I am not merging.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. No GPU tests ran.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on90ce1e69.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:24:33Z.
Re-review of head
90ce1e69, trial-merged ontomainc04e0dd6(git merge-tree --write-treeexits 0,git diff --checkclean). Pure Python on Linux, plus native x87 probes (gcc inline asm) on an Intel i7-10700KF. I did no MSVC build, so the native/lifted DLL differential is not re-run here.Since my comment on
520b61c0:60b5a24ais a clean merge ofmain(git show --remerge-diffprints nothing).preservedordeprecated-zero, with a single profile required per host. I mirrored the fixture's FCS/FDS cases in a native probe here. This host reportsCPUID.(EAX=7,ECX=0):EBX[13]=1, and the probe givesFCS/FDS profile counts: preserved=0 deprecated-zero=7 other=0 -> single profile. It covers bothfldenv_fnstenvsets, bothfldenv_wait_fnstenvcases,fdecstp_wrap_top_0/7andfrstor_fnsave. FDECSTP leaves FOP alone on all 8 tops (preserved=8 updated=0). So a second Intel part classifies the same way as the author's i7-13620H.sw C0..C3 in=0x4700 out=0x4700, which matches the newop_fldenv_wait_fnstenvcase. I won't repeat the FLDCW/FNSTCW/FNSTSW note from the latest approval.12 x87 env sequences accepted; 54 rejection controls passed.form_coverage_check,docs_links_checkandbidi_controls_checkexit 0.MUST: none.
SHOULD
docs/experiments.mdsay FDECSTP, FLD, FLD1, FLDZ and FSTP preserve the loaded or initialized FIP in the lifted model, "matching the profile measured on the i7-13620H". The fixture never compares FIP after these instructions:fdecstp_wrap_top_*,fnstenv_pushed_*,fstenv_pushed_*andfrstor_fdecstp_top_*all callassert_env28_deterministic(..., check_fip=False).Here, I ran FLDENV (FIP
0x12345678) followed by one instruction and then FNSTENV. FIP came back as the low 32 bits of that instruction's own address for FDECSTP, FLD1, FLD m80 and FSTP m80 (for examplefdecstp fip=0x8f98c312 (insn low32 0x8f98c312 UPDATED)). FOP and FDP kept their loaded values. The AMD result one59e5de9also showed FDECSTP updating FIP. So on both vendors measured so far, the lifted FIP differs from native after these instructions.Fix: say that FIP after non-control instructions is neither modelled nor compared. Or classify the native FIP the way FOP is classified, and add a case that tells the two apart.
NIT
2.
_classify_fcs_fdsaccepts whichever profile the host shows, but never reads CPUID. The docs tiedeprecated-zerotoCPUID.(EAX=7,ECX=0):EBX[13]=1. Asserting that the bit agrees with the observed profile would separate a deprecating host from a wrong result.Merge is blocked by the changes request on
e59e5de9. Its FOP, entry-state, #MF, FNINIT, FCS/FDS and docs points look addressed at this head, so it needs a re-review by the reviewer who opened it. I'd like SHOULD 1 settled first, but it's a docs/profile fix, not wrong code inside the stated model.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-12-01T03:22:03Z.
@MasterDomino Friendly re-review ping: your
CHANGES_REQUESTEDreview one59e5de9is currently the only merge block on this PR.Head
90ce1e69(via520b61c0and90ce1e69) addresses the FOP/FCS/FDS profiles, pre-init state refusals, unmasked exception traps, FNINIT register/tag handling, undefined condition codes, and docs. All 5 CI checks pass,git merge-tree --write-treeontoupstream/main(1c634037) exits0, and@pigalotre-tested and approved90ce1e69on an AMD Ryzen 7 9800X3D Windows 11 host (all 31cpu_(aot_x87|x87)checks passing acrossdevandrelease).Could you re-review when you have a moment so this can land? Thank you!
AI-assisted.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.