Skip to content

kernelx: XMemGetWorkingSetStatistics fills the fast-memory fields - #3148

Draft
KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:kernelx-xmem-working-set-fields
Draft

KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:kernelx-xmem-working-set-fields

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Status: a guess that needs evidence before it can be merged. The layout of XMemGetWorkingSetStatistics' output past +0x8 (the fast-memory pair and the other fields up to +0x4F) is reasoned from how titles call the API and from the PC's D3D12; it is not taken from any console documentation, and no title has confirmed it yet. Draft until then.

Evidence that would confirm it: a title that reads those fields: a streaming pool sized from them (in the title's own log or its memory use), with and without this change. The retail game used for the regression run does not get there.

If you run a title that gets there, please post those lines here (not the whole log, which names your paths).

Only +0 (title limit) and +8 (title used) were written, so engines that size

streaming pools from the fast-memory (GPU-optimal bandwidth) pair read stack

garbage. Now +0x10..+0x4F are written too: tools limit / used 0, stack used

and page count 0, fast-memory limit and used = the title's (one pool here),

the tools' fast memory 0, kernel pool 0. Every caller has those 0x50 bytes;

nothing is written at or past +0x50, where an older caller's stack cookie is

(zeroing 0x78 bytes once failed its cookie check, 0xC0000409).

What is in it

  • crates/xcl/src/hle/kernelx.rs: +31 / -3

  • new tests: working_set_statistics_fill_the_fields_up_to_0x50_only

Tested

Regression run

Both 60-second runs used the same warm DXIL cache directory.


xcl-smoke v1

commit: 336fdddafbcb3c3db753629f5f79a9f44b6c4b9d

gpu: NVIDIA GeForce RTX 2070 SUPER

title: retail game

seconds: 60

exit: 0x0

frames shown: 1228 (PresentX 1228)

presents per 2 s (last 3): 61 60 60

device removals: 0

crashes: 0

peak commit: 15234 MB


xcl-smoke v1

commit: dc4f69fb32886d3d4bcf8b095ea608de2b06b4cd

gpu: NVIDIA GeForce RTX 2070 SUPER

title: retail game

seconds: 60

exit: 0x0

frames shown: 1353 (PresentX 1353)

presents per 2 s (last 3): 60 60 60

device removals: 0

crashes: 0

peak commit: 16192 MB

Not tested

  • Full preparation. The smoke runs used XCL_PREPARE=0.

  • The two structure sizes are not told apart: the fields up to +0x50, inside every caller's buffer, are written for all callers; the tests check a 0x50-byte and a 0x78-byte buffer. A title reading these fields: none checked.

  • AMD and Intel GPUs; wave64 hardware (the RTX 2070 SUPER is wave32).

AI use

  • Codex (exact model name unavailable) verified the queued smoke results and drafted this description update.

  • patch-worker on Claude Sonnet 5.5 (self-reported); reviewed by Claude Opus 5.5: the code and tests. The description and the test / suite runs: Claude Code, Claude Sonnet 5.5 and Claude Opus 5.5.

🤖 Generated with Claude Code

Only +0 (title limit) and +8 (title used) were written, so engines that size
streaming pools from the fast-memory (GPU-optimal bandwidth) pair read stack
garbage. Now +0x10..+0x4F are written too: tools limit / used 0, stack used
and page count 0, fast-memory limit and used = the title's (one pool here),
the tools' fast memory 0, kernel pool 0. Every caller has those 0x50 bytes;
nothing is written at or past +0x50, where an older caller's stack cookie is
(zeroing 0x78 bytes once failed its cookie check, 0xC0000409).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii marked this pull request as ready for review November 28, 2026 14:43
@KOLESNiii
KOLESNiii marked this pull request as draft November 28, 2026 16:40
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head dc4f69f

No open or merged PR fills more of XMemGetWorkingSetStatistics; #3352 adds XMemGetPhysicalMemoryLayout next to it and does not overlap.
kernelx.rs write_working_set_tail: main's comment says the older EOSSDK caller has "at most 0x50 bytes before its stack cookie" and deliberately writes only +0 / +8. This PR now writes through +0x4F. That is safe only if that caller's buffer is exactly 0x50 bytes; the diff gives no evidence for that, and the field layout from +0x10 is inferred.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Review (head dc4f69f, diff read, not a merge-check; draft):

  • Where does the 0x10..0x4F layout come from? The field meanings (tools limit / used, stack and page count, the fast-memory pair, the tools' fast memory, the kernel pool) aren't something the two observed callers show by their size alone. Please say how they were obtained (e.g. what a title reads back and where).
  • It writes 64 more bytes into the title's structure, on the default path. Main writes only +0..+0x0F, after the cookie crash recorded in the doc comment: zeroing 0x78 bytes broke EOSSDK's older 0x50-byte structure. This keeps below +0x50, which fits the two callers known (Fortnite's exe with 0x78, its EOSSDK with at most 0x50). A caller built against a GDK whose structure is smaller than 0x50 would now be overwritten past its end (unverified that one exists). A smoke run on a title other than Fortnite would help.
  • The +0x20 slot is commented as two fields ("stack used, allocated page count") but written as one u64; if they are two u32s, zero is still right, but the comment should say so.

Fine: the test checks every field up to +0x50 and that nothing at or past +0x50 is touched, for both buffer sizes. Reporting the fast-memory pair as the title's limit and use fits XCL's one pool, and the helper keeps the null check and the min(limit) as before.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants