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

Manually merged
github merged 2 commits from gh-pr/935/head into gh-pr/935/base 2026-11-26 22:29:33 +00:00
Owner

@⁠Holastor on GitHub · 2026-11-23 17:52 UTC · original
Holastor:xmem/transfer-memory-contract-fixture → main · +466 −0 · 6 files · 2 commits · merged 2026-11-23 18:19 UTC

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

**@⁠Holastor** on GitHub · 2026-11-23 17:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/935) `Holastor:xmem/transfer-memory-contract-fixture` → `main` · +466 −0 · 6 files · 2 commits · merged 2026-11-23 18:19 UTC ### 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
Add a source-built caller (tests/cpu/transfer_mem_caller.asm) and
recording provider (tests/cpu/transfer_mem_provider.cpp) exercising
the proposed XMemTransferMemory call shape.

The fixture verifies:
- valid 2 MiB and 16 MiB transfers under partition 1;
- negative controls rejecting invalid partition, zero byte count,
  unaligned sizes, and oversized requests exceeding 16 MiB;
- provider call counter and recorded argument verification;
- clean process exit under cpu_exe_io!finish_exe and with
  CPU_CRC_TEST_LIVE_WORKER=1;
- mapped return under tools/pe_map.cpp;
- independent negative control confirming pe_map stops before entry
  when XMemTransferMemory is withheld.

Refs #870
Update tests/cpu/transfer_mem_provider.cpp to record all six ordered
calls (partition, byte count, and outcome) rather than only the last
accepted call.

Add changed-first-call control patching the 2 MiB request in the caller
binary to 4 MiB: verify that both loaders exit with code 0xF0B from the
internal trace assertion and record 4 MiB in call 0.

Explicitly label partition selector 1, 2 MiB alignment, the 16 MiB
maximum boundary, and BOOL return semantics as test-provider policy
throughout the provider, test harness, and docs/experiments.md, leaving
native console transfer semantics and partition effects open.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:29:31 +00:00
github manually merged commit 51ad45bb65 into gh-pr/935/base 2026-11-26 22:29:33 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 17:56 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-23 17:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/935#issuecomment-7109420324) 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.
Author
Owner

@⁠Holastor on GitHub · 2026-11-23 18:03 UTC · original

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.
**@⁠Holastor** on GitHub · 2026-11-23 18:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/935#issuecomment-7109597915) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.