tooling: add fixed-frame generators to the CPU fuzz test #920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/927"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-23T17:31:47Z.
Refs #446
Adds the fixed-frame generator suggested in #446 after #894: fixed frames, saved and restored registers, partial spill overlaps, and a planted error. There are no calls.
Change
tools/fuzz_cpu.py --area framesgenerates functions for the sharedcpu_switch_aotlifter from its own seed. The new CTest iscpu_aot_fuzz_frames; the default is seed0xF4A3with 16 functions.PUSH. Alternatively, as MSVC does at/O2, RBX and RSI are saved into home space withMOV [rsp+8]/MOV [rsp+10h]beforePUSH RDI.SUB RSPallocates 16 to 40 bytes and leaves RSP 16-byte aligned. The prologue carries the matching.pushreg,.saveregand.allocstackdirectives.MOVorPOP, andADD RSPreleases the frame.translate --mutantbuilds a second translation in which every frame reload narrower than 8 bytes reads one byte higher in the frame array.check --mutantruns it against native, and the test fails if it never differs.cpu_aot_stack_framesgives.cpu_fuzz.asm/.deffor0xA902/20 and0xCCD1/96, and the generatedcpu_fuzz_lifted.cpp, are byte-identical tomain. Its output line is unchanged.--areaand prints the seed in hex. Previously it printed decimal, which still parsed.Measurements
Commit
f9ad552on94bc632. AMD Ryzen 7 7700, Windows 11 build 26300, MSVC x64.--preset releasegives the same three lines. Each test takes about 0.3 s.Default seed contents:
The failure paths were run by hand against the dev build:
fuzz_frame_0input 0. It printednative return=0x38409001c000 default return=0x38384061c000, then the first differing output byte (offset 0:00native,07mutant), the function's MASM including its prologue, andreproduce: python -B tools/fuzz_cpu.py check 0xf4a3 16 ... --area frames --only fuzz_frame_0 --input 0. That command repeats the case.--mutant. Exit 1, printingthe planted translator fault was not detectedandmutant reload_shift: 0/5008 mismatches in 0/16 functions.Longer manual run:
cmake --preset dev -DCPU_FUZZ_FRAMES_SEED=<seed> -DCPU_FUZZ_FRAMES_FUNCTIONS=128, then the same test.0x10x20xBEEF0xCCD1These runs found no translator difference. In 3 of the 512 functions the mutant didn't differ:
fuzz_frame_6at0x2andfuzz_frame_77at0xCCD1), every reload is 8 bytes wide, and the mutant leaves those alone.0x1, the shifted reloads gave the same results on all 313 inputs.Wider checks:
ctest --preset dev --no-tests=error -R '^cpu_': 172/172 pass on the rebased tree. The only later change is the hex seed in the reproduction line.tests/docs_links_check.py(13 files, 183 links),tests/bidi_controls_check.pyandgit diff --checkpass.Scope
The generator uses only RSP-based fixed frames. There is no RBP anchor and no
LEAVE, so #907 and #895 can changeFrameindependently. Calls, call graphs, mid-body RSP changes and fault equivalence remain follow-ups.docs/experiments.mdgains acpu_aot_fuzz_framesparagraph in the fuzz section.AI-assisted (Claude Code).