runtime: test ACP address and memory mapping sequence #993

Merged
Holastor merged 1 commit from upstream-pr/1000 into main 2026-11-23 20:54:35 +00:00
Holastor commented 2026-11-23 20:37:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T20:37:24Z.


Add a source-built caller (tests/cpu/apu_address_caller.asm) and controlled test recording provider (tests/cpu/apu_address_provider.cpp) exercising the ACP address and memory mapping exports from acphal.dll:

  • acphal.dll!ApuAlloc (MIT Microsoft/DirectXTK12 call shape)
  • acphal.dll!ApuFree (MIT Microsoft/DirectXTK12 call shape)
  • acphal.dll!ApuMapVirtualAddress
  • acphal.dll!ApuMapApuAddress
  • acphal.dll!ApuIsVirtualAddressValid

Fixture contract qualification

  • Call shapes and evidence: While ApuAlloc and ApuFree call shapes are taken from public MIT call sites in Microsoft/DirectXTK12 (SoundEffect.cpp, WaveBankReader.cpp, SoundStreamInstance.cpp), the three mapping and query signatures (ApuMapVirtualAddress, ApuMapApuAddress, and ApuIsVirtualAddressValid) and the address translation behavior tested here are the recording provider's fixture contract (proposed test-provider policy) rather than verification against an original or production console provider.
  • Milestone distinction: This milestone establishes that a source-built caller, controlled provider, and loaders (Windows native loader and pe_map) can exercise, record, and verify bidirectional address translation, linear offset preservation, validity query lifecycle, and failure/withholding controls. Verification against an original console provider remains open.

Verified behaviors

  1. Bidirectional mapping identity: ApuMapVirtualAddress translates an allocated CPU virtual pointer to an APU device address (APU_ADDRESS / UINT64), and ApuMapApuAddress translates it back to the exact identical CPU pointer (ApuMapApuAddress(ApuMapVirtualAddress(ptr)) == ptr).
  2. Linear offset preservation: Verified that offsets inside an allocation translate consistently (ApuMapVirtualAddress(ptr + offset) == apu_addr + offset and ApuMapApuAddress(apu_addr + offset) == ptr + offset).
  3. Validity query lifecycle: ApuIsVirtualAddressValid(ptr) returns TRUE (1) while the block is live, and returns FALSE (0) after ApuFree(ptr).
  4. Data access: Memory written through the mapped pointer is verified byte-for-byte upon readback.
  5. Refusal controls: Null pointers, stack addresses, and out-of-range APU addresses are refused (ApuIsVirtualAddressValid returns FALSE, ApuMapVirtualAddress returns 0, ApuMapApuAddress returns nullptr).
  6. Faulty provider negative control: A faulty provider build (APU_TEST_FAULTY) where mapping returns nullptr causes the caller to abort at Step 4 (0xF04).
  7. Withholding negative controls: Withholding any of ApuMapVirtualAddress, ApuMapApuAddress, or ApuIsVirtualAddressValid stops pe_map at import resolution before entry with STATUS["unresolved"] naming the missing export.

Verification

cmake --build --preset dev --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller
ctest --preset dev --no-tests=error -R '^cpu_native_apu_address$' -V
test 321: cpu_native_apu_address ........... Passed (0.18 sec)
caller imports: {'acphal.dll': ['ApuAlloc', 'ApuFree', 'ApuIsVirtualAddressValid', 'ApuMapApuAddress', 'ApuMapVirtualAddress', 'get_apu_unmapped_refusals'], 'cpu_exe_io.dll': ['finish_exe']}
native and mapped exit 0x8a1; all address translation assertions passed
faulty provider: native and mapped exit 0xf04 at Step 4
before entry: unresolved import acphal.dll!ApuMapVirtualAddress
before entry: unresolved import acphal.dll!ApuMapApuAddress
before entry: unresolved import acphal.dll!ApuIsVirtualAddressValid
100% tests passed, 0 tests failed out of 1

Release build:

cmake --build --preset release --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller
ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V
100% tests passed, 0 tests failed out of 1 (0.17 sec)

Documentation and hygiene checks:

.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py

All passed.

Refs #870.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6568340989 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1000). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T20:37:24Z. --- Add a source-built caller (`tests/cpu/apu_address_caller.asm`) and controlled test recording provider (`tests/cpu/apu_address_provider.cpp`) exercising the ACP address and memory mapping exports from `acphal.dll`: - `acphal.dll!ApuAlloc` (MIT Microsoft/DirectXTK12 call shape) - `acphal.dll!ApuFree` (MIT Microsoft/DirectXTK12 call shape) - `acphal.dll!ApuMapVirtualAddress` - `acphal.dll!ApuMapApuAddress` - `acphal.dll!ApuIsVirtualAddressValid` ### Fixture contract qualification - **Call shapes and evidence**: While `ApuAlloc` and `ApuFree` call shapes are taken from public MIT call sites in Microsoft/DirectXTK12 (`SoundEffect.cpp`, `WaveBankReader.cpp`, `SoundStreamInstance.cpp`), the three mapping and query signatures (`ApuMapVirtualAddress`, `ApuMapApuAddress`, and `ApuIsVirtualAddressValid`) and the address translation behavior tested here are the recording provider's **fixture contract** (proposed test-provider policy) rather than verification against an original or production console provider. - **Milestone distinction**: This milestone establishes that a source-built caller, controlled provider, and loaders (Windows native loader and `pe_map`) can exercise, record, and verify bidirectional address translation, linear offset preservation, validity query lifecycle, and failure/withholding controls. Verification against an original console provider remains open. ### Verified behaviors 1. **Bidirectional mapping identity**: `ApuMapVirtualAddress` translates an allocated CPU virtual pointer to an APU device address (`APU_ADDRESS` / `UINT64`), and `ApuMapApuAddress` translates it back to the exact identical CPU pointer (`ApuMapApuAddress(ApuMapVirtualAddress(ptr)) == ptr`). 2. **Linear offset preservation**: Verified that offsets inside an allocation translate consistently (`ApuMapVirtualAddress(ptr + offset) == apu_addr + offset` and `ApuMapApuAddress(apu_addr + offset) == ptr + offset`). 3. **Validity query lifecycle**: `ApuIsVirtualAddressValid(ptr)` returns `TRUE` (`1`) while the block is live, and returns `FALSE` (`0`) after `ApuFree(ptr)`. 4. **Data access**: Memory written through the mapped pointer is verified byte-for-byte upon readback. 5. **Refusal controls**: Null pointers, stack addresses, and out-of-range APU addresses are refused (`ApuIsVirtualAddressValid` returns `FALSE`, `ApuMapVirtualAddress` returns 0, `ApuMapApuAddress` returns `nullptr`). 6. **Faulty provider negative control**: A faulty provider build (`APU_TEST_FAULTY`) where mapping returns `nullptr` causes the caller to abort at Step 4 (`0xF04`). 7. **Withholding negative controls**: Withholding any of `ApuMapVirtualAddress`, `ApuMapApuAddress`, or `ApuIsVirtualAddressValid` stops `pe_map` at import resolution before entry with `STATUS["unresolved"]` naming the missing export. ### Verification ```powershell cmake --build --preset dev --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller ctest --preset dev --no-tests=error -R '^cpu_native_apu_address$' -V ``` ``` test 321: cpu_native_apu_address ........... Passed (0.18 sec) caller imports: {'acphal.dll': ['ApuAlloc', 'ApuFree', 'ApuIsVirtualAddressValid', 'ApuMapApuAddress', 'ApuMapVirtualAddress', 'get_apu_unmapped_refusals'], 'cpu_exe_io.dll': ['finish_exe']} native and mapped exit 0x8a1; all address translation assertions passed faulty provider: native and mapped exit 0xf04 at Step 4 before entry: unresolved import acphal.dll!ApuMapVirtualAddress before entry: unresolved import acphal.dll!ApuMapApuAddress before entry: unresolved import acphal.dll!ApuIsVirtualAddressValid 100% tests passed, 0 tests failed out of 1 ``` Release build: ```powershell cmake --build --preset release --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V ``` ``` 100% tests passed, 0 tests failed out of 1 (0.17 sec) ``` Documentation and hygiene checks: ```powershell .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py ``` All passed. Refs #870.
upstream-sync closed this pull request 2026-11-24 06:45:47 +00:00
R0Y00 commented 2026-11-24 06:49:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:43:38Z.


Independent Windows Release run of 5f0aa84 passed ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V (1/1). Native and pe_map returned 0x8a1, the faulty provider returned 0xf04 in both, and withholding each mapping/query import failed before entry. The three mapping/query signatures and address behavior in this patch are the recording provider's fixture contract. Please carry that qualification into the PR summary so readers can distinguish this milestone from verification against the original provider.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7113471941 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1000#issuecomment-7113471941). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:43:38Z. --- Independent Windows Release run of `5f0aa84` passed `ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V` (1/1). Native and pe_map returned `0x8a1`, the faulty provider returned `0xf04` in both, and withholding each mapping/query import failed before entry. The three mapping/query signatures and address behavior in this patch are the recording provider's fixture contract. Please carry that qualification into the PR summary so readers can distinguish this milestone from verification against the original provider.
Holastor commented 2026-11-24 06:49:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T20:48:40Z.


Thanks @R0Y00, that qualification is important and makes complete sense. Updated the PR summary accordingly:

  • Added an explicit Fixture contract qualification section distinguishing the test-provider policy and recording provider's fixture contract (for ApuMapVirtualAddress, ApuMapApuAddress, ApuIsVirtualAddressValid, and synthetic address translation) from verified behavior against an original/production console provider.
  • Clarified that this milestone establishes caller, loader, and failure isolation contracts under source-built inputs, while verification against the original console provider remains open.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7113587840 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1000#issuecomment-7113587840). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T20:48:40Z. --- Thanks @R0Y00, that qualification is important and makes complete sense. Updated the PR summary accordingly: - Added an explicit **Fixture contract qualification** section distinguishing the test-provider policy and recording provider's fixture contract (for `ApuMapVirtualAddress`, `ApuMapApuAddress`, `ApuIsVirtualAddressValid`, and synthetic address translation) from verified behavior against an original/production console provider. - Clarified that this milestone establishes caller, loader, and failure isolation contracts under source-built inputs, while verification against the original console provider remains 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!993
No description provided.