Pin x87 status-word AX tracking across joins, EAX reads and direct calls #1003

Merged
Leyukaka merged 2 commits from upstream-pr/1010 into main 2026-11-23 21:27:55 +00:00
Leyukaka commented 2026-11-23 21:10:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-23T21:10:38Z.


Change

This closes three gaps in the test coverage of the status-word tracking in tools/x87_lower.py. Each gap is shown by a small mutation of the lowering that still passes the whole ^cpu_ suite on main. Only tests/cpu/x87_status.py and one paragraph of docs/experiments.md change; the lowering does not.

New rejection probe Mutation it covers
One path skips and ah, 45h before mov [rdx], ah (reads AX bits 0x8200) the known AX bits at a join taken as the union instead of the intersection
fnstsw ax, then mov al, 0 and test eax, eax (reads AX bits 0x8200) an EAX read counted as a read of AL only
A direct call with the status word still in AX (RAX holds unknown status-word bits 0x82ff at call) direct calls dropped from the points where unknown AX bits must not escape

The first probe is the only case in the ^cpu_ suite that pins the AX join; the existing join case pins only the condition bits. The second also pins that an AL write makes only the low byte known. All three are translation-only byte sequences, like the existing probes. The translation now rejects 35 sequences instead of 32, and the docs list the three new ones.

Verification

On 12574172 (based on main at ace6a3c), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R '^cpu_aot_x87_status$' -V
python -B tests/docs_links_check.py

The test passes and prints rejected 35 sequences outside the profile: .... The docs check passes.

Each mutation was applied to tools/x87_lower.py one at a time and the project was rebuilt. With main at commit 3174eb3, the ^cpu_ suite passed under all three mutations (tools/x87_lower.py and tests/cpu/x87_status.py are unchanged between the branch base and current main); with this branch, cpu_aot_x87_status fails under each of them. With the unmutated lowering everything passes.

The three edits to tools/x87_lower.py:

  1. self.ax & other.ax -> self.ax | other.ax
  2. read |= bits -> read |= bits & (0x00FF if used.register == R.EAX else 0xFFFF)
  3. if flow in (FlowControl.RETURN, FlowControl.CALL, FlowControl.INDIRECT_CALL, FlowControl.INDIRECT_BRANCH): -> without FlowControl.CALL

Evidence and follow-up

No new fixture file: the three probes are hand-written byte sequences inside tests/cpu/x87_status.py, translated only, like the existing probes. No follow-up is needed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6568906992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1010). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-23T21:10:38Z. --- ## Change This closes three gaps in the test coverage of the status-word tracking in `tools/x87_lower.py`. Each gap is shown by a small mutation of the lowering that still passes the whole `^cpu_` suite on `main`. Only `tests/cpu/x87_status.py` and one paragraph of `docs/experiments.md` change; the lowering does not. | New rejection probe | Mutation it covers | |---|---| | One path skips `and ah, 45h` before `mov [rdx], ah` (`reads AX bits 0x8200`) | the known AX bits at a join taken as the union instead of the intersection | | `fnstsw ax`, then `mov al, 0` and `test eax, eax` (`reads AX bits 0x8200`) | an EAX read counted as a read of AL only | | A direct call with the status word still in AX (`RAX holds unknown status-word bits 0x82ff at call`) | direct calls dropped from the points where unknown AX bits must not escape | The first probe is the only case in the `^cpu_` suite that pins the AX join; the existing join case pins only the condition bits. The second also pins that an AL write makes only the low byte known. All three are translation-only byte sequences, like the existing probes. The translation now rejects 35 sequences instead of 32, and the docs list the three new ones. ## Verification On `12574172` (based on `main` at `ace6a3c`), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R '^cpu_aot_x87_status$' -V python -B tests/docs_links_check.py ``` The test passes and prints `rejected 35 sequences outside the profile: ...`. The docs check passes. Each mutation was applied to `tools/x87_lower.py` one at a time and the project was rebuilt. With `main` at commit `3174eb3`, the `^cpu_` suite passed under all three mutations (`tools/x87_lower.py` and `tests/cpu/x87_status.py` are unchanged between the branch base and current `main`); with this branch, `cpu_aot_x87_status` fails under each of them. With the unmutated lowering everything passes. The three edits to `tools/x87_lower.py`: 1. `self.ax & other.ax` -> `self.ax | other.ax` 2. `read |= bits` -> `read |= bits & (0x00FF if used.register == R.EAX else 0xFFFF)` 3. `if flow in (FlowControl.RETURN, FlowControl.CALL, FlowControl.INDIRECT_CALL, FlowControl.INDIRECT_BRANCH):` -> without `FlowControl.CALL` ## Evidence and follow-up No new fixture file: the three probes are hand-written byte sequences inside `tests/cpu/x87_status.py`, translated only, like the existing probes. No follow-up is needed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:50 +00:00
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
R0Y00/Xbox2Windows!1003
No description provided.