cpu: lower the hint-NOP space (RESERVEDNOP, ENDBR64/ENDBR32) in the shared lowering #1476
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#1476
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@legacy-code-archaeologist on GitHub · 2026-11-24 12:32 UTC · original
The shared lowering (
tools/ffx_version_query.py) acceptsNOP(0F 1F /0,90). It refuses the hint-NOP space that iced decodes asRESERVEDNOP, andENDBR64/ENDBR32:(
lower(list(Decoder(64, bytes.fromhex(h + "c3"))), [], {}, {}, {})one3193607.)form_coverage --gaps x64_zen2listsreservednopas unobserved.On the x64_zen2 target these execute as NOPs. The AMD APM documents
0F 19–0F 1Fas reserved/hint NOPs that take a ModRM but do not access memory.ENDBR64/ENDBR32(F3 0F 1E FA/FB) fall in that space too, and Zen2 has no CET indirect-branch tracking. CET-instrumented code (-fcf-protection) starts many functions withendbr64, and today each of those functions is refused.Proposed slice:
;:RESERVEDNOP(any ModRM, register or memory form) andENDBR64/ENDBR32.CLDEMOTE(0F 1C /0),RDSSPD/RDSSPQ(F3 0F 1E /1), the prefetches in0F 18 /0-3and0F 0D, and the MPX forms when decoded as such;Fixture plan (source-built MASM via
dbbytes, since ML64 has no spelling for most of these; native vs translated, plus/O2):PAGE_NOACCESSpage must not fault, natively or translated.cldemote [rax],rdsspq rax,prefetchw [rax].Host note: my test host is a Skylake. Windows does not enable MPX, so
0F 1A/0F 1Bexecute as NOPs there too, and ENDBR64 is a NOP without IBT. Native runs on a CET-IBT host would still see ENDBR64 as an architectural no-op, because ENDBR only marks a valid target.Is this scope OK? One open question: accept the whole
RESERVEDNOPrange, or only0F 1F-adjacent forms plus ENDBR64/ENDBR32?@R0Y00 on GitHub · 2026-11-24 12:44 UTC · original
Please start with the exact RESERVEDNOP encodings for which the target manual documents no observable effect. List those forms in the test and keep unsupported decoded forms rejected. The source-built native/default/optimized comparison for registers, flags, and no memory access is a good acceptance check. Keep ENDBR out of this first slice so the change stays scoped to reserved NOPs.
@triggered02 on GitHub · 2026-11-24 13:46 UTC · original
Claiming this, taking the scope you set rather than the one I proposed: RESERVEDNOP forms whose target manual documents no observable effect, ENDBR64/ENDBR32 excluded.
Slice:
RESERVEDNOPencodings that are reserved hint NOPs on x64_zen2 with a documented no-effect — the0F 19 /r,0F 1D /r,0F 1E /r(unprefixed) and0F 1F /rforms, any ModRM. The memory operand is not evaluated: no address computation, no load, no fault.ENDBR64/ENDBR32(F3 0F 1E FA/FB) as you asked, plus the decodes that are not reserved NOPs —CLDEMOTE(0F 1C /0),RDSSPD/RDSSPQ(F3 0F 1E /1), the0F 18prefetches,0F 0D, and the MPX forms. The test lists the accepted forms by exact bytes and asserts the refused set stays refused, so widening this later is a visible change rather than a silent one.tools/ffx_version_query.py); no per-translator change.Fixture plan, source-built:
/O2builds.PAGE_NOACCESSpage must not fault — this is the check that would catch an implementation that evaluates the operand.cldemote [rax],rdsspq rax,prefetchw [rax],endbr64.Reported numbers will be the per-form byte patterns accepted plus the register/flag diff counts (all zero), not "it works". I will say explicitly what the fixture does not establish: it does not validate CET/IBT behaviour, since ENDBR is out of this slice and the host has no IBT.
AI-assisted (Claude Code).
@legacy-code-archaeologist on GitHub · 2026-11-24 13:50 UTC · original
@triggered02 I opened #1476 and R0Y00's reply above was the go-ahead for that slice. I'm on it, so please pick something else to avoid two PRs for the same forms.
On the list itself: I'm sourcing it from the AMD64 APM Vol. 3 (24594, rev 3.39) before writing code, because the space is crowded. sandpile.org's group table lists
0F 1C /0as CLDEMOTE and0F 18 /4,/6,/7as MOVRS/PREFETCHI. It also lists0F 1E /6and several0F 1E /7register forms as reassigned, and0F 1A/0F 1Bas MPX. So "0F 1E /runprefixed, any ModRM" is wider than what I can cite as no-effect today. The PR will list each accepted form with its manual reference, and everything else will stay refused.@R0D4X on GitHub · 2026-11-26 13:42 UTC · original
Claiming the remaining ENDBR64 / ENDBR32 follow-up slice of #1476 now that the RESERVEDNOP slice (1455727, 72a0929,
7368c1b6) is on main.Plan: