cpu: handle immediate INSERTQ in the startup debugger #1229
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1229
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1229/head"
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?
@R0Y00 on GitHub · 2026-11-24 04:26 UTC · original
R0Y00:codex/startup-insertq→main· +140 −1 · 7 files · 1 commits · closed without mergingRefs #870.
An opt-in startup debugger fallback executes the defined low-quadword result of immediate SSE4a INSERTQ on an x64 host that raises an illegal-instruction exception. It only handles six-byte XMM0-XMM7 register encodings in the mapped main executable. Native support needs no exception handling. Unsupported forms/ranges and stop-first-chance diagnostics retain normal exception processing.
Windows Release on Intel Core i9-14900HX, MSVC 19.51, checked with the source-built MASM fixture:
1/1 passed, zero skips. The baseline stops on 0xc000001d. With X2W_STARTUP_INSERTQ=1 the same fixture checks neighboring bits, source contents and flags, exits 0, and records one emulation. Independent context controls cover length 0 / 64, bit 63, unchanged state on rejection, and bounded decoding. The upper 64 bits of the hardware result are unspecified. No private samples or logs are included.
@R0Y00 on GitHub · 2026-11-25 00:56 UTC · original
Superseded by #1274 and the wider SSE4a support in #1846. I rebuilt the original MASM fixture from this PR and ran it under the merged debugger on a Core i9-14900HX. With X2W_HOST_CPU off it stopped at 0xc000001d. With X2W_HOST_CPU=1 it rewrote one INSERTQ and exited 0, including the fixture destination, source and flag checks. The source-built fixture remains available here for an exact debugger-path regression.
@tedin7 on GitHub · 2026-11-24 04:38 UTC · original · reviewed
Reviewed commit
7bb1ab4fon Linux (x86_64, Python 3.12 withiced-x86andpefile). Windows build/tests (startup_insertq_fixture,ctest --preset release --no-tests=error -R '^startup_insertq$' -V) were not run locally.Code & Spec Audit
tools/startup/insertq.py:apply_insertqmatches the 6-byte SSE4a immediateINSERTQ xmm1, xmm2, imm8, imm8(F2 0F 78 /r ib ib,ModR/M >= 0xc0, XMM0-XMM7), mapslength == 0to64((code[4] & 63) or 64), masksoffset = code[5] & 63, rejectsoffset + width > 64(undefined AMD64 range), checksCONTEXT.Rip(0xf8) againstrip, updates only the low 64 bits ofdestinFltSave.XmmRegisters(0x1a0 + 16 * reg), preservesEFLAGS, and advancesRipby 6.tools/startup/debug_launch.py: gates onfirst and ex_code == 0xc000001d and allow_insertq and not stop_first, usesK32GetModuleInformationto boundaddressto[base, base + size - 6], and reads/writesCONTEXTwithContextFlags = 0x10000B(includesCONTEXT_FLOATING_POINT).README.mdanddocs/experiments.mdare title-neutral and match the implementation.Checks Run Locally (Linux)
/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (self-test passed; 16 Markdown files, 277 links)/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (self-test passed; 1037 tracked files)/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: passed/root/.local/share/x2w-rev-venv/bin/python -B tests/hardware_reports_check.py: 12/12 passed, 0 skipped, 0 failed/root/.local/share/x2w-rev-venv/bin/python -B tests/gpu_report_format_check.py: 10/10 passed, 0 skipped, 0 failedtools/startup/insertq.pyapply_insertqcheck (3 valid boundary cases:16/16,0/0 -> 64,1/63; 6 invalid/rejected cases): passedgit diff --check HEAD~1..HEAD: passedPull request closed