tooling: add bit-operation generators to the CPU fuzz test #1777

Merged
roansystemlabs merged 1 commit from upstream-pr/1784 into main 2026-11-25 19:33:36 +00:00
roansystemlabs commented 2026-11-24 18:38:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T18:38:05Z.


Refs #446.

Adds the bits area claimed in #446 (https://github.com/R0Y00/Xbox2Windows/issues/446#issuecomment-7139407793): bit tests, bit counts, bit scans, byte swaps and immediate shifts on the shared cpu_switch_aot lifter, with every flag read only under the conditions the translator defines for its producer. Six refused controls cover the documented limits, and a planted fault in the bit-test lowering must be detected.

As asked for the other areas in #446: the area has its own seed, 0xB175, and the existing generators' emitted cases and translations are unchanged.

Change

tools/fuzz_cpu.py --area bits generates straight-line leaf functions from its own seed, in one MASM DLL and one translation. The new CTest is cpu_aot_fuzz_bits; the default is seed 0xB175 with 40 exports.

  • Steps. Each export runs 8 to 10 steps, with every kind at least once: BT, BTS, BTR or BTC on a 16-, 32- or 64-bit register base with an immediate or register offset; the same on a memory base with an immediate offset; POPCNT, LZCNT or TZCNT, and BSF or BSR, from a register or memory source; a 32- or 64-bit BSWAP, sometimes between a bit test and its readers; and SHL, SHR or SAR of an 8- to 64-bit register by 1 up to the operand width minus 1. About one immediate bit offset in five (21 of 123 at the default seed) is past the operand width. Exports are straight-line; every Jcc jumps forward, so every input terminates, under the planted fault too.
  • Values. RAX, R9 and R10 carry values from step to step. Sources are the arguments, R11 masked or shifted from one of them so that it is often zero, or a 32-byte bit string in the output buffer that the memory bit tests change. Each step stores its destination, so a zero-source BSF or BSR shows its unchanged destination, upper half included.
  • Flags. Each producer is read by one to three of SETcc into the buffer, CMOVcc into a carried register and a forward Jcc around an update of one, only under the defined conditions: B and AE after a bit test, E and NE after a bit scan, B, AE, E, NE, BE and A after LZCNT and TZCNT, all sixteen after POPCNT and a shift by 1, and all but O, NO, L, GE, LE and G after a larger shift.
  • Refused controls. A register bit offset into memory, SETZ after BT, SETS after LZCNT, SETC after BSF, SETC after an 8-bit SHL by 8 and SETO after SHR by 3; each must be refused with the translator's reason.
  • Host check. A native export, the same CPUID code as host_bit_counts in tests/cpu/switch_bit_counts.asm, is called first; without POPCNT, BMI1 and ABM the test is skipped (exit 77), as cpu_aot_switch_bit_counts is. It is the only generic change: Function.host_features marks such a probe, which is exported but never translated or compared; the other areas set no probe, so their filters select the same functions as before.
  • Planted error. translate --mutant (set_reset_swap) makes BTS clear the selected bit and BTR set it; CF, BT and BTC stay right. check --mutant runs it against native, and the test fails if it never differs.
  • Existing tests. The emitted MASM and .def of the eight existing areas (at their default seed and one longer seed each), and their clean and mutant translations in dev and release, are byte-identical to main.

Measurements

Commit f5edebc on b4c961c. Intel Core i7-10700 (POPCNT, BMI1, ABM), Windows 11 build 26200, MSVC 19.44.35230, CMake/Ninja, Python 3.12.

ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_bits$' -V
area=bits seed=0xb175 functions=40 inputs=313 comparisons=25040 default and /O2 matched
controls refused: fuzz_bits_refused_bit_string (unsupported bit-string operand), fuzz_bits_refused_test_zero (only CF is defined after BT), fuzz_bits_refused_count_sign (OF, SF and PF are undefined after LZCNT), fuzz_bits_refused_scan_carry (only ZF is defined after BSF), fuzz_bits_refused_shift_width (CF is undefined for SHL and SHR), fuzz_bits_refused_shift_overflow (OF is undefined after a shift by more than 1)
mutant set_reset_swap: 11581/12520 mismatches in 37/40 functions
Preset Runs cpu_aot_fuzz_bits
dev 3 0.71–0.81 s
release 3 0.71–0.84 s

Default seed contents, counted from the emitted MASM: 154 bit tests (66 on memory, 31 with a register offset, 21 with an immediate offset past the width), 57 counts, 54 scans, 57 byte swaps (33 at 32 bits, 24 at 64) and 63 shifts, read by 331 SETcc, 160 CMOVcc and 143 Jcc. Replaying the sources on the 313 inputs, 5,515 of 16,902 scans and 2,982 of 10,016 LZCNT and TZCNT calls have a zero source. The three exports the mutant leaves equal to native have no BTS or BTR.

Failure paths, run by hand against the dev build:

  • Mutant passed as the translation. Exit 1 at fuzz_bits_0 input 0 (native RAX 0x1231f1d, translated 0x1231f1f; first differing byte at output offset 16, the step's BTS), with the MASM and the reproduce: line. That command repeats the case; with the clean translation it exits 0.
  • Clean translation passed as --mutant. Exit 1, the planted translator fault was not detected.
  • Capability skip. With a probe mask this processor cannot report, the check exits 77 with capability skip: ....

Longer manual run: cmake --preset dev -DCPU_FUZZ_BITS_SEED=<seed> -DCPU_FUZZ_BITS_FUNCTIONS=128, then the same test (on 9ffb852; 0xCCD1 also on f58d242, with the same counts).

Seed Exports Comparisons Time Refusals Mismatches Mutant mismatches
0x1 128 80,128 2.53 s 0 0 33,178/40,064
0x2 128 80,128 1.96 s 0 0 35,056/40,064
0xBEEF 128 80,128 1.99 s 0 0 33,804/40,064
0xCCD1 128 80,128 1.93 s 0 0 34,117/40,064

Wider checks:

  • ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_' and the same with --preset release: 9/9 pass.
  • ctest --preset dev --no-tests=error -R '^cpu_' after a full dev build on f58d242: 258/258 pass, with 3 capability skips (cpu_aot_switch_fsgsbase_rdpid, cpu_aot_fences_hints_clwb, cpu_aot_crypto_sha). The commits since touch no CPU tool, CPU test or fuzz block.
  • tests/docs_links_check.py (17 files, 367 links), tests/bidi_controls_check.py and git diff --check pass.

Not run: MSVC 19.5x, Linux, an AMD processor, a host without BMI1 or ABM (the skip was only simulated), more than 128 exports.

Scope

Leaf functions only. 16-bit BSWAP (refused: its result is undefined), shifts by CL, rotates as flag producers, SHLD and SHRD, and the BMI1 and BMI2 forms beyond LZCNT and TZCNT are not generated. #1667 (x87) touches the same three files; if it lands first, I'll rebase and rerun these checks. docs/experiments.md gains a cpu_aot_fuzz_bits paragraph after the loops one.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588830006 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1784). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-24T18:38:05Z. --- Refs #446. Adds the bits area claimed in #446 (https://github.com/R0Y00/Xbox2Windows/issues/446#issuecomment-7139407793): bit tests, bit counts, bit scans, byte swaps and immediate shifts on the shared `cpu_switch_aot` lifter, with every flag read only under the conditions the translator defines for its producer. Six refused controls cover the documented limits, and a planted fault in the bit-test lowering must be detected. As asked for the other areas in #446: the area has its own seed, `0xB175`, and the existing generators' emitted cases and translations are unchanged. ## Change `tools/fuzz_cpu.py --area bits` generates straight-line leaf functions from its own seed, in one MASM DLL and one translation. The new CTest is `cpu_aot_fuzz_bits`; the default is seed `0xB175` with 40 exports. - **Steps.** Each export runs 8 to 10 steps, with every kind at least once: `BT`, `BTS`, `BTR` or `BTC` on a 16-, 32- or 64-bit register base with an immediate or register offset; the same on a memory base with an immediate offset; `POPCNT`, `LZCNT` or `TZCNT`, and `BSF` or `BSR`, from a register or memory source; a 32- or 64-bit `BSWAP`, sometimes between a bit test and its readers; and `SHL`, `SHR` or `SAR` of an 8- to 64-bit register by 1 up to the operand width minus 1. About one immediate bit offset in five (21 of 123 at the default seed) is past the operand width. Exports are straight-line; every `Jcc` jumps forward, so every input terminates, under the planted fault too. - **Values.** RAX, R9 and R10 carry values from step to step. Sources are the arguments, R11 masked or shifted from one of them so that it is often zero, or a 32-byte bit string in the output buffer that the memory bit tests change. Each step stores its destination, so a zero-source `BSF` or `BSR` shows its unchanged destination, upper half included. - **Flags.** Each producer is read by one to three of `SETcc` into the buffer, `CMOVcc` into a carried register and a forward `Jcc` around an update of one, only under the defined conditions: B and AE after a bit test, E and NE after a bit scan, B, AE, E, NE, BE and A after `LZCNT` and `TZCNT`, all sixteen after `POPCNT` and a shift by 1, and all but O, NO, L, GE, LE and G after a larger shift. - **Refused controls.** A register bit offset into memory, `SETZ` after `BT`, `SETS` after `LZCNT`, `SETC` after `BSF`, `SETC` after an 8-bit `SHL` by 8 and `SETO` after `SHR` by 3; each must be refused with the translator's reason. - **Host check.** A native export, the same CPUID code as `host_bit_counts` in `tests/cpu/switch_bit_counts.asm`, is called first; without POPCNT, BMI1 and ABM the test is skipped (exit 77), as `cpu_aot_switch_bit_counts` is. It is the only generic change: `Function.host_features` marks such a probe, which is exported but never translated or compared; the other areas set no probe, so their filters select the same functions as before. - **Planted error.** `translate --mutant` (`set_reset_swap`) makes `BTS` clear the selected bit and `BTR` set it; CF, `BT` and `BTC` stay right. `check --mutant` runs it against native, and the test fails if it never differs. - **Existing tests.** The emitted MASM and `.def` of the eight existing areas (at their default seed and one longer seed each), and their clean and mutant translations in dev and release, are byte-identical to `main`. ## Measurements Commit `f5edebc` on `b4c961c`. Intel Core i7-10700 (POPCNT, BMI1, ABM), Windows 11 build 26200, MSVC 19.44.35230, CMake/Ninja, Python 3.12. ```powershell ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_bits$' -V ``` ``` area=bits seed=0xb175 functions=40 inputs=313 comparisons=25040 default and /O2 matched controls refused: fuzz_bits_refused_bit_string (unsupported bit-string operand), fuzz_bits_refused_test_zero (only CF is defined after BT), fuzz_bits_refused_count_sign (OF, SF and PF are undefined after LZCNT), fuzz_bits_refused_scan_carry (only ZF is defined after BSF), fuzz_bits_refused_shift_width (CF is undefined for SHL and SHR), fuzz_bits_refused_shift_overflow (OF is undefined after a shift by more than 1) mutant set_reset_swap: 11581/12520 mismatches in 37/40 functions ``` | Preset | Runs | `cpu_aot_fuzz_bits` | | --- | ---: | ---: | | dev | 3 | 0.71–0.81 s | | release | 3 | 0.71–0.84 s | Default seed contents, counted from the emitted MASM: 154 bit tests (66 on memory, 31 with a register offset, 21 with an immediate offset past the width), 57 counts, 54 scans, 57 byte swaps (33 at 32 bits, 24 at 64) and 63 shifts, read by 331 `SETcc`, 160 `CMOVcc` and 143 `Jcc`. Replaying the sources on the 313 inputs, 5,515 of 16,902 scans and 2,982 of 10,016 `LZCNT` and `TZCNT` calls have a zero source. The three exports the mutant leaves equal to native have no `BTS` or `BTR`. Failure paths, run by hand against the dev build: - **Mutant passed as the translation.** Exit 1 at `fuzz_bits_0` input 0 (native RAX `0x1231f1d`, translated `0x1231f1f`; first differing byte at output offset 16, the step's `BTS`), with the MASM and the `reproduce:` line. That command repeats the case; with the clean translation it exits 0. - **Clean translation passed as `--mutant`.** Exit 1, `the planted translator fault was not detected`. - **Capability skip.** With a probe mask this processor cannot report, the check exits 77 with `capability skip: ...`. Longer manual run: `cmake --preset dev -DCPU_FUZZ_BITS_SEED=<seed> -DCPU_FUZZ_BITS_FUNCTIONS=128`, then the same test (on `9ffb852`; `0xCCD1` also on `f58d242`, with the same counts). | Seed | Exports | Comparisons | Time | Refusals | Mismatches | Mutant mismatches | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | `0x1` | 128 | 80,128 | 2.53 s | 0 | 0 | 33,178/40,064 | | `0x2` | 128 | 80,128 | 1.96 s | 0 | 0 | 35,056/40,064 | | `0xBEEF` | 128 | 80,128 | 1.99 s | 0 | 0 | 33,804/40,064 | | `0xCCD1` | 128 | 80,128 | 1.93 s | 0 | 0 | 34,117/40,064 | Wider checks: - `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_'` and the same with `--preset release`: 9/9 pass. - `ctest --preset dev --no-tests=error -R '^cpu_'` after a full dev build on `f58d242`: 258/258 pass, with 3 capability skips (`cpu_aot_switch_fsgsbase_rdpid`, `cpu_aot_fences_hints_clwb`, `cpu_aot_crypto_sha`). The commits since touch no CPU tool, CPU test or fuzz block. - `tests/docs_links_check.py` (17 files, 367 links), `tests/bidi_controls_check.py` and `git diff --check` pass. Not run: MSVC 19.5x, Linux, an AMD processor, a host without BMI1 or ABM (the skip was only simulated), more than 128 exports. ## Scope Leaf functions only. 16-bit `BSWAP` (refused: its result is undefined), shifts by CL, rotates as flag producers, `SHLD` and `SHRD`, and the BMI1 and BMI2 forms beyond `LZCNT` and `TZCNT` are not generated. #1667 (x87) touches the same three files; if it lands first, I'll rebase and rerun these checks. `docs/experiments.md` gains a `cpu_aot_fuzz_bits` paragraph after the `loops` one. AI-assisted.
tedin7 commented 2026-11-24 19:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:56:57Z.

Review: COMMENTED


Peer review of head f5edebc41582022943f797c47827353ae230b30c.

Result: no P1/P2 defects found in the local verification.

Read the full diff (CMakeLists.txt, docs/experiments.md, tools/fuzz_cpu.py) and checked:

  • Output buffer layout: step qwords end at offset 79 (below the bit string at 128), flag bytes stay in 192..211, final registers at 224..247, all inside the 256-byte buffer.
  • Flag consumers: each reader only uses conditions the translator defines for its producer (CF after BT, ZF after BSF/BSR, CF/ZF after LZCNT/TZCNT, all after POPCNT and shift by 1, no O/L/GE/LE/G after a larger shift). Jump labels are unique per step.
  • Host probe: CPUID.1:ECX bit 23 (POPCNT), CPUID.7:EBX bit 3 (BMI1), CPUID.80000001:ECX bit 5 (ABM) are the right bits, and leaf 7 and the extended leaf are guarded by the max-leaf checks. The probe is excluded from translation and comparison, and the skip uses exit 77 matched by SKIP_RETURN_CODE.
  • CMake follows the same pattern as the loops area (emit, translate, lifted, mutant, /O2 build, test).

Win2025 (log from the coordinator run at this head), Debug dev and Release /O2: build of cpu_fuzz_bits, cpu_fuzz_bits_lifted, cpu_fuzz_bits_lifted_o2 and cpu_fuzz_bits_mutant succeeded; ctest -R '^cpu_aot_fuzz_bits$' passed 1/1 in both presets.

Linux checks run locally in a clean worktree at this head:

  • git diff --check origin/main...HEAD: clean
  • tests/docs_links_check.py: passed (17 Markdown files, 367 links)
  • tests/bidi_controls_check.py: passed (1304 files)
  • python -B -m py_compile tools/fuzz_cpu.py: passed
  • fuzz_cpu.py emit 0xB175 40 ... --area bits run twice: .asm and .def are byte-identical; seed 0x1 gives a different .asm; --area loops emit still works.
  • Independent static check of the emitted bits .asm (638 flag readers): every reader uses a condition allowed for its producer. The only hits were the two intended refused controls (sets, seto).

Mutation (local, reverted afterwards): adding "e" to BITS_CONDITIONS["test"] made the emitted sources contain many ZF readers after bit tests, and the static check above flagged them all (exit 1). The tree was restored with git checkout -- . and is clean. The translator-side planted fault (set_reset_swap) is exercised by the Win2025 run, where the test requires the mutant to differ from native.

Non-blocking note: the docs state that a scan of a zero source leaves the whole destination register unchanged, upper half included. That is the behavior on the Win2025 host, but vendors differ on how a 32-bit scan treats the upper half, so the comparison could differ on other processors. Worth a sentence in the docs.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045438017 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1784#pullrequestreview-6045438017). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:56:57Z. **Review:** COMMENTED --- Peer review of head `f5edebc41582022943f797c47827353ae230b30c`. **Result: no P1/P2 defects found in the local verification.** Read the full diff (CMakeLists.txt, docs/experiments.md, tools/fuzz_cpu.py) and checked: - Output buffer layout: step qwords end at offset 79 (below the bit string at 128), flag bytes stay in 192..211, final registers at 224..247, all inside the 256-byte buffer. - Flag consumers: each reader only uses conditions the translator defines for its producer (CF after BT, ZF after BSF/BSR, CF/ZF after LZCNT/TZCNT, all after POPCNT and shift by 1, no O/L/GE/LE/G after a larger shift). Jump labels are unique per step. - Host probe: CPUID.1:ECX bit 23 (POPCNT), CPUID.7:EBX bit 3 (BMI1), CPUID.80000001:ECX bit 5 (ABM) are the right bits, and leaf 7 and the extended leaf are guarded by the max-leaf checks. The probe is excluded from translation and comparison, and the skip uses exit 77 matched by SKIP_RETURN_CODE. - CMake follows the same pattern as the loops area (emit, translate, lifted, mutant, /O2 build, test). Win2025 (log from the coordinator run at this head), Debug `dev` and Release `/O2`: build of cpu_fuzz_bits, cpu_fuzz_bits_lifted, cpu_fuzz_bits_lifted_o2 and cpu_fuzz_bits_mutant succeeded; `ctest -R '^cpu_aot_fuzz_bits$'` passed 1/1 in both presets. Linux checks run locally in a clean worktree at this head: - `git diff --check origin/main...HEAD`: clean - `tests/docs_links_check.py`: passed (17 Markdown files, 367 links) - `tests/bidi_controls_check.py`: passed (1304 files) - `python -B -m py_compile tools/fuzz_cpu.py`: passed - `fuzz_cpu.py emit 0xB175 40 ... --area bits` run twice: .asm and .def are byte-identical; seed 0x1 gives a different .asm; `--area loops` emit still works. - Independent static check of the emitted bits .asm (638 flag readers): every reader uses a condition allowed for its producer. The only hits were the two intended refused controls (`sets`, `seto`). Mutation (local, reverted afterwards): adding `"e"` to `BITS_CONDITIONS["test"]` made the emitted sources contain many ZF readers after bit tests, and the static check above flagged them all (exit 1). The tree was restored with `git checkout -- .` and is clean. The translator-side planted fault (`set_reset_swap`) is exercised by the Win2025 run, where the test requires the mutant to differ from native. Non-blocking note: the docs state that a scan of a zero source leaves the whole destination register unchanged, upper half included. That is the behavior on the Win2025 host, but vendors differ on how a 32-bit scan treats the upper half, so the comparison could differ on other processors. Worth a sentence in the docs. AI-assisted; commands listed were executed locally.
stan495 commented 2026-11-25 06:01:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:48:18Z.

Review: APPROVED


Verified head f5edebc4 on Windows x64 (dev preset, MSVC 19.44.35228.0, Python 3.12).

  • cmake --build --preset dev --target cpu_fuzz_bits cpu_fuzz_bits_lifted cpu_fuzz_bits_lifted_o2 cpu_fuzz_bits_mutant -> succeeded
  • ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_bits$' -V -> 1/1 passed

Verdict: Approved at f5edebc4.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052477312 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1784#pullrequestreview-6052477312). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T05:48:18Z. **Review:** APPROVED --- Verified head `f5edebc4` on Windows x64 (`dev` preset, MSVC `19.44.35228.0`, Python 3.12). - `cmake --build --preset dev --target cpu_fuzz_bits cpu_fuzz_bits_lifted cpu_fuzz_bits_lifted_o2 cpu_fuzz_bits_mutant` -> succeeded - `ctest --preset dev --no-tests=error -R '^cpu_aot_fuzz_bits$' -V` -> 1/1 passed Verdict: Approved at `f5edebc4`.
tedin7 commented 2026-11-25 19:03:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:03:25Z.

Review: COMMENTED


Review of head b1bb4224 against main. Verdict: one blocking finding, the new test fails on this head.

Blocking: the bit_string refused control is stale.

  • tools/fuzz_cpu.py:1599 expects bt DWORD PTR [r8], ecx to be refused with unsupported bit-string operand.
  • #2031 (register-indexed memory bit tests, already in this head) now lowers a register-bit-offset test on a plain non-frame, non-RIP, 64-bit-base memory operand. It only refuses frame-resident, RIP/EIP-based or 32-bit-base operands (tools/cpu_switch_aot.py:1268-1272).
  • Result on Windows Server 2025 WARP (dev, ctest --preset dev -R cpu_aot_fuzz_bits): fuzz_bits_refused_bit_string was translated; expected refusal: unsupported bit-string operand, test FAILED (the area=bits ... default and /O2 matched line is printed, so only the refused-control part breaks).
  • Fix: change the control to an operand that is still refused, for example a RIP-relative or 32-bit base register ([r8d]) or a frame-resident base, and keep the expected message. Then re-run; the other five refused controls and the planted fault were not reported as failing.

Other checks:

  • Existing areas stay unchanged: emit output for leaf, frames, loops, scalar_fp and switches is byte-identical between main and this head (seed 0x1234, 20 exports); the bits area is deterministic for seed 0xB175.
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean.
  • Note for the author: the Win2025 helper's default target list does not include the *_lifted_o2 custom targets, so a bare win2025 run of the fuzz tests fails on a missing DLL for every area; I built the bits targets explicitly (cpu_fuzz_bits, _lifted, _mutant, _lifted_o2).
  • No other open PR covers the bits area; #1667 (x87) is a different area but edits the same table and CMakeLists.txt region, so the second one to land will need a merge.

Not merged. Happy to re-run on Win2025 once the control is updated.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063357932 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1784#pullrequestreview-6063357932). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:03:25Z. **Review:** COMMENTED --- Review of head b1bb4224 against main. Verdict: one blocking finding, the new test fails on this head. **Blocking: the `bit_string` refused control is stale.** - `tools/fuzz_cpu.py:1599` expects `bt DWORD PTR [r8], ecx` to be refused with `unsupported bit-string operand`. - #2031 (register-indexed memory bit tests, already in this head) now lowers a register-bit-offset test on a plain non-frame, non-RIP, 64-bit-base memory operand. It only refuses frame-resident, RIP/EIP-based or 32-bit-base operands (`tools/cpu_switch_aot.py:1268-1272`). - Result on Windows Server 2025 WARP (dev, `ctest --preset dev -R cpu_aot_fuzz_bits`): `fuzz_bits_refused_bit_string was translated; expected refusal: unsupported bit-string operand`, test FAILED (the `area=bits ... default and /O2 matched` line is printed, so only the refused-control part breaks). - Fix: change the control to an operand that is still refused, for example a RIP-relative or 32-bit base register (`[r8d]`) or a frame-resident base, and keep the expected message. Then re-run; the other five refused controls and the planted fault were not reported as failing. Other checks: - Existing areas stay unchanged: `emit` output for leaf, frames, loops, scalar_fp and switches is byte-identical between main and this head (seed 0x1234, 20 exports); the bits area is deterministic for seed 0xB175. - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean. - Note for the author: the Win2025 helper's default target list does not include the `*_lifted_o2` custom targets, so a bare `win2025` run of the fuzz tests fails on a missing DLL for every area; I built the bits targets explicitly (`cpu_fuzz_bits`, `_lifted`, `_mutant`, `_lifted_o2`). - No other open PR covers the bits area; #1667 (x87) is a different area but edits the same table and `CMakeLists.txt` region, so the second one to land will need a merge. Not merged. Happy to re-run on Win2025 once the control is updated. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 20:04:01 +00:00
roansystemlabs commented 2026-11-25 20:04:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T19:25:18Z.


Thanks for catching this. #2031 lowers BT with a register offset on a plain 64-bit base, so the control was stale.

I rebased the branch onto main at 32a2e2f6f as one commit (it also merges cleanly with the current e2faf858c). The conflicts with #1667 were only adjacent insertions (the AREAS and MUTANTS tables, the generator block, the CMake region and the docs paragraph), and both areas are kept. The control now uses a 32-bit base, which cpu_switch_aot.py still refuses with the same message:

-    "bit_string": (["bt DWORD PTR [r8], ecx", "setc al"], "unsupported bit-string operand"),
+    "bit_string": (["bt DWORD PTR [r8d], ecx", "setc al"], "unsupported bit-string operand"),

The docs now name the control as a register bit offset through a 32-bit base register.

Run on Windows 11 x64, MSVC 19.44, dev and release:

  • cmake --build --preset <preset> --target cpu_fuzz_bits cpu_fuzz_bits_lifted cpu_fuzz_bits_mutant cpu_fuzz_bits_lifted_o2: succeeded
  • ctest --preset <preset> --no-tests=error -R '^cpu_aot_fuzz_bits$' -V: 1/1 passed in both; 25,040 comparisons matched, all six controls refused for their own reason, the planted fault differed in 11,581 of 12,520 calls
  • With the old [r8] control on the same base, dev fails exactly as you reported (fuzz_bits_refused_bit_string was translated)
  • emit for the other nine areas is byte-identical to main; the bits emit only changes that one line
  • tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean

Thanks also for the offer to re-run on Win2025; that would be welcome.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172271910 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1784#issuecomment-7172271910). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T19:25:18Z. --- Thanks for catching this. #2031 lowers `BT` with a register offset on a plain 64-bit base, so the control was stale. I rebased the branch onto main at `32a2e2f6f` as one commit (it also merges cleanly with the current `e2faf858c`). The conflicts with #1667 were only adjacent insertions (the `AREAS` and `MUTANTS` tables, the generator block, the CMake region and the docs paragraph), and both areas are kept. The control now uses a 32-bit base, which `cpu_switch_aot.py` still refuses with the same message: ```diff - "bit_string": (["bt DWORD PTR [r8], ecx", "setc al"], "unsupported bit-string operand"), + "bit_string": (["bt DWORD PTR [r8d], ecx", "setc al"], "unsupported bit-string operand"), ``` The docs now name the control as a register bit offset through a 32-bit base register. Run on Windows 11 x64, MSVC 19.44, `dev` and `release`: - `cmake --build --preset <preset> --target cpu_fuzz_bits cpu_fuzz_bits_lifted cpu_fuzz_bits_mutant cpu_fuzz_bits_lifted_o2`: succeeded - `ctest --preset <preset> --no-tests=error -R '^cpu_aot_fuzz_bits$' -V`: 1/1 passed in both; 25,040 comparisons matched, all six controls refused for their own reason, the planted fault differed in 11,581 of 12,520 calls - With the old `[r8]` control on the same base, `dev` fails exactly as you reported (`fuzz_bits_refused_bit_string was translated`) - `emit` for the other nine areas is byte-identical to main; the bits emit only changes that one line - `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean Thanks also for the offer to re-run on Win2025; that would be welcome. AI-assisted.
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!1777
No description provided.