test: refuse a GPU virtual address floor of 16 bits #1720

Merged
ChazY11 merged 1 commit from upstream-pr/1727 into main 2026-11-24 18:08:21 +00:00
ChazY11 commented 2026-11-24 17:53:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T17:53:50Z.


What

src/d3d12_xs_range.cpp refuses a device whose MaxGPUVirtualAddressBitsPerResource is below 17:

if (va.MaxGPUVirtualAddressBitsPerResource < 17) return E_FAIL;

The device-free check (tests/d3d12_xs_range_check.cpp) exercises the boundary from above — a fake device reporting
17 bits creates the range — but never below it. Lowering the floor to 16 leaves the fixture green, so an adapter that
reports 16 bits would receive a range whose windows it cannot address, with nothing to notice.

Change

One case below the floor, next to the existing 17-bit case: a fake device with 16 bits must produce E_FAIL, leave the
out pointer untouched, and create no window.

+        // One bit below the floor the range refuses instead of creating a window it cannot address.
+        {
+            Fixture below(16);
+            IX2WGpuRange* refused_range = reinterpret_cast<IX2WGpuRange*>(std::uintptr_t{1});
+            expect(d3d12_xs_range::create(below.get(), 3 * tile, &refused_range, create_window) == E_FAIL &&
+                       !refused_range && requests.empty() && live_windows == 0,
+                   "16 bits: the range is refused before a window is created");
+        }

requests.empty() is the part that distinguishes "refused up front" from "refused after the first window", and the
sentinel output checks that a failure does not hand back a range.

Tested

cmake --preset dev
cmake --build --preset dev --target d3d12_xs_range_check
ctest --preset dev --no-tests=error -R '^d3d12_xs_range' -V
with the case, floor left at 17            d3d12_xs_range Passed, d3d12_xs_range_full_last_window_control Passed
with the case, floor changed to 16         d3d12_xs_range FAILED   (rebuilt; binary timestamp checked)
reverted, rebuilt                          both Passed

The mutant run is the negative control: the point of the case is that it fails when the guard is weakened.

Scope

One test file, no behaviour change. The two other guards in create (the UINT and max_size window-count check, and
the range's own QueryInterface IID check) are also unwitnessed by this fixture; I left them alone to keep this to one
behaviour, and can send them separately if you want the whole function covered.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588054820 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1727). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:53:50Z. --- ## What `src/d3d12_xs_range.cpp` refuses a device whose `MaxGPUVirtualAddressBitsPerResource` is below 17: ```cpp if (va.MaxGPUVirtualAddressBitsPerResource < 17) return E_FAIL; ``` The device-free check (`tests/d3d12_xs_range_check.cpp`) exercises the boundary from above — a fake device reporting **17** bits creates the range — but never below it. Lowering the floor to 16 leaves the fixture green, so an adapter that reports 16 bits would receive a range whose windows it cannot address, with nothing to notice. ## Change One case below the floor, next to the existing 17-bit case: a fake device with 16 bits must produce `E_FAIL`, leave the out pointer untouched, and create no window. ```diff + // One bit below the floor the range refuses instead of creating a window it cannot address. + { + Fixture below(16); + IX2WGpuRange* refused_range = reinterpret_cast<IX2WGpuRange*>(std::uintptr_t{1}); + expect(d3d12_xs_range::create(below.get(), 3 * tile, &refused_range, create_window) == E_FAIL && + !refused_range && requests.empty() && live_windows == 0, + "16 bits: the range is refused before a window is created"); + } ``` `requests.empty()` is the part that distinguishes "refused up front" from "refused after the first window", and the sentinel output checks that a failure does not hand back a range. ## Tested ```powershell cmake --preset dev cmake --build --preset dev --target d3d12_xs_range_check ctest --preset dev --no-tests=error -R '^d3d12_xs_range' -V ``` ```text with the case, floor left at 17 d3d12_xs_range Passed, d3d12_xs_range_full_last_window_control Passed with the case, floor changed to 16 d3d12_xs_range FAILED (rebuilt; binary timestamp checked) reverted, rebuilt both Passed ``` The mutant run is the negative control: the point of the case is that it fails when the guard is weakened. ## Scope One test file, no behaviour change. The two other guards in `create` (the `UINT` and `max_size` window-count check, and the range's own `QueryInterface` IID check) are also unwitnessed by this fixture; I left them alone to keep this to one behaviour, and can send them separately if you want the whole function covered. ## Notes - AI-assisted.
tedin7 commented 2026-11-24 18:02:50 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Dual-platform verification at commit ed9689bcd6d52d93f8162551093aeec8e9f69c95: 0 blocking issues.

Summary

  • tests/d3d12_xs_range_check.cpp: adds a focused boundary check one bit below the 17-bit MaxGPUVirtualAddressBitsPerResource floor (Fixture below(16)), verifying E_FAIL, nulling of a non-null sentinel out pointer, requests.empty(), and live_windows == 0.
  • Test-only diff (no src/ changes, no weakened assertions).

Verification

  • Linux:
    • git diff --check: passed.
    • python3 tests/docs_links_check.py: passed.
    • python3 tests/bidi_controls_check.py: passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207):
    • Debug (--preset dev): cmake --build --preset dev --target d3d12_xs_range_check -- -j 6 (3.86s); ctest --preset dev -R '^(d3d12_xs_range|d3d12_xs_range_full_last_window_control)$' --parallel 4 --no-tests=error --output-on-failure — 2/2 passed (0.11s).
    • Release /O2 (--preset release): cmake --build --preset release --target d3d12_xs_range_check -- -j 6 (1.32s); ctest --preset release -R '^(d3d12_xs_range|d3d12_xs_range_full_last_window_control)$' --parallel 4 --no-tests=error --output-on-failure — 2/2 passed (0.10s).
  • Mutation check (Win2025 Debug):
    • Weakening va.MaxGPUVirtualAddressBitsPerResource < 17 to < 16 in src/d3d12_xs_range.cpp causes d3d12_xs_range to fail (***Exception: Numerical, divide-by-zero when window == 0), confirming the new 16-bit case catches regressions on the floor guard; reverted cleanly.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044642795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1727#pullrequestreview-6044642795). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:00:23Z. **Review:** COMMENTED --- Dual-platform verification at commit `ed9689bcd6d52d93f8162551093aeec8e9f69c95`: **0 blocking issues**. ### Summary - `tests/d3d12_xs_range_check.cpp`: adds a focused boundary check one bit below the 17-bit `MaxGPUVirtualAddressBitsPerResource` floor (`Fixture below(16)`), verifying `E_FAIL`, nulling of a non-null sentinel out pointer, `requests.empty()`, and `live_windows == 0`. - Test-only diff (no `src/` changes, no weakened assertions). ### Verification - **Linux**: - `git diff --check`: passed. - `python3 tests/docs_links_check.py`: passed. - `python3 tests/bidi_controls_check.py`: passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207)**: - **Debug (`--preset dev`)**: `cmake --build --preset dev --target d3d12_xs_range_check -- -j 6` (`3.86s`); `ctest --preset dev -R '^(d3d12_xs_range|d3d12_xs_range_full_last_window_control)$' --parallel 4 --no-tests=error --output-on-failure` — **2/2 passed** (`0.11s`). - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target d3d12_xs_range_check -- -j 6` (`1.32s`); `ctest --preset release -R '^(d3d12_xs_range|d3d12_xs_range_full_last_window_control)$' --parallel 4 --no-tests=error --output-on-failure` — **2/2 passed** (`0.10s`). - **Mutation check (Win2025 Debug)**: - Weakening `va.MaxGPUVirtualAddressBitsPerResource < 17` to `< 16` in `src/d3d12_xs_range.cpp` causes `d3d12_xs_range` to fail (`***Exception: Numerical`, divide-by-zero when `window == 0`), confirming the new 16-bit case catches regressions on the floor guard; reverted cleanly. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 19:01:07 +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!1720
No description provided.