runtime: define the memory-transfer contract for startup #928

Merged
Holastor merged 2 commits from upstream-pr/935 into main 2026-11-23 18:19:57 +00:00
Holastor commented 2026-11-23 17:52:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T17:52:30Z.


Summary

Establishes the source-built contract fixture for xmem.dll!XMemTransferMemory following the slice claim on #870 and the pattern from #902.

Fixture and Controls

  • Source-built caller (tests/cpu/transfer_mem_caller.asm):
    • Starts through tests/cpu/exe_startup.asm and calls finish_exe from cpu_exe_io.dll.
    • Step 1: Valid 2 MiB transfer under partition 1 (rcx = 1, rdx = 0x200000), verifying return value 1.
    • Step 2: Valid 16 MiB transfer under partition 1 (rcx = 1, rdx = 0x1000000), verifying return value 1.
    • Step 3: Rejection control for invalid partition (rcx = 0), returning 0.
    • Step 4: Rejection control for zero byte count (rdx = 0), returning 0.
    • Step 5: Rejection control for unaligned byte count (rdx = 0x200100), returning 0.
    • Step 6: Rejection control for oversized byte count (rdx = 0x2000000), returning 0.
    • Step 7: Internal verification of provider call counts (2 valid, 4 rejections) and recorded parameters directly within the caller process.
  • Recording provider (tests/cpu/transfer_mem_provider.cpp):
    • Records valid transfers (recorded_partition, recorded_bytes).
    • Tracks valid call counts and rejection counts via interlocked operations.
  • Test harness (tests/cpu/transfer_mem_check.py):
    • Native Windows execution under standard environment and with CPU_CRC_TEST_LIVE_WORKER=1 (clean exit with code 0x870).
    • Mapped execution under tools/pe_map.cpp (clean host return with code 0x870).
    • Independent withholding control: confirms pe_map stops before entry with STATUS["unresolved"] naming xmem.dll!XMemTransferMemory.

Verification

cmake --preset dev
cmake --build --preset dev --target cpu_transfer_mem_caller cpu_transfer_mem_provider
ctest --preset dev --no-tests=error -R '^cpu_native_transfer_mem$' -V
ctest --preset release --no-tests=error -R '^cpu_native_transfer_mem$' -V
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
python -B tests/form_coverage_check.py
python -B tests/hardware_reports_check.py

Observed: 1/1 passed in dev (0.17s) and 1/1 passed in release (0.16s). All linters passed.

Refs #870

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6565441393 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/935). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T17:52:30Z. --- ### Summary Establishes the source-built contract fixture for `xmem.dll!XMemTransferMemory` following the slice claim on #870 and the pattern from #902. ### Fixture and Controls - **Source-built caller** (`tests/cpu/transfer_mem_caller.asm`): - Starts through `tests/cpu/exe_startup.asm` and calls `finish_exe` from `cpu_exe_io.dll`. - Step 1: Valid 2 MiB transfer under partition 1 (`rcx = 1`, `rdx = 0x200000`), verifying return value `1`. - Step 2: Valid 16 MiB transfer under partition 1 (`rcx = 1`, `rdx = 0x1000000`), verifying return value `1`. - Step 3: Rejection control for invalid partition (`rcx = 0`), returning `0`. - Step 4: Rejection control for zero byte count (`rdx = 0`), returning `0`. - Step 5: Rejection control for unaligned byte count (`rdx = 0x200100`), returning `0`. - Step 6: Rejection control for oversized byte count (`rdx = 0x2000000`), returning `0`. - Step 7: Internal verification of provider call counts (2 valid, 4 rejections) and recorded parameters directly within the caller process. - **Recording provider** (`tests/cpu/transfer_mem_provider.cpp`): - Records valid transfers (`recorded_partition`, `recorded_bytes`). - Tracks valid call counts and rejection counts via interlocked operations. - **Test harness** (`tests/cpu/transfer_mem_check.py`): - Native Windows execution under standard environment and with `CPU_CRC_TEST_LIVE_WORKER=1` (clean exit with code `0x870`). - Mapped execution under `tools/pe_map.cpp` (clean host return with code `0x870`). - Independent withholding control: confirms `pe_map` stops before entry with `STATUS["unresolved"]` naming `xmem.dll!XMemTransferMemory`. ### Verification ```powershell cmake --preset dev cmake --build --preset dev --target cpu_transfer_mem_caller cpu_transfer_mem_provider ctest --preset dev --no-tests=error -R '^cpu_native_transfer_mem$' -V ctest --preset release --no-tests=error -R '^cpu_native_transfer_mem$' -V python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py python -B tests/form_coverage_check.py python -B tests/hardware_reports_check.py ``` Observed: 1/1 passed in dev (0.17s) and 1/1 passed in release (0.16s). All linters passed. Refs #870
upstream-sync closed this pull request 2026-11-24 06:45:29 +00:00
R0Y00 commented 2026-11-24 06:49:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:56:57Z.


The six source-built calls and missing-export control give us a good recorder starting point. I found a gap in the trace assertion: the provider keeps only the most recent accepted arguments, so changing the first 2 MiB request to 4 MiB still satisfies both counters and the final 16 MiB check. Could you record and compare all six ordered argument pairs, including the rejected calls, and add that changed-first-call control? Please also label selector 1, alignment, maximum and BOOL as test-provider policy throughout. The fixture should leave the native transfer and partition effect open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7109420324 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/935#issuecomment-7109420324). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T17:56:57Z. --- The six source-built calls and missing-export control give us a good recorder starting point. I found a gap in the trace assertion: the provider keeps only the most recent accepted arguments, so changing the first 2 MiB request to 4 MiB still satisfies both counters and the final 16 MiB check. Could you record and compare all six ordered argument pairs, including the rejected calls, and add that changed-first-call control? Please also label selector 1, alignment, maximum and BOOL as test-provider policy throughout. The fixture should leave the native transfer and partition effect open.
Holastor commented 2026-11-24 06:49:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T18:03:56Z.


Updated in 51ad45b:

  • Ordered argument pairs: transfer_mem_provider.cpp now records all six calls in sequence (CallRecord { partition, bytes, result }), capturing both accepted and rejected requests.
  • Trace verification: transfer_mem_check.py verifies all six ordered pairs and outcomes against expected values:
    1. Call 0: partition 1, 2 MiB (0x200000), result 1
    2. Call 1: partition 1, 16 MiB (0x1000000), result 1
    3. Call 2: partition 0, 2 MiB (0x200000), result 0
    4. Call 3: partition 1, 0 bytes, result 0
    5. Call 4: partition 1, unaligned 0x200100, result 0
    6. Call 5: partition 1, oversized 0x2000000, result 0
  • Changed-first-call control: Added a control that patches the first request in the binary from 2 MiB to 4 MiB. The caller's internal trace check rejects it under both loaders with exit code 0xF0B, and the recorded trace verifies 4 MiB in call 0.
  • Test-provider policy labeling: Partition selector 1, 2 MiB alignment, the 16 MiB maximum boundary, and BOOL return semantics are explicitly labeled as test-provider policy throughout transfer_mem_provider.cpp, transfer_mem_check.py, and docs/experiments.md. Native console transfer semantics and partition effects remain open.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7109597915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/935#issuecomment-7109597915). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T18:03:56Z. --- Updated in `51ad45b`: - **Ordered argument pairs**: `transfer_mem_provider.cpp` now records all six calls in sequence (`CallRecord { partition, bytes, result }`), capturing both accepted and rejected requests. - **Trace verification**: `transfer_mem_check.py` verifies all six ordered pairs and outcomes against expected values: 1. Call 0: partition 1, 2 MiB (`0x200000`), result 1 2. Call 1: partition 1, 16 MiB (`0x1000000`), result 1 3. Call 2: partition 0, 2 MiB (`0x200000`), result 0 4. Call 3: partition 1, 0 bytes, result 0 5. Call 4: partition 1, unaligned `0x200100`, result 0 6. Call 5: partition 1, oversized `0x2000000`, result 0 - **Changed-first-call control**: Added a control that patches the first request in the binary from 2 MiB to 4 MiB. The caller's internal trace check rejects it under both loaders with exit code `0xF0B`, and the recorded trace verifies 4 MiB in call 0. - **Test-provider policy labeling**: Partition selector 1, 2 MiB alignment, the 16 MiB maximum boundary, and `BOOL` return semantics are explicitly labeled as test-provider policy throughout `transfer_mem_provider.cpp`, `transfer_mem_check.py`, and `docs/experiments.md`. Native console transfer semantics and partition effects remain open.
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!928
No description provided.