Console CPU instructions: leave CLWB intact while single stepping #571
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!571
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-571"
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?
@Prime1997 on GitHub · 2026-11-24 01:56 UTC · original
Prime1997:contrib/clwb-trap-flag→main· +62 −1 · 1 files · 1 commits · openWhen a debugger single-steps a title on a CPU without CLWB, the exception handler currently replaces the original instruction with several one-byte NOPs. A later visit to the same address sees different instruction boundaries. Keep the instruction bytes while the x86 trap flag is set.
What is in it
Tested
ff37edccb1dabb9e39985b51ecf33a5e352c699a, Windows 11 Pro build 26200, Intel Core i5-10400, NVIDIA GeForce RTX 3060 Ti, driver 32.0.16.1714, Rust 1.100.0 MSVC.508a0c7with the original four-byte CLWB replaced by four NOPs. The release exception-handler tests passed after the change (7 passed, 0 failed, 0 ignored).cargo test --workspacerun with locked dependencies, four test threads and--no-fail-fastcompleted with 681 passed, 0 failed, 41 ignored. Two GPU tests reported a wave64 hardware skip. Both the debug workspace and release CLI builds passed.Regression run
Both runs used the same retail title, RTX 3060 Ti, 60-second limit, offline mode, first-use compute setting and two DXC workers.
Main
PR head
Not tested
The focused test exercises the real exception handler with a saved Windows context. An interactive debugger session and CPUs that execute CLWB natively were outside this test. Optional retail sample tests had no external input.
AI use
OpenAI Codex (GPT-6) assisted with reproducing the behavior, implementing the guard and tests, checking overlap and preparing this report.
I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@MesshM on GitHub · 2026-11-24 03:12 UTC · original
Test run of
ff37edccb1dabb9e39985b51ecf33a5e352c699aon AMD RDNA4. I merged it onto currentmaindd2ae9alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 691 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 651 passed, 0 failed, 21 ignoredSKIPPED;clwb_single_step_keeps_code_and_normal_faults_still_patchpasses.Review: With the trap flag (
EFlags & 0x100) set the handler leaves the bytes alone and only advances RIP; without it it patches as before, and the test covers the 4-, 5- and 6-byte encodings both ways. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@upipibi on GitHub · 2026-11-24 04:05 UTC · original
On the overlap with #321 that the description mentions: I checked it at heads
ff37edccb1(this PR) anddfa332a5a4(#321). The two conflict incrates/xcl/src/eh.rsin either order againstmainf4ce27ceb6, and #321 changes the premise of this one.code.fill(0x90)path. Several one-byte NOPs move the instruction boundaries a stepping debugger sees on its next visit.hot_patch_clwbwrites a single 2-bytejmp shortover the whole CLWB, atomically under theCLWB_PATCHESlock. After that patch, a later visit sees one instruction atripthat ends atrip + len, so the boundary problem this PR fixes no longer occurs.So if #321 lands first, this PR's change mostly becomes unnecessary. The TF check would only matter if the code should stay untouched while a debugger steps at all, in which case it would go at #321's call site (
if hot_patch_clwb(rip, ...) == ClwbPatch::Patched, line 428 at its head) and return theSteppedbehaviour. Your test cases (4-, 5- and 6-byte encodings, TF on and off) would still be useful against #321's jump patch either way.Read-only, not built. AI-assisted (Claude Code).
@Prime1997 on GitHub · 2026-11-24 04:08 UTC · original
Interesting. I was using 321 but I didn't think it would be an issue, but I will try and see if this gets pushed first. If anything, we can use a debugger for the lower end systems.
Good catch!
@DavidM1911 on GitHub · 2026-11-25 13:18 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@upipibi on GitHub · 2026-11-26 04:30 UTC · original
NVIDIA test report for
ff37edc: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(thehle::xaudio2tests hang on this machine, onmaintoo):no wave64). The newclwb_single_step_keeps_code_and_normal_faults_still_patchpasses.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.