cpu: lower the hint-NOP space (RESERVEDNOP, ENDBR64/ENDBR32) in the shared lowering #1476

Closed
opened 2026-11-26 23:10:10 +00:00 by github-bot · 4 comments
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-24 12:32 UTC · original

The shared lowering (tools/ffx_version_query.py) accepts NOP (0F 1F /0, 90). It refuses the hint-NOP space that iced decodes as RESERVEDNOP, and ENDBR64/ENDBR32:

f30f1efa ENDBR64      refused: unsupported query operation at 0x0: endbr64
0f1900   RESERVEDNOP  refused: unsupported query operation at 0x0: nop [rax],eax
0f1ec0   RESERVEDNOP  refused: ...
0f18e0   RESERVEDNOP  refused: ...
0f1f00   NOP          accepted

(lower(list(Decoder(64, bytes.fromhex(h + "c3"))), [], {}, {}, {}) on e3193607.) form_coverage --gaps x64_zen2 lists reservednop as unobserved.

On the x64_zen2 target these execute as NOPs. The AMD APM documents 0F 19–0F 1F as 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 with endbr64, and today each of those functions is refused.

Proposed slice:

  • Accepted, lowered to ;: RESERVEDNOP (any ModRM, register or memory form) and ENDBR64/ENDBR32.
    • The memory operand is not evaluated: no address computation, load or fault.
    • No register, flag or memory change.
  • Still refused:
    • everything iced decodes to another mnemonic in that space: CLDEMOTE (0F 1C /0), RDSSPD/RDSSPQ (F3 0F 1E /1), the prefetches in 0F 18 /0-3 and 0F 0D, and the MPX forms when decoded as such;
    • other translators: this slice touches only the shared lowering.

Fixture plan (source-built MASM via db bytes, since ML64 has no spelling for most of these; native vs translated, plus /O2):

  • Each accepted encoding sits between writes of known register and flag values. The check compares all GPRs and the arithmetic flags afterwards.
  • A memory-form hint NOP whose ModRM points at a PAGE_NOACCESS page must not fault, natively or translated.
  • Controls that must fail: one where the hint NOP evaluates its memory operand (it then faults on the inaccessible page), and one where it clobbers a register.
  • Refusals: cldemote [rax], rdsspq rax, prefetchw [rax].

Host note: my test host is a Skylake. Windows does not enable MPX, so 0F 1A/0F 1B execute 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 RESERVEDNOP range, or only 0F 1F-adjacent forms plus ENDBR64/ENDBR32?

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-24 12:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1476) The shared lowering (`tools/ffx_version_query.py`) accepts `NOP` (`0F 1F /0`, `90`). It refuses the hint-NOP space that iced decodes as `RESERVEDNOP`, and `ENDBR64`/`ENDBR32`: ``` f30f1efa ENDBR64 refused: unsupported query operation at 0x0: endbr64 0f1900 RESERVEDNOP refused: unsupported query operation at 0x0: nop [rax],eax 0f1ec0 RESERVEDNOP refused: ... 0f18e0 RESERVEDNOP refused: ... 0f1f00 NOP accepted ``` (`lower(list(Decoder(64, bytes.fromhex(h + "c3"))), [], {}, {}, {})` on e3193607.) `form_coverage --gaps x64_zen2` lists `reservednop` as unobserved. On the x64_zen2 target these execute as NOPs. The AMD APM documents `0F 19`–`0F 1F` as 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 with `endbr64`, and today each of those functions is refused. **Proposed slice:** - **Accepted, lowered to `;`:** `RESERVEDNOP` (any ModRM, register or memory form) and `ENDBR64`/`ENDBR32`. - The memory operand is not evaluated: no address computation, load or fault. - No register, flag or memory change. - **Still refused:** - everything iced decodes to another mnemonic in that space: `CLDEMOTE` (`0F 1C /0`), `RDSSPD`/`RDSSPQ` (`F3 0F 1E /1`), the prefetches in `0F 18 /0-3` and `0F 0D`, and the MPX forms when decoded as such; - other translators: this slice touches only the shared lowering. **Fixture plan** (source-built MASM via `db` bytes, since ML64 has no spelling for most of these; native vs translated, plus `/O2`): - Each accepted encoding sits between writes of known register and flag values. The check compares all GPRs and the arithmetic flags afterwards. - A memory-form hint NOP whose ModRM points at a `PAGE_NOACCESS` page must not fault, natively or translated. - **Controls that must fail:** one where the hint NOP evaluates its memory operand (it then faults on the inaccessible page), and one where it clobbers a register. - **Refusals:** `cldemote [rax]`, `rdsspq rax`, `prefetchw [rax]`. **Host note:** my test host is a Skylake. Windows does not enable MPX, so `0F 1A`/`0F 1B` execute 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 `RESERVEDNOP` range, or only `0F 1F`-adjacent forms plus ENDBR64/ENDBR32?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:10:10 +00:00
Author
Owner

@⁠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.

**@⁠R0Y00** on GitHub · 2026-11-24 12:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1476#issuecomment-7131852843) 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.
Author
Owner

@⁠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:

  • Accepted and lowered to a no-op: RESERVEDNOP encodings that are reserved hint NOPs on x64_zen2 with a documented no-effect — the 0F 19 /r, 0F 1D /r, 0F 1E /r (unprefixed) and 0F 1F /r forms, any ModRM. The memory operand is not evaluated: no address computation, no load, no fault.
  • Still refused: 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), the 0F 18 prefetches, 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.
  • Shared lowering only (tools/ffx_version_query.py); no per-translator change.

Fixture plan, source-built:

  1. Each accepted encoding between writes of known register and flag values; compare all GPRs and the arithmetic flags afterwards, native vs translated, in the default and /O2 builds.
  2. A memory-form hint NOP whose ModRM addresses a PAGE_NOACCESS page must not fault — this is the check that would catch an implementation that evaluates the operand.
  3. Negative controls that must fail: one where the hint NOP evaluates its memory operand (faults on the inaccessible page), and one where it writes a register.
  4. Refusal cases: 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).

**@⁠triggered02** on GitHub · 2026-11-24 13:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1476#issuecomment-7133316081) 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:** - Accepted and lowered to a no-op: `RESERVEDNOP` encodings that are reserved hint NOPs on x64_zen2 with a documented no-effect — the `0F 19 /r`, `0F 1D /r`, `0F 1E /r` (unprefixed) and `0F 1F /r` forms, any ModRM. The memory operand is **not** evaluated: no address computation, no load, no fault. - Still refused: `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`), the `0F 18` prefetches, `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. - Shared lowering only (`tools/ffx_version_query.py`); no per-translator change. **Fixture plan, source-built:** 1. Each accepted encoding between writes of known register and flag values; compare all GPRs and the arithmetic flags afterwards, native vs translated, in the default and `/O2` builds. 2. A memory-form hint NOP whose ModRM addresses a `PAGE_NOACCESS` page must not fault — this is the check that would catch an implementation that evaluates the operand. 3. Negative controls that must fail: one where the hint NOP evaluates its memory operand (faults on the inaccessible page), and one where it writes a register. 4. Refusal cases: `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).
Author
Owner

@⁠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 /0 as CLDEMOTE and 0F 18 /4, /6, /7 as MOVRS/PREFETCHI. It also lists 0F 1E /6 and several 0F 1E /7 register forms as reassigned, and 0F 1A/0F 1B as MPX. So "0F 1E /r unprefixed, 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.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-24 13:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1476#issuecomment-7133415468) @⁠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 /0` as CLDEMOTE and `0F 18 /4`, `/6`, `/7` as MOVRS/PREFETCHI. It also lists `0F 1E /6` and several `0F 1E /7` register forms as reassigned, and `0F 1A`/`0F 1B` as MPX. So "`0F 1E /r` unprefixed, 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.
Author
Owner

@⁠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:

  • ools/ffx_version_query.py: accept exact Code.ENDBR64 (F3 0F 1E FA) and Code.ENDBR32 (F3 0F 1E FB) as no-ops (;), matching by exact iced_x86.Code so RDSSPD/RDSSPQ (F3 0F 1E /1), CLDEMOTE,
**@⁠R0D4X** on GitHub · 2026-11-26 13:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1476#issuecomment-7193728501) Claiming the remaining **ENDBR64 / ENDBR32** follow-up slice of #1476 now that the RESERVEDNOP slice (1455727, 72a0929, 7368c1b6) is on main. Plan: - ools/ffx_version_query.py: accept exact Code.ENDBR64 (F3 0F 1E FA) and Code.ENDBR32 (F3 0F 1E FB) as no-ops (;), matching by exact iced_x86.Code so RDSSPD/RDSSPQ (F3 0F 1E /1), CLDEMOTE,
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#1476
No description provided.