cpu: lower the reserved/hint NOP space in the shared lowering #1540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1547"
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 triggered02 on 2026-11-24T13:48:22Z.
Implements the slice you scoped: the exact RESERVEDNOP forms the target manual documents as no-effect, ENDBR out, with the native-versus-lifted comparison as the acceptance fixture.
Lowering
iced decodes
0F 19 /r,0F 1D /r,0F 1E /r(unprefixed) and0F 1F /rasRESERVEDNOP. The AMD APM documents them as reserved hint NOPs that take a ModRM but access no memory, so they lower to;— operand not evaluated, so no address computation, no load, no fault. Forms iced decodes as another mnemonic never reach that branch and stay refused: ENDBR64/ENDBR32, CLDEMOTE, RDSSPD/RDSSPQ, the0F 18prefetches and the MPX forms.Fixture 1 —
cpu_hint_nop(lowering-level)Six exact accepted patterns must lower to a body identical to an already-accepted NOP (block labels normalised, since they are numbered by instruction count). Identical bodies are the proof the instruction evaluates nothing. Four neighbours must stay refused:
Fixture 2 —
cpu_hint_nop_fixture(native versus lifted execution)One generator assembles the exact bytes and lowers the same instructions, so the two arms cannot drift apart. Prologue sets RAX from the input and the arithmetic flags from an ADD; each case executes the encoding under test and stores the flags in AH with LAHF, so a changed register or flag changes the return value. The memory forms are handed a pointer to a
PAGE_NOACCESSpage as the base register — if anything evaluated the operand, the call would fault instead of returning.The two controls are what make the rest meaningful rather than circular: the harness must be able to see a memory access (the load faults), and a real register write must move the result (the
mov eax, immcase returns a different value with the same inputs).Fail-first: with the lowering change reverted, the generator raises on the first hint-NOP encoding and
cpu_hint_nopreports the accepted forms as mismatches.cpu_aot_integer_flags, the neighbouring control for the same lowering, still passes.What this does not establish
/O2variant is not separate here: the fixture is built with the release preset, which is the optimised build; a Debug build would exercise the same bytes and the same lowered body.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:58:51Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
7ed75b1e84ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:48:36Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
7ed75b1ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T14:03:13Z.
Correct — recorded in
0ba1a965.docs/experiments.mdnow carries the reserved/hint NOP entry next to the existing90/66 90notes, and it covers what you asked for:0F 19 /r, unprefixed0F 1D /rand0F 1E /r, and0F 1F /rin any ModRM form, lowered to a no-op with the operand not evaluated.ENDBR64/ENDBR32,CLDEMOTE,RDSSPD/RDSSPQ, the0F 18prefetches and the MPX forms — named explicitly, including why ENDBR is out of scope on a target without CET (accepting it would claim something about indirect-branch tracking that nothing here checks).ctest --preset dev --no-tests=error -R '^cpu_hint_nop$' -Vand... -R '^cpu_hint_nop_fixture$' -V, with the measured native-versus-lifted result and the two controls (a real load from the inaccessible page must fault; a real register write must move the result) that make the comparison meaningful rather than circular.docs_links_check(340 links) andbidi_controls_checkpass after the addition.Separately, I saw R0Y00 pushed
15e42befonto the audio pacing branch — gating acceptance on p95 with maximum and RMS kept as diagnostics, plus a deterministic control for isolated and sustained delays. I've adopted it locally rather than reworking it; that's a better shape than my max-based bound.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:58:51Z.
Code review location:
tools/ffx_version_query.py; line 3069Since this branch now accepts
0F 19,0F 1Dand unprefixed0F 1Ein the shared integer lowering, the CPU notes indocs/experiments.mdstill describe only the existing90/66 90NOP cases and omit both the new acceptance/refusal boundary and how to runcpu_hint_nop/cpu_hint_nop_fixture; contributors following the documented capability notes cannot reproduce this change. Please update those notes, as repository guidance requires for public capability changes.AGENTS.md reference: AGENTS.md:L191-L192
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T14:51:29Z.
Review: COMMENTED
Reviewed against the AMD64 APM Vol. 3 (24594, rev. 3.39, October 2026). I'm not opening a competing PR for #1476, so this is yours.
1. The accepted set is wider than the docs and the comment say. The branch tests
op in (M.NOP, M.RESERVEDNOP), which accepts every encoding iced decodes asRESERVEDNOP, not only0F 19,0F 1D, unprefixed0F 1Eand0F 1F. With iced as pinned here:0F 0Dis wrong for the APM. Table A-7 lists Group P as prefetches for every/reg: footnote 4 says reserved prefetch encodings alias PREFETCH Exclusive. So these are not hint NOPs.0F 18 /6and/7are listed as NOP in the Table A-7 Group 16 row. But the PREFETCHlevel page in the same revision documents them as PREFETCHIT1/PREFETCHIT0, gated by CPUID Fn8000_0021_EAX[PREFETCHI]. I would keep them out of a "documented no effect" slice.0F 1A,0F 1B,0F 1C /1-7and prefixed0F 1Eare listed as NOP in Table A-4. OnlyF3 0F 1Ewith reg=1, mod=11 is RDSSP. So accepting them matches the APM, but the docs and the code comment then need to say so, and a test needs to pin them.Suggestion: select by
i.coderather than by mnemonic. Accept theRESERVEDNOP_RM{16,32,64}_R{16,32,64}_0F19…_0F1Fcodes, plus_0F18withModRM.reg & 7in {4, 5} if you want Group 16 /4 and /5. Add0f0dc0and0f18f0to the refused neighbours inhint_nop_check.py, so that a later widening is visible as intended.2. Smaller points:
hint_nop_fixture.py, the lifted call is outside the__try. A lifted body that evaluates the operand would crash the test process instead of reporting MISMATCH. Wrapping it like the native call gives a clearer failure.[page + 17](or+25), because RAX isa + bafter the prologue. That is still inside the inaccessible page, so the fault check holds. A comment saying so would help.cpu_integer_flags_controlslines, inside the indentedif(EXISTS "${INTAKE_PYTHON}")block.APM references:
0F 19–0F 1Fas NOP with a ModRM, plus(F3) RDSSP reg=1, mod=11.0F 18 /6and/7encodings.I did not build or run the branch. The acceptance results above come from decoding with iced and from applying the branch's condition.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T14:54:51Z.
Both points were right, and the first one was a real defect rather than a documentation gap: my acceptance test was
op in (M.NOP, M.RESERVEDNOP), so it accepted every encoding iced decodes asRESERVEDNOP. Fixed in992cf643.1. Selection by code. The lowering now accepts exactly
RESERVEDNOP_RM{16,32,64}_R{16,32,64}_0F19,_0F1D,_0F1Eand_0F1F, and nothing else in that space. Your three sub-points:0F 0D— agreed, Group P aliases PREFETCH Exclusive, so it is now refused.0f0dc0is in the refused set.0F 18 /6and/7— agreed, PREFETCHIT1/0 under CPUID Fn8000_0021_EAX, so refused.0f18f0and0f18f8are pinned as refused. I did not take the optional Group 16/4and/5; leaving the whole0F 18row out keeps this slice to encodings the APM calls no-effect without a CPUID dependency.0F 1A,0F 1B,0F 1C /1-7, prefixed0F 1E— I checked iced here: the prefixed form really does decode to the same code as unprefixed0F 1E(RESERVEDNOP_RM32_R32_0F1E), whileENDBR64/ENDBR32/RDSSPdecode differently. So the prefixed form is accepted and the docs now say why: only reg=1 with mod=11 in that encoding isRDSSP, which matches the APM.0F 1A,0F 1Band0F 1Cstay out of this slice and are refused, since the slice is the 19/1D/1E/1F row.The check now pins the boundary from both sides — seven accepted patterns and ten refused neighbours, six of which the previous test accepted:
2. The smaller points, all taken.
__tryas the native call, and the line printslifted_faulted=0as well asfaulted=0, so a lowering that evaluated the operand reports a mismatch instead of taking the process down.page+17(page+25), which is still inside the single inaccessible page, so the fault control holds.if(EXISTS "${INTAKE_PYTHON}")it sits in.docs/experiments.mdnow states the exact accepted and refused sets and why0F 0Dand0F 18are not hint NOPs.Fixture still passes:
PASS: every hint NOP matched its lifted body without evaluating the operand, with the load and register-write controls both holding. Thanks for the APM citations — the mnemonic shortcut was the wrong level to select at and I would not have caught it from the tests.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:35:54Z.
Review: COMMENTED
Technical review (Linux only; the Windows pipeline and the Windows-only native fixture were not run).
Checked out the PR head in a clean tree and ran:
tests/cpu/hint_nop_check.py: passes (7 accepted, 10 refused).tests/cpu/hint_nop_fixture.py emit: generates the C++ for the 5 cases. It needsVirtualAlloc, SEH and__declspec(allocate), so I could only read the output, not build or run it. The "matched natively" statements indocs/experiments.mdare therefore unverified here.lower()(same body as an already-accepted0F 1F 00, labels normalised):66/REX.Wforms of0F 19/0F 1E/0F 1F, register forms,0F 1Fwith disp32 and RIP-relative operands,F2/F3/67prefixes,F3 0F 1Ewith mod=11 and reg=0/2..7 (includingFC,FF) all lower to the same no-op.F3 0F 1E C8/REX.W C8(RDSSP),F0-prefixed forms (decode as invalid) and a segment prefix stay refused. This agrees with the selection by iced code described in the PR.Local mutation check on
tools/ffx_version_query.py(each reverted afterwards, tree clean):0F19: caught. Drop0F1D: caught.op == M.RESERVEDNOP) instead of by code: caught (6 cases)._RESERVED_NOP_CODES: not caught.So the statement that the set covers "every operand size" is not pinned by any test: all accepted encodings in
ACCEPTEDuse the default size. Suggestion (non-blocking): add660f1900,660f1e00,480f1900and480f1e00toACCEPTED. They pass today (verified above), so this is only a guard.Docs (
docs/experiments.md), worth fixing before merge:cpu_aot_xchgrun line, with no blank line, so Markdown renders it as part of the preceding paragraph....is \RDSSP`.`cpu_hint_nop` pins the exact byte patterns` has no space or paragraph break between two sentences.cpu_native_sectionblock, the LDS qword paragraphs, the Leonida paragraph, the AVX2 heading and thedxr_placed_build_block). They are unrelated to this change and add diff noise.CMake wiring (
cpu_hint_nopunderINTAKE_PYTHON,cpu_hint_nop_fixturewithSKIP_RETURN_CODE 77) is consistent with the other entries in that block. One small thing:tests/cpu/hint_nop_fixture.pyhas no trailing newline.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:00:03Z.
All three points taken, in
f64f7e38. And your mutation result was the useful one: the operand-size claim was genuinely unpinned.Operand sizes.
ACCEPTEDnow includes660f1900,660f1e00,480f1900and480f1e00. Your two surviving mutations now fail:So the "every operand size" statement in the docs is now backed by the test rather than by the implementation.
Docs. I rebuilt
docs/experiments.mdfrommainand inserted only the block, so the five unrelated blank-line hunks are gone — the file's diff against main is now a 6-line addition. The block starts on its own paragraph, and the two sentences that ran together (...is \RDSSP`.`cpu_hint_nop` pins...`) are separated.Trailing newline added to
tests/cpu/hint_nop_fixture.py.On your Linux-only caveat: the native half did run here, on Windows, release preset:
So the "matched natively" statements are verified on one Windows machine, not just read from the generated source — but only for the five memory/register/displacement cases in
ACCEPTEDthat the fixture emits; the four operand-size forms are pinned only at the lowering level, which the docs now describe that way.cpu_hint_nopandcpu_hint_nop_fixtureboth pass;docs_links_check(348 links) andbidi_controls_checkpass. Thanks — the mutation table is what turned a comment into a requirement.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:59:14Z.
Review: COMMENTED
Re-review of head
f3b9f52f(the earlier review was one418311c).What the change does
tools/ffx_version_query.pylowers the reserved hint NOP forms (0F 19,0F 1D,0F 1E,0F 1Fwith any ModRM, in 16, 32 and 64-bit operand size) to a no-op. The set is chosen by iced code (_RESERVED_NOP_CODES), not by mnemonic, so0F 0D,0F 18 /6-/7,0F 1A,0F 1B, CLDEMOTE, RDSSP and ENDBR stay refused. That is the right call: those decode as the same reserved-NOP mnemonic family but are not all hint NOPs.Findings
tests/cpu/hint_nop_check.pymatch the doc (11 accepted, 10 refused).tests/cpu/hint_nop_fixture.pycovers the five unprefixed 32-bit cases only. TheF3and 16/64-bit forms are exercised by the Python check, not by the native-versus-lifted fixture. That is enough for this PR, but a later case would close it.ENDBR64/32being refused is stated in the docs. Code built with CET will still hit the refusal; that is a separate slice.Checks run (Linux only;
cpu_hint_nop_fixturecompiles with MSVC__tryand needs Windows, so it was not run)git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.py: self-test passed, 16 files, 348 links.python3 tests/bidi_controls_check.py: self-test passed, 1275 files, no bidirectional controls.tests/cpu/hint_nop_check.pywith iced-x86 fromrequirements-dev.txt: PASS, 11 accepted forms lowered to the same body as a plain NOP, 10 neighbours still refused.tests/cpu/hint_nop_fixture.py emitruns and writes the fixture. MinGW cannot compile it (MSVC-only__assumeand__try), as expected.tests/cpu/lower_prefixes_check.py: passes with the change.0F1Dremoved from the code set: KILLED (accepted 0f1d00fails).66forms fail).RESERVEDNOPspace accepted: KILLED (six refused cases, among them0f0dc0and0f18f0, are accepted and reported).Verification is Linux-only; the native comparison needs the Windows run.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:14:56Z.
Review: COMMENTED
Re-review of the delta for head
4fb81a5fagainst my previous review atf3b9f52f(comment only, no approval).Verdict: no blocking findings in the delta.
What changed since
f3b9f52f:f3b9f52fis no longer an ancestor of the head. I compared the PR's own diff against its merge base before and after the rebase. The only differences are intests/cpu/hint_nop_check.pyandtests/cpu/hint_nop_fixture.py: both files now end with a newline (both end in0a), andhint_nop_fixture.pyhas five new native-versus-lifted cases (F3 0F 1E [rax],66 0F 19,66 0F 1E,48 0F 19,48 0F 1E).CMakeLists.txt,docs/experiments.mdandtools/ffx_version_query.pyare byte-identical across the rebase.hint_nop_check.pyalready lists as accepted, so the Python check and the Windows fixture now cover the same eleven forms (the fixture keeps its own five unprefixed cases for 32-bit, so ten in total, as the commit message says). The docs paragraph ("seven accepted encodings plus the 16-bit and 64-bit forms", "ten neighbours") still matches the code.Checks run on Linux (Python 3 venv with the versions pinned in
requirements-dev.txt: iced-x86 1.21.0, pefile 2024.8.26):python3 -I -B tests/cpu/hint_nop_check.py: PASS (11 accepted forms lowered to a no-op, 10 neighbours still refused).python3 -I -B tests/cpu/hint_nop_fixture.py emit: emits 10 cases, and the five new names are in the generated C++.git diff --checkover the PR files: clean.python3 -I tests/docs_links_check.py: self-test passed, 17 files, 363 links.python3 -I tests/bidi_controls_check.py: self-test passed, 1282 files, none found.Mutation checks I actually ran on
tools/ffx_version_query.py(one change at a time, restored after each; every one is caught byhint_nop_check.py, exit 1):480f1900and480f1e00.660f1900and660f1e00.0F19,0F1Dor0F1Efrom the opcode list: 5, 1 and 4 mismatches.0F1Ato the accepted set:0f1a00reported as wrongly accepted.op == M.RESERVEDNOP) instead of by iced code: 6 mismatches, starting with0f0dc0.;: 10 mismatches.So the five new fixture cases are not what protects the lowering on Linux. The Python check already does, and the new cases extend the Windows-only native comparison, which I could not run.
Non-blocking notes (none are caused by the delta):
hint_nop_check.pysays the memory-form cases include a non-canonical pointer in RAX and a RIP-relative displacement, but theACCEPTEDtable has neither. I checked by hand that0f190500000000(RIP-relative) lowers to the same no-op body, and so do670f1900,f20f1900andf30f1e08(F3 0F 1E /1 with a memory operand, which the docs say is not RDSSP).f00f1900(LOCK) is refused. Adding0f190500000000andf30f1e08toACCEPTEDwould pin the claims the docstring and the docs make.cpu_hint_nop_fixturenative run, the PAGE_NOACCESS and register-write controls) are as reported by the author; I did not reproduce them.Limits: Linux only. I ran no ctest preset and no Windows build, and the stand-alone Python check uses the iced version pinned by the repo, not the newest release.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:15:47Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:03:25Z.
Both minors are done in
4fb81a5f, and the Windows run you could not do is now in the PR.Native coverage for the prefixed and 16/64-bit forms. The fixture has ten cases now, adding
F3 0F 1E [rax]and the four66/48operand-size forms. Each compares the executed bytes against the lifted body with aPAGE_NOACCESSbase, so evaluating the operand would fault rather than return:Both controls still fire, so "did not fault" is meaningful rather than a dead assertion.
Trailing newlines are added to both new Python files.
One note on the pre-existing five cases: they already covered
0F 19,0F 1D,0F 1Eand0F 1Fat 32-bit, so the set now spans all four opcodes in the accepted list at the sizes the doc claims, with F3 covered once.ENDBR64/32stays refused, as you noted — that is its own slice.Thanks for the mutation work; the 16-bit removal mutation was the one that caught the operand-size gap, and that is exactly the case this fixture addition now pins natively as well.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:15:46Z.
Code review location:
tools/ffx_version_query.py; line 3069Verified the experiment notes on
4fb81a5f. They document the accepted encodings, refusals and both CTest commands. The two Windows Release checks passed independently.