audio: log the XDspActivate parameter block before refusing #3478

Manually merged
github merged 2 commits from github-bot/gh-3476 into gh-pr/3476/base 2026-11-30 19:59:27 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 16:37 UTC · original
Leyukaka:runtime-xdsp-activate-log → main · +58 −2 · 2 files · 2 commits · merged 2026-11-30 19:58 UTC

Refs #1145

What changes

XDspActivate (src/startup_stubs/chad.cpp) logs the activation parameter block (second argument) for its first 6 calls, before the existing refusal:

  • x2w-audio XDspActivate rdx=0x... params=<128 hex digits>: 64 bytes at the parameter pointer. They are copied to a local buffer with guarded_memcpy after probe_readable reports all 64 bytes readable, and the hex is built from that copy.
  • x2w-audio XDspActivate rdx=0x... params=unreadable when the probe or the copy fails (null, reserved or unmapped pointer).

The block has its own call counter and never returns early. Return value and outputs are unchanged: the refusal from #1887 stays (E_POINTER on a null or unwritable output, otherwise both outputs cleared and XDSP_E_NO_DEVICE_RESOURCES).

Why

#1145: the run log shows that activations are refused, but not what was requested. The stand-in logs the argument values and the two output pointers, not the contents of the parameter block, so a run on main does not show which effects the application asks for.

Tests

tests/startup_chad_check.cpp:

  • A 64-byte sentinel block (0xc0..0xff) must appear as one complete 128-digit log line.
  • A MEM_RESERVE / PAGE_NOACCESS page and a null pointer must each log params=unreadable.
  • All three calls must still return XDSP_E_NO_DEVICE_RESOURCES with both outputs cleared.
  • The existing E_POINTER checks are kept. The one with unwritable outputs now runs after the three calls above.

Build with libopus off, on 9798063c:

cmake --preset dev -DX2W_WITH_OPUS:BOOL=OFF
cmake --build --preset dev --target startup_chad_check
ctest --preset dev --no-tests=error --output-on-failure -R '^startup_chad_check$'

Result: 1/1 passed.

Mutations, each restored afterwards:

Mutation Result
Guard replaced by a direct std::memcpy from the pointer Crash at the reserved-page call
Direct read only when the pointer is null, guard kept otherwise Crash at the null call
Hex-dump log line removed FAIL: XDspActivate logs all 64 sentinel parameter bytes

Not covered

  • The parameter layout is not interpreted: the dump is a fixed 64 bytes.
  • No convolution and no change to what the application receives.
  • The dump from a run of the application stays local; it is not attached here.
**@⁠Leyukaka** on GitHub · 2026-11-29 16:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3476) `Leyukaka:runtime-xdsp-activate-log` → `main` · +58 −2 · 2 files · 2 commits · merged 2026-11-30 19:58 UTC Refs #1145 ## What changes `XDspActivate` (`src/startup_stubs/chad.cpp`) logs the activation parameter block (second argument) for its first 6 calls, before the existing refusal: - `x2w-audio XDspActivate rdx=0x... params=<128 hex digits>`: 64 bytes at the parameter pointer. They are copied to a local buffer with `guarded_memcpy` after `probe_readable` reports all 64 bytes readable, and the hex is built from that copy. - `x2w-audio XDspActivate rdx=0x... params=unreadable` when the probe or the copy fails (null, reserved or unmapped pointer). The block has its own call counter and never returns early. Return value and outputs are unchanged: the refusal from #1887 stays (`E_POINTER` on a null or unwritable output, otherwise both outputs cleared and `XDSP_E_NO_DEVICE_RESOURCES`). ## Why #1145: the run log shows that activations are refused, but not what was requested. The stand-in logs the argument values and the two output pointers, not the contents of the parameter block, so a run on `main` does not show which effects the application asks for. ## Tests `tests/startup_chad_check.cpp`: - A 64-byte sentinel block (`0xc0`..`0xff`) must appear as one complete 128-digit log line. - A `MEM_RESERVE` / `PAGE_NOACCESS` page and a null pointer must each log `params=unreadable`. - All three calls must still return `XDSP_E_NO_DEVICE_RESOURCES` with both outputs cleared. - The existing `E_POINTER` checks are kept. The one with unwritable outputs now runs after the three calls above. Build with libopus off, on 9798063c: ``` cmake --preset dev -DX2W_WITH_OPUS:BOOL=OFF cmake --build --preset dev --target startup_chad_check ctest --preset dev --no-tests=error --output-on-failure -R '^startup_chad_check$' ``` Result: 1/1 passed. Mutations, each restored afterwards: | Mutation | Result | |---|---| | Guard replaced by a direct `std::memcpy` from the pointer | Crash at the reserved-page call | | Direct read only when the pointer is null, guard kept otherwise | Crash at the null call | | Hex-dump log line removed | `FAIL: XDspActivate logs all 64 sentinel parameter bytes` | ## Not covered - The parameter layout is not interpreted: the dump is a fixed 64 bytes. - No convolution and no change to what the application receives. - The dump from a run of the application stays local; it is not attached here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 16:40:13 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 08:38 UTC · original · approved these changes

Reviewed 9798063c by reading the diff; not built or run.

Verdict: approve. Diagnostic only. The read is bounded and guarded, and the refusal path is unchanged. No MUST.

  • The read is safe: probe_readable refuses addresses below 0x10000 and unmapped space without touching them (local_log.h:137, :141). guarded_memcpy(..., false) then catches an access violation on a page that goes away after the probe, and the copy goes into a zeroed local buffer. The dump has its own first_calls(param_logs, 6) counter, so the existing accept logging and its limit are untouched.
  • The return value and outputs stay exactly as #1887 left them. The new block sits before the validation and returns nothing.
  • NIT: a block that ends less than 64 bytes before an unmapped page logs params=unreadable, although its first bytes could be read. probe_readable already returns the readable length, so the line could dump that prefix with its length. That only matters if the real block turns out to be shorter than 64 bytes and lies at a page end.

Tests: startup_chad_check sets X2W_TRAP_LOG to its own temp file (startup_chad_check.cpp:136), so the new log assertions run under ctest. They cover the full 128-digit line, unreadable for a reserved page and for null, and the unchanged results. The two crash mutations show the guard and the probe are each needed. CI built chad.dll but did not run startup_chad_check: it is not in the pr preset's list, and /O2 was skipped on the PR.

**@⁠lukaslw-lab** on GitHub · 2026-11-30 08:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3476#pullrequestreview-6109007843) · **approved these changes** Reviewed `9798063c` by reading the diff; not built or run. **Verdict: approve.** Diagnostic only. The read is bounded and guarded, and the refusal path is unchanged. No MUST. - The read is safe: `probe_readable` refuses addresses below 0x10000 and unmapped space without touching them (`local_log.h:137`, `:141`). `guarded_memcpy(..., false)` then catches an access violation on a page that goes away after the probe, and the copy goes into a zeroed local buffer. The dump has its own `first_calls(param_logs, 6)` counter, so the existing `accept` logging and its limit are untouched. - The return value and outputs stay exactly as #1887 left them. The new block sits before the validation and returns nothing. - **NIT:** a block that ends less than 64 bytes before an unmapped page logs `params=unreadable`, although its first bytes could be read. `probe_readable` already returns the readable length, so the line could dump that prefix with its length. That only matters if the real block turns out to be shorter than 64 bytes and lies at a page end. Tests: `startup_chad_check` sets `X2W_TRAP_LOG` to its own temp file (`startup_chad_check.cpp:136`), so the new log assertions run under ctest. They cover the full 128-digit line, `unreadable` for a reserved page and for null, and the unchanged results. The two crash mutations show the guard and the probe are each needed. CI built `chad.dll` but did not run `startup_chad_check`: it is not in the `pr` preset's list, and `/O2` was skipped on the PR.
github-bot changed target branch from main to gh-pr/3476/base 2026-11-30 19:59:26 +00:00
github manually merged commit 9798063c1e into gh-pr/3476/base 2026-11-30 19:59:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.