cpu: select BC7 storage ranges from a bounded guest directory #1338

Merged
R0Y00 merged 1 commit from upstream-pr/1345 into main 2026-11-24 09:05:40 +00:00
R0Y00 commented 2026-11-24 08:47:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:47:57Z.


Refs #1198 and #870. Follows #1331.

Let the compiler-built guest select both requests from a raw file prefix of up to 64 KiB. It validates the RDS5 directory and both logical pages, binary-searches for each requested record, and computes its source range. Queue creation and submission remain in the existing Windows provider. The guest's lookup function has an explicit PE export so the AOT verifier can identify the leaf function.

The three runners use the same underlying files. The controls distinguish three ways to get the same incorrect first half of the BC7 frame:

  • Opening the alternate file changes the Windows file-object identity. Its directory entries and request ranges match the original file.
  • Selecting the equal-length decoy in the original file reports directory entry 3585.
  • Shifting the correct entry's offset by 896 KiB reports entry 1 but reads the same bytes as entry 3585.

The ordinary two-page batch also selects entry 2 then jumps to entry 3585. Two ETPF metadata sizes change the absolute start of the compressed data. An oversized count, an out-of-file terminal boundary, and an unavailable second page each return 3 before the provider creates the queue. Moving only the first physical offset to EOF returns 6, leaves that page untouched and completes the second request.

Windows 11 build 26200.9974 x64, Release 4f3f79a2, RTX 4060 Laptop GPU 32.0.16.1656 and WARP 10.0.26100.9818. Native PE, mapped PE and AOT: 108 runs, 60 complete RGBA frames, 12 queue EOF controls, 36 pre-enqueue rejections and no capability skips. Existing reader, texture publication and directory queue regressions passed. Documentation checker verified 299 links.

cmake --build --preset release --target archive_directory_lifted pe_map archive_reader_lifted archive_texture_lifted startup_stub_consumer startup_stub_xcrdapi
ctest --preset release --no-tests=error --output-on-failure -R '^(cpu_archive_directory_gpu_(warp|hardware)|cpu_native_archive_reader|cpu_archive_texture_publication|startup_storage_directory_batch)$'

The fixture accepts a whole single-page zlib interval for each requested logical page. Its failure controls leave the separate production offset-source question in #1198 open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6578018261 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1345). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:47:57Z. --- Refs #1198 and #870. Follows #1331. Let the compiler-built guest select both requests from a raw file prefix of up to 64 KiB. It validates the RDS5 directory and both logical pages, binary-searches for each requested record, and computes its source range. Queue creation and submission remain in the existing Windows provider. The guest's lookup function has an explicit PE export so the AOT verifier can identify the leaf function. The three runners use the same underlying files. The controls distinguish three ways to get the same incorrect first half of the BC7 frame: - Opening the alternate file changes the Windows file-object identity. Its directory entries and request ranges match the original file. - Selecting the equal-length decoy in the original file reports directory entry 3585. - Shifting the correct entry's offset by 896 KiB reports entry 1 but reads the same bytes as entry 3585. The ordinary two-page batch also selects entry 2 then jumps to entry 3585. Two ETPF metadata sizes change the absolute start of the compressed data. An oversized count, an out-of-file terminal boundary, and an unavailable second page each return 3 before the provider creates the queue. Moving only the first physical offset to EOF returns 6, leaves that page untouched and completes the second request. Windows 11 build 26200.9974 x64, Release 4f3f79a2, RTX 4060 Laptop GPU 32.0.16.1656 and WARP 10.0.26100.9818. Native PE, mapped PE and AOT: 108 runs, 60 complete RGBA frames, 12 queue EOF controls, 36 pre-enqueue rejections and no capability skips. Existing reader, texture publication and directory queue regressions passed. Documentation checker verified 299 links. ```powershell cmake --build --preset release --target archive_directory_lifted pe_map archive_reader_lifted archive_texture_lifted startup_stub_consumer startup_stub_xcrdapi ctest --preset release --no-tests=error --output-on-failure -R '^(cpu_archive_directory_gpu_(warp|hardware)|cpu_native_archive_reader|cpu_archive_texture_publication|startup_storage_directory_batch)$' ``` The fixture accepts a whole single-page zlib interval for each requested logical page. Its failure controls leave the separate production offset-source question in #1198 open.
tedin7 commented 2026-11-24 08:52:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:52:44Z.

Review: COMMENTED


Technical peer review at commit 4f3f79a23178922dc4b9b1538123ee2cada3f6c2 (LGTM, no blocking findings):

Code audit:

  • tests/cpu/archive/directory_reader.zig: validate checks the 16-byte header, RDS5 magic, entry count bounds against both input.bytes and the entry-0 metadata boundary, strictly increasing logical/physical offsets, and terminal physical/logical bounds against file_size and words[1]. locate binary-searches safely within [0, count - 1], rejects non-zlib/multi-page/zero-or-overflowing spans, and uses entry 0 as a safe sentinel (validated as compression type 0). queueRecord checks @addWithOverflow(start, bias) before calling enqueue_page.
  • tests/cpu/archive/directory_gpu.cpp & tests/cpu/archive_directory_gpu_check.py: _setmode(_fileno(stdin), _O_BINARY) avoids text-mode translation on binary stdin; begin_batch logs the file-object ID (nFileIndexHigh/Low) and defers queue creation until enqueue_page, so validation failures exit 3 before any queue/trace/pixel artifacts are created. Negative controls cover invalid count, terminal beyond EOF, missing second, EOF, wrong file, wrong record, and wrong offset.
  • CMakeLists.txt & docs/experiments.md: EXPORT_SYMBOLS (-rdynamic) is cleanly parsed via cmake_parse_arguments; wording is title-neutral.

Checks:

  • Linux: tests/docs_links_check.py (16 Markdown files, 299 links) passed; tests/bidi_controls_check.py (1113 files) passed; git diff --check clean.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, archive_directory_lifted pe_map): cpu_archive_directory_gpu_warp 1/1 passed (10.34s).
    • Release /O2 (--preset release, archive_directory_lifted pe_map): cpu_archive_directory_gpu_warp 1/1 passed (9.82s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036211801 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1345#pullrequestreview-6036211801). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:52:44Z. **Review:** COMMENTED --- Technical peer review at commit `4f3f79a23178922dc4b9b1538123ee2cada3f6c2` (LGTM, no blocking findings): **Code audit:** - `tests/cpu/archive/directory_reader.zig`: `validate` checks the 16-byte header, `RDS5` magic, entry count bounds against both `input.bytes` and the entry-0 metadata boundary, strictly increasing logical/physical offsets, and terminal physical/logical bounds against `file_size` and `words[1]`. `locate` binary-searches safely within `[0, count - 1]`, rejects non-zlib/multi-page/zero-or-overflowing spans, and uses entry `0` as a safe sentinel (validated as compression type `0`). `queueRecord` checks `@addWithOverflow(start, bias)` before calling `enqueue_page`. - `tests/cpu/archive/directory_gpu.cpp` & `tests/cpu/archive_directory_gpu_check.py`: `_setmode(_fileno(stdin), _O_BINARY)` avoids text-mode translation on binary stdin; `begin_batch` logs the file-object ID (`nFileIndexHigh`/`Low`) and defers queue creation until `enqueue_page`, so validation failures exit `3` before any queue/trace/pixel artifacts are created. Negative controls cover `invalid count`, `terminal beyond EOF`, `missing second`, `EOF`, `wrong file`, `wrong record`, and `wrong offset`. - `CMakeLists.txt` & `docs/experiments.md`: `EXPORT_SYMBOLS` (`-rdynamic`) is cleanly parsed via `cmake_parse_arguments`; wording is title-neutral. **Checks:** - **Linux**: `tests/docs_links_check.py` (16 Markdown files, 299 links) passed; `tests/bidi_controls_check.py` (1113 files) passed; `git diff --check` clean. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `archive_directory_lifted pe_map`): `cpu_archive_directory_gpu_warp` **1/1 passed** (`10.34s`). - Release `/O2` (`--preset release`, `archive_directory_lifted pe_map`): `cpu_archive_directory_gpu_warp` **1/1 passed** (`9.82s`).
upstream-sync closed this pull request 2026-11-24 10:02:24 +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!1338
No description provided.