cpu: lower PUSHF, PUSHFQ, POPF, and POPFQ instructions #1466
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1473"
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 Ammmae0x on 2026-11-24T12:24:12Z.
Change
Lower the uncovered x64
Integergroup instructionspushf,pushfq,popf, andpopfqfromdocs/coverage/x64_zen2.tsvintools/ffx_version_query.py:flag_stack_depths) startingrspatframe + FRAME_WORDS(FLAG_STACK_LIMIT = 128bytes), steppingrspby2(pushf/popf) or8(pushfq/popfq), enforcing depth0at everyret, call, indirect branch, and external exit, and rejecting underflow, overflow, mismatched depths at control-flow joins, disallowed instruction prefixes, explicitrspregister tampering orleaaliases, and[rsp + disp]accesses outside the pushed region.DF=0exit analysis (flag_definedness) supportingentry_state="defined"(default Windows x64 ABI: status flags undefined,DF=0at entry) andentry_state="canonical"(status flags defined at entry), requiring defined{CF, PF, AF, ZF, SF, OF}beforepushf/pushfq, tracking per-byteDFtaint across stack pushes and[rsp]stores, and rejecting anyret, call, indirect branch, or external exit whereDFmay be1.pushf/pushfqandpopf/popfqwith ring-3RFLAGSbit normalization (preserving bit1andIFin0x0202, updatingCF/PF/AF/ZF/SF/DF/OF/NTinpopfand additionallyIDinpopfq, and clearingIOPL/reserved bits), and record the slice indocs/experiments.mdandCMakeLists.txt.Verification
Verified on commit
f5933122(rebased cleanly ontoupstream/main06e2ff78) in bothdev(Debug) andrelease(/O2) presets with zero compiler errors or warnings:& .\tools\dev.ps1; ctest --preset dev -N->923total tests (cpu_aot_integer_flags,cpu_aot_integer_pushf_popfpresent).devbuild and targeted tests:cmake --build --preset dev --target cpu_integer_pushf_popf_original cpu_integer_pushf_popf_original_lifted cpu_integer_pushf_popf_altered_lifted cpu_integer_pushf_popf_controls cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered_lifted cpu_integer_flags_controlsctest --preset dev --no-tests=error -R "^cpu_aot_integer_(pushf_popf|flags)$" -V->
2 passed, 0 failed, 0 skipped(cpu_aot_integer_flags: 460 differential cases + 4 alternate-encoding checks + 38 unit and 11 PE-patched rejection controls;cpu_aot_integer_pushf_popf: 513 differential cases across 22 exports + 5 alternate-encoding/entry-state checks + 36 unit and 11 PE-patched rejection controls + dead-read,ALTER_IMM, 8 mutated-C++, and output-mutation controls).release(/O2) build and targeted tests:cmake --build --preset release --target cpu_integer_pushf_popf_original cpu_integer_pushf_popf_original_lifted cpu_integer_pushf_popf_altered_lifted cpu_integer_pushf_popf_controls cpu_integer_flags_original cpu_integer_flags_original_lifted cpu_integer_flags_altered_lifted cpu_integer_flags_controlsctest --preset release --no-tests=error -R "^cpu_aot_integer_(pushf_popf|flags)$" -V->
2 passed, 0 failed, 0 skipped..\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0;pushf,pushfq,popf,popfqcovered undercpu_aot_integer_pushf_popf)..\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py->Checked 16 Markdown files and 333 links.(exit 0)..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py->Checked 1210 tracked source, script and build/CI files: no bidirectional controls.(exit 0).Evidence and follow-up
tests/cpu/integer_pushf_popf.asmandtests/cpu/integer_pushf_popf.defare original MASM x64 test fixtures written for this repository.sahfoutside the x87 profile,TF/ACtrap semantics, and title CPU code execution remain out of scope for this slice.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T13:29:02Z.
Review: CHANGES_REQUESTED
The existing native/lifted fixture passes in Release. The analysis marks arbitrary writes to pushed flag words as possible DF, but it does not constrain the unmodeled control bits. In particular, generated POPF/POPFQ drops TF although a guest flag image can make it observable. Please limit the accepted stack edits to flag images proven to leave unmodeled control bits clear, or model those effects explicitly. A static rejection control for an input-derived flag word is sufficient for the restricted slice.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T14:28:29Z.
Updated
flag_definednessintools/ffx_version_query.py(commit7332169b) to propagate per-byte may-be-1 bitmasks across GP registers and pushed flag-stack edits, statically rejectingpopfunlessTF(0x0100) is proven clear andpopfqunless bothTFandAC(0x040100) are proven clear.Also masked input-derived flag words in
tests/cpu/integer_pushf_popf.asm, added positive masked-stack-edit and unconstrainedTF/ACrejection controls (42 unit rejections, 13 PE-patched DLL rejections) intests/cpu/integer_pushf_popf_check.pyanddocs/experiments.md, and re-verifiedcpu_aot_integer_pushf_popfandcpu_aot_integer_flagson bothdevandreleasepresets.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T15:13:58Z.
The fixture carries its own mutation matrix; I confirmed the case counts and re-ran it
Independent reviewer, not the author. Reviewed the current head; nothing pushed to the branch.
Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, MASM from the same toolset.
What I checked rather than assumed
a comparison of the new path against itself.
produced the same number as another would suggest it was hitting a shared early-out rather than its own flag; the
distinct counts say each one perturbs something specific.
ctrl_rsp_step_wrongat 4 is the smallest and is the one Iwould have expected to be easiest to miss — it is caught.
ctrl_af_bit5at 6 andctrl_pf_full_widthat 8 are the two width/bit-position errors, which are exactly the mistakesa hand-written flag packer makes; both are caught, so the bit layout is asserted rather than only the flag values.
What I did not verify
The individual case set behind "513 cases across 22 exports" — I did not enumerate the exports or check that the flag
matrix covers each flag in both directions per export. The summary claims it; confirming it would mean instrumenting the
fixture, which is yours to decide.
Verdict
Reviewed the current head. Builds clean, the case runs in 1.37 s, and the in-tree controls already cover eight distinct
partial implementations plus the immediate-form and dead-read cases. No objection from me.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:11:38Z.
Review: COMMENTED
Review of head
7332169b. Result: no defect found in the lowering or in the static analysis. Findings below are test-coverage gaps (P2) and one undocumented entry-state assumption. The earlier change request (unmodeled TF/AC reachable through guest-controlled flag words) is addressed byflag_definedness; I re-checked it independently (below).Verified
Linux x86-64 only. The MASM fixture was translated line by line to GNU as (intel syntax,
.seh_*for the PE copy that the lowering tool reads, ms-ABI shim for the native copy). Lifted C++ was built with g++ -O2 plus a small shim for the MSVC-only constructs (__unaligned,__declspec,RaiseException,<intrin.h>).integer_pushf_popf_check.pyemiton the rebuilt fixture, then native vs lifted vs the independent Python RFLAGS model, all 22 differential exports: 513/513 cases equal, 0 mismatches. Guard bytes intact.check_alt_encodings_and_rejectionson the rebuilt PE:9 alternate-encoding/entry-state checks, 42 unit rejection controls, and 13 PE-patched rejection controls passed.66 9C/48 9C/66 48 9C/48 66 9C/67 9Cchange RSP by 2 / 8 / 8 / 2 / 8. iced decodes them as PUSHFW / PUSHFQ / PUSHFQ / PUSHFW / PUSHFQ (same for POPF), which is whatFLAG_STACK_DELTASassumes. REX.W beats 66h, and67his ignored. The lowering accepts the67form consistently.and/or/movon[rsp]+ POPF/POPFQ, then a PUSHF/PUSHFQ capture), 10 random inputs each, native vs lifted: 0 mismatches. A DF leak at return was also checked natively: none.flag_definedness(about 1100), the word that POPF/POPFQ would pop was captured natively (pop r11in place ofpopfq) on 60 inputs: TF/AC were never set. The probe is sensitive: it reports unsound acceptances for mutants that treat a guest-memory load as zero (40-46 per 200 programs), clear all bits in BTR, or use AND instead of OR/XOR.integer_flags,flag_conditions,cmov_setcc,bit_ops,carry_rotates,branch) is byte-identical betweenorigin/mainand this head.CMakeLists.txtwiring mirrors theinteger_flagsblock (variants,ALTER_IMM, controls library,SKIP_RETURN_CODE 77);.deflists the 23 exports in the.asm; counts quoted indocs/experiments.md(23 exports, 22 differential, 513, 9/42/13) match what I reproduced.integer_pushf_popf_check.pyis written from the architectural rules (bit 1 and IF forced, NT/ID writable, IOPL/RF/VM/VIF/VIP dropped, 16-bit POPF keeps bits 16+), not copied from the lowering. Good.Mutation of the PR (each applied to all occurrences in the lowered C++ and rebuilt, 513 cases re-run): dropping OF from PUSHF, IF from PUSHF, SF/PF/AF from POPF, DF/NT from POPF, NT/ID from POPFQ, DF/NT from PUSHFQ, and a wrong POPF step are all detected. Two are not, see P2-1.
Findings
P2-1 (proven): 16-bit PUSHF never pushes DF=1 or NT=1 in the fixture.
tools/ffx_version_query.py, PUSHF statement inlower(the(static_cast<uint16_t>(direction) << 10)and(static_cast<uint16_t>(nt_flag) << 14)terms). Removing either term from every lowered PUSHF leaves all 513 cases and the 8 mutated-C++ controls passing. All PUSHF exports run with DF=0/NT=0; NT/DF are only observed throughpushfq. The code is correct (native == lifted below); the test would not notice a regression.Repro (fixture addition,
tests/cpu/integer_pushf_popf.asm, inputsa0in {0, 0x400, 0x4000, 0x4400, 0x8D5}):Native / lifted:
0x202 / 0x202,0x602 / 0x602(DF),0x4202 / 0x4202(NT),0x4602 / 0x4602,0xad7 / 0xad7. With the two terms removed the lifted result is0x202for the DF and NT inputs.P2-2 (proven by mutation): several may-be-1 propagation paths are untested.
_read_op_may_one/_update_may_one_state/ the joins inflag_definedness(tools/ffx_version_query.py). These mutations all leave the 42 unit controls, 13 PE controls and 9 accept cases passing:unconstrained_*controls only use an input register (rcx), nevermov reg, [mem];or/xorcombining with&,btr reg, immclearing everything,shl/shrwrong, high-byte (ah) read shifted wrongly,btr [rsp], immreplaced by 0;&(the only join control,unconstrained_join_one_arm_popfq, is decided by the register join).The AND/MOV/stack-OR/AC/TF/DF paths are covered (mutants killed). Suggested minimal controls: one rejection with
mov rcx, [rdx]feedingmov [rsp], rcx; popfq; one pair (accept/reject) each for a masked-then-ored register,shl/shr,btr; and one join where one arm edits the pushed word and the other does not.P2-3 (proven, low likelihood): entry NT/ID (and AC) are assumed 0.
lowerinitialisesnt_flag=false, id_flag=falseand the pushed word never carries AC. Nativeadd rax,0 / pushfq / mov rax,[rsp] / popfq / retreturns0x206normally,0x200206if the caller enters with ID set and0x4206with NT set; the lifted function returns0x206in all three cases. The doc section states the entry assumptions for status flags and DF only. Either state this assumption (NT/ID/AC clear at entry) or seed them from the guest.nit:
entry_state="canonical"has no in-tree caller.It is only passed by one
alt_acceptcase ininteger_pushf_popf_check.py; with it, an entrypushfqobserves fabricated all-clear status flags. Consider dropping the option or documenting where it will be used.Not verified
cmake --preset dev/release,ctest(cpu_aot_integer_pushf_popf,cpu_aot_integer_flags), MSVC /O2 code generation of the lifted C++, PE unwind data produced by MASMPROC FRAME(I used.seh_proc), and the other tests that sharetools/ffx_version_query.pybeyond the byte-identical-output comparison above.pushfas66 9C) were checked separately by byte, not by running the MASM output.Commands executed locally:
gh pr view,gh pr diff,git fetch pull/1473/head,git worktree add,x86_64-w64-mingw32-gcc -shared -nostdlib(PE copy of the translated fixture),gcc -shared -nostdlib(native copy),python tests/cpu/integer_pushf_popf_check.pyentry points (emit,check_alt_encodings_and_rejections),g++ -O2 -shared -fPICon the emitted C++, ctypes differential runs, and the mutation/fuzz scripts described above.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:23:52Z.
Review: COMMENTED
Re-review of head
a346a3f189ca1a4990a9ea757558776cbbc5d80b. My previous review was at7332169b; the PR added one commit (a346a3f1, +162/-13 in 4 files: docs, the.asm/.deffixture and the check). Comment only, not an approval.Verdict: 0 P1 / 0 P2. All three P2 findings and the nit from my last review are closed. Two P3 notes remain.
Linux limits. Linux x86-64, Python 3, iced-x86 and pefile in a venv. Not run: MSVC/MASM build,
cmake --preset dev|release,ctest(cpu_aot_integer_pushf_popf,cpu_aot_integer_flags), MSVC /O2 code, PE unwind data, and the 13 PE-patched rejection controls (they need the built DLL). The author's counts (519 cases over 23 differential exports, 15 alternate-encoding checks, 50 unit rejections, 10 C++ mutation controls) are theirs; what I reproduced is listed below.Previous findings
op_pushf_df_ntis the repro I gave, with inputs0, 0x400, 0x4000, 0x4400, 0x08D5, 0x204400, plus controlsctrl_pushf_df_droppedandctrl_pushf_nt_dropped. I hand-encoded the same sequence, lowered it with the realflag_stack_depths/flag_definedness/lower, compiled with g++ -O2 (small shim for the MSVC-only constructs) and ran it against the native instructions: 40 cases, 0 mismatches. Removing the DF term from the lowered PUSHF: 16/40 mismatch (for example0x4ed7native vs0x4ad7). Removing the NT term: 16/40 mismatch (0x4ed7vs0x0ed7).chhigh-byte reads, register OR/XOR/SHL/SHR/BTR,btr [rsp], imm(a directflag_definednesspair) and a one-arm stack join. I extractedcheck_alt_encodings_and_rejectionsup to the PE-patch section and ran it at this SHA: "15 accept; 50 unit rejections" pass. Mutations oftools/ffx_version_query.py, each followed by that run and then restored:non_rsp_mem_load_popfq)or_tf_reg_popfq)btr_reg_wrong_bit_popfq)shl_tf_reg_popfq)btr [rsp], immresult forced to 0btr_stack_bad)ac_or_stack_popfq)join_stack_one_arm_ac_popfq)old_df or after_dfchanged toanddocs/experiments.mdnow says DF, NT, ID and AC are assumed clear at entry. That is an honest statement of the profile. The lowering still does not read them from the caller.entry_state="canonical"has no caller): addressed. The doc says the option is tested in the suite, and it is (rex_w_pushfq_popfqruns withcanonical).Remaining notes (non-blocking)
flag_definedness(old_df or after_df) is not pinned by any control; changing it toandleaves all 15 + 50 controls green. A control with one arm that sets DF and one that clears it, reaching aret, would pin it.origin/main.git merge-tree --write-tree origin/main HEADis clean (exit 0), so no conflict, but please rebase before anyone relies on the CI result.Other checks:
git diff --check origin/main...HEAD: clean.tests/docs_links_check.py(16 files, 333 links at this base) andtests/bidi_controls_check.py(1210 files): clean.tests/form_coverage_check.py: passed. The.deflists 24 exports and the.asmhas 24PROC FRAMEblocks, matching the doc's "24 functions". 513 + 6 new cases = 519, as quoted.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T20:14:18Z.
Updated PR #1473 (commit
a346a3f1) to address the P2 findings:pushfcapturingDF=1/NT=1): Addedop_pushf_df_ntintests/cpu/integer_pushf_popf.asm,tests/cpu/integer_pushf_popf.def, andtests/cpu/integer_pushf_popf_check.py, plusctrl_pushf_df_droppedandctrl_pushf_nt_droppedC++ mutation controls (diverging on 3 cases each).flag_definednessmay-be-1propagation coverage): Added accept/reject pairs intests/cpu/integer_pushf_popf_check.pyfor non-RSP memory loads (mov rcx, [rdx]), high-bytechreads (mov byte ptr [rsp+1], ch), masked-then-or/xorregisters,shl/shr,btr reg, imm, a directflag_definednessaccept/reject pair forbtr [rsp], imm, and a single-arm post-push[rsp]orjoin (join_stack_one_arm_ac_popfq).docs/experiments.mdthatlowerassumesNT,ID, andACare0at function entry alongsideDF = 0.Verified
cpu_aot_integer_pushf_popf(519 cases across 23 differential exports, 15 alternate-encoding/entry-state checks, 50 unit rejection controls, 13 PE-patched rejection controls, 10 C++ mutation controls) andcpu_aot_integer_flagsin bothdevandrelease, plusform_coverage_check.py,docs_links_check.py, andbidi_controls_check.py. AI-assisted.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:01:21Z.
Review: APPROVED
Independently reviewed
a346a3f1integrated overmain4b0350ea(tree36f290b3). The merge is clean (CMakeLists.txt,docs/experiments.mdandtools/ffx_version_query.pyauto-merged) andgit diff --cached --check origin/mainis clean.Earlier finding (R0Y00, changes requested on
f5933122): addressed.flag_definednessnow tracks may-be-1 masks for the GP registers and the pushed flag bytes. It rejects POPF unless TF is proven clear, and POPFQ unless TF and AC are proven clear. The input-derived rejection controls R0Y00 asked for are there (unconstrained_input_mem_write_popf(q), also as PE-patched controls). Removing the TF/AC check, or treating the registers as 0 at entry, failscpu_aot_integer_pushf_popf(table below).What I ran. Full
devandreleasebuilds of the trial merge, then:/O2.cpu_aot_integer_pushf_popfreports 519 native/lifted/reference cases over 23 exports matched, 15 alternate-encoding/entry-state checks, 50 unit and 13 PE-patched rejection controls.cpu_aot_integer_flagsreports 460 LAHF cases matched.tools/ffx_version_query.pyis shared, so I ran every^cpu_test indev. 302 tests: 301 pass andcpu_aot_sysdescis the existing skip.main:cpu_aot_integer_pushf_popfis not registered.Mutants in
tools/ffx_version_query.py, each applied alone. For each one I rebuilt the fixture targets indev, rancpu_aot_integer_pushf_popf, and restored the file from its raw bytes.git diff --quietwas clean afterwards.df_leak_*control accepted)[rsp]access 8 bytes past the pushed depth allowedPF_DEFINERSThe two analysis survivors are coverage gaps, not defects. The real tool rejects both programs below. I ran them through
lowerwith the real module and with each mutant loaded in memory:xor eax,eax, a host op that writesrax,add r9d,1,pushfq,mov [rsp],rax,popfq,ret, withhost_ops={0x1002: "rax = load<word>(rcx);"}. The real tool rejects it ("popfq may set unmodeled control flag(s) TF, AC"). With the register masks kept across the host op, it is accepted.join_stack_one_arm_ac_popfqmirrored, with the AC edit on the taken arm:add rax,rcx; pushfq; test ecx,ecx; je BAD; jmp JOIN; BAD: or qword [rsp],0x40000; JOIN: popfq; cld; ret(4801c89c85c97402eb0848810c24000004009dfcc3). The real tool rejects it. With only the last-arriving arm kept, it is accepted. The shipped control is still rejected under that mutant, because there the AC edit is on the fall-through.Adding these two programs as rejection controls would pin both paths. The x87 and RSP-binding refusals have no control. Each would need a one-line case.
Non-blocking. The registration is in
CMakeLists.txt.tests/cmake/fragments arrived after this PR opened (#2655), so I'm not asking for a move.Verdict: approve on
a346a3f1. R0Y00's changes-requested review onf5933122still stands, so I am not merging. That is R0Y00's call.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass ona346a3f1.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:15:05Z.
Thanks for the careful TF/AC work. This is a review of head
a346a3f1, posted as a comment only: I'd merge it with the nits below, but R0Y00's CHANGES_REQUESTED review onf5933122still stands, so the PR needs R0Y00's re-review before it can merge.What I checked (trial merge onto main
1f07b2c1, pure Python, iced-x86 1.21.0). Not run: MSVC/MASM build, Wine, the native differential and the 13 PE-patched controls.git merge-tree --write-tree origin/main a346a3f1→ rc=0, andgit diff --checkis clean. The branch is 2298 commits behind main.0x40100). Withbad_bits = 0the unit check fails (btr_stack_bad was unexpectedly accepted by flag_definedness).integer_pushf_popf_check.pygives 15 accepts and 50 unit rejections. Theinteger_flags_check.pyunit rejections (38), the x87_compare rejections andtests/form_coverage_check.pyall pass. A static recount gives 23 exports and 519 cases, which matches the doc.ctest --preset pr, and that preset's filter doesn't includeinteger_pushf_popf. The name appears 0 times in the Windows job log, so CI hasn't run the new test.Should fix. For each of these, a one-line mutant of
flag_definednesskeeps the unit check green at 15/50 and accepts a program that the real tool rejects:after_regs = before_regs). Witness31c0488b014183c1019c488904249dc3, with a host op at 0x1002 that loads rax from guest memory. The real tool givespopfq may set unmodeled control.after_stack). Witness4801c89c85c97402eb0848810c24000004009dfcc3, with the AC edit on the taken arm. The real tool rejects it.join_stack_one_arm_ac_popfqputs the edit on the fall-through, so it can't catch this.old_df and after_df). Witness83c0019c9d85c97403fdeb01fcc3, withstdon one arm andcldon the other. The real tool givesdirection flag may be set.Adding the three witnesses as rejection controls would pin these.
Nits: the x87 and RSP-binding refusals have no control, and both mutants stay green. The integer_flags controls
out_of_scope_pushfandout_of_scope_pushfqnow reach the new flag-stack diagnostics, and its doc paragraph still listspushf/popf/pushfq/popfqamong the forms that "also reject". "per the Windows x64 ABI" covers DF only; NT, ID and AC being clear is a profile assumption. The test is registered in CMakeLists.txt, while main now usestests/cmake/fragments.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T08:36:53Z.
I checked JohnConnorNPC's three surviving
flag_definednessmutants ona346a3f1:tools/ffx_version_query.pyin memory, changed only the join'sold_df or after_dftoold_df and after_df, and lowered83c0019c9d85c97403fdeb01fcc3, which isadd eax,1; pushfq; popfq; test ecx,ecx; je L; std; jmp J; L: cld; J: ret. The real tool rejects it withdirection flag may be set at ret, and the mutant accepts it. The shippeddf_leak_*controls are all straight-line, so none of them reaches the join.I agree that the three witnesses would make good rejection controls. I'm still treating these as coverage gaps rather than defects, so my approval of
a346a3f1stands. R0Y00's changes request onf5933122still needs R0Y00's re-review.The CI point is also correct. The
prpreset's include list onmaindoesn't matchinteger_pushf_popf, so CI hasn't run the new test. My approval relied on localdevandreleaseruns.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-28T10:52:36Z.
Addressed the remaining coverage and doc items in
5e007e1a(merged withupstream/mainec71c290):flag_definednessjoin/host-op witness controls intests/cpu/integer_pushf_popf_check.py: host-op GP register reset (31c0488b014183c1019c488904249dc3withhost_ops={0x1002: "rax = load<word>(rcx);"}), stack-byte join on taken arm (4801c89c85c97402eb0848810c24000004009dfcc3), and DF join acrossstd/cldarms (83c0019c9d85c97403fdeb01fcc3).fld1; fstp st(0); ...; pushfqunderx87=True) and explicitRSPbinding alongside flag-stack instructions.docs/experiments.md: removedpushf/popf/pushfq/popfqfrom theinteger_flagsrejection list, clarified thatDF=0at entry follows the Windows x64 ABI whileNT/ID/ACclear at entry is a profile assumption, and updated the control counts.Verified locally on Windows in both
devandrelease(/O2):cpu_aot_integer_flagsandcpu_aot_integer_pushf_popfpassed (519 differential cases, 15 alt checks, 52 unit + 4 host/profile controls, 13 PE-patched controls), all 5 targetedffx_version_query.pymutants killed, andform_coverage_check.py/docs_links_check.py/bidi_controls_check.pyexited 0.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T11:02:28Z.
Review: APPROVED
Retested
5e007e1aintegrated overmainec71c290(tree5ff54a06). The trial merge is clean andgit diff --cached --check origin/mainis clean. This follows my approval ofa346a3f1.What changed since
a346a3f1. Two commits, both by the author:04aaba0cmergesmainec71c290.git show --remerge-diff 04aaba0cis empty, so nothing was resolved by hand. The PR's diff oftools/ffx_version_query.pyagainst its base is line-for-line the same as ata346a3f1.5e007e1atouches onlytests/cpu/integer_pushf_popf_check.py(+37) anddocs/experiments.md. No lowering or analysis code changed.Earlier notes, checked at this head. These were the coverage gaps from my review of
a346a3f1, plus the DF-join one from tedin7 and JohnConnorNPC that I reproduced in a comment. None was blocking.a346a3f15e007e1a31c0488b014183c1019c488904249dc3)POPFQ accepted RAX after host-op overwritejoin_stack_taken_arm_ac_popfqorchanged toanddf_join_one_arm_std_popfqflag-stack sequence accepted alongside x87Each mutant was applied alone to
tools/ffx_version_query.py. For each one I rebuilt the lifted and controls targets indev, rancpu_aot_integer_pushf_popf, and restored the file from its raw bytes.git diff --quietwas clean afterwards. Ata346a3f1the first four survived the same run (my review's table), and the DF-join mutant accepted the witness that is nowdf_join_one_arm_std_popfq(my later comment). That is the negative control for the new cases.R0Y00's finding on
f5933122(unmodeled TF/AC reachable through an edited flag word) was addressed ata346a3f1, and that code is unchanged here.What I ran.
/O2, no skips.cpu_aot_integer_pushf_popfreports 519 native/lifted/reference cases over 23 exports matched, 15 alternate-encoding/entry-state checks, 52 unit and 13 PE-patched rejection controls (50 unit controls ata346a3f1).cpu_aot_integer_flagsreports 460 LAHF cases matched.tools/ffx_version_query.pyis shared, so after a fulldevbuild I ran every^cpu_test. 302 tests: 301 pass andcpu_aot_sysdescis the existing skip.docs/experiments.md(52 unit controls, four host/profile controls, 13 PE-patched) match the test output and the check file.One more surviving mutant (non-blocking). Changing the register join in
flag_definednessfroma | btoa & bleavescpu_aot_integer_pushf_popfgreen.unconstrained_join_one_arm_popfqdoes not pin it: the worklist takes the branch target first, the unmasked value reaches the pushed bytes, and the stack join's|keeps it there, so that control is still rejected under the mutant. A witness with the wide value on the fall-through instead:xor eax,eax; test ecx,ecx; je J; mov rax,rcx; J: add r9d,1; pushfq; mov [rsp],rax; popfq; ret(31c085c974034889c84183c1019c488904249dc3, bindingrcx = a;)I loaded the tool in memory with and without the mutant and called
loweron it. The real tool rejects it (popfq may set unmodeled control flag(s) TF, AC); the mutant accepts it. This is a coverage gap, not a defect, and one more rejection control would close it.Also non-blocking. CI's
prpreset include list does not matchcpu_aot_integer_pushf_popf, so CI has not run the new test; the results above are from local runs. The registration is still inCMakeLists.txtrather than atests/cmake/fragment.Verdict: approve on
5e007e1a. I am not merging it: R0Y00's changes-requested review onf5933122still stands.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on5e007e1a.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:24:31Z.
Re-review of head
5e007e1a, trial-merged ontomainc04e0dd6(git merge-tree --write-treeexits 0,git diff --checkclean). Pure Python on Linux (iced-x86), no MSVC/MASM build, so the native/lifted differential and the 13 PE-patched controls are not re-run here.Since my comment on
a346a3f1:04aaba0cis a clean merge ofmain(git show --remerge-diff 04aaba0cprints nothing). After it, the PR's diff oftools/ffx_version_query.pyandtests/cpu/integer_pushf_popf_check.pyhas the samegit patch-idas ata346a3f1.5e007e1aadds the controls I asked for. I applied each one-line mutant offlag_definednessto a fresh copy of the merged tree and ran the DLL-free part of the check. Each now fails for its own control:after_regs = before_regs):UNIT FAIL: POPFQ accepted RAX after host-op overwritejoin_stack_taken_arm_ac_popfq: translator unexpectedly accepted rejected controlor→and:df_join_one_arm_std_popfq: translator unexpectedly accepted rejected controlflag-stack sequence accepted alongside x87flag-stack sequence accepted with explicit RSP bindingUNIT OK: 15 accept, 52 unit rejections. Theinteger_flagsunit check gives38 unit rejections, and the x87_compare rejections pass.form_coverage_check,docs_links_checkandbidi_controls_checkexit 0. A static recount still gives 23 exports and 519 cases, which matches the doc.integer_flagsparagraph no longer lists the flag-stack forms as rejected, and the entry-state sentence now limits the ABI claim to DF. The new counts (52 unit, four host/profile, 13 PE-patched) match the check file.MUST: none.
SHOULD: none from me. I won't repeat the register-join note from the latest approval.
NIT: the
integer_flagscontrols are still namedout_of_scope_pushf/popf/pushfq/popfq(integer_flags_check.py), although these forms are now in scope and fail on flag-stack balance. Renaming them is optional.From my side this is ready to merge. It stays blocked on the changes request from
f5933122. That request (TF/AC on an edited flag word) was addressed ata346a3f1, and that code is unchanged at this head, so it needs a re-review or a dismissal by the reviewer who opened it.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-12-01T03:21:56Z.
@R0Y00 Friendly re-review ping: your
CHANGES_REQUESTEDreview onf5933122is currently the only merge block on this PR.Head
5e007e1aaddresses unmodeled control-bit constraints (TF/ACmay-be-1 tracking across GP registers and pushed flag bytes plus input-derived rejection controls). All 5 CI checks pass,git merge-tree --write-treeontoupstream/main(1c634037) exits0, and@pigalothas reviewed and approved5e007e1a.Could you re-review when you have a moment so this can land? Thank you!
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T12:18:38Z.
Review: APPROVED
The earlier POPF/POPFQ finding is addressed by the may-be-set analysis for TF and AC and the input-derived flag-image refusal controls. Pigalot's independent current-head review and its source-built differential and mutation evidence cover this revision. I checked the current trial merge and required Windows CI, both clean.