Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(arch): RISC-V jal panic and control-flow/compare classification on RISC-V, AArch64 and x86 - #468

Open
Wenzel wants to merge 2 commits into
intel:mainfrom
Wenzel:fix/arch-control-flow-classification
Open

Wenzel wants to merge 2 commits into
intel:mainfrom
Wenzel:fix/arch-control-flow-classification

Conversation

@Wenzel

@Wenzel Wenzel commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Instruction classification fixes, two commits (RISC-V, then AArch64 and x86).

 RISC-V
-  full execution trace of `jal`: panic (todo!() in the pinned yaxpeax-riscv)   (#419)
+  `jal` is formatted by tsffs: "jal ra, 0x8"
-  compares: SLT* BEQ BNE BGE BLTU BGEU                                         (#420)
+  compares: SLT* BEQ BNE BLT BGE BLTU BGEU
-  SLT/SLTU/SLTI/SLTIU log (rd, rs1)
+  SLT/SLTU/SLTI/SLTIU log (rs1, rs2 or imm)
-  call/ret: JALR JAL AUIPC
+  call/ret: JALR JAL                    # auipc does not transfer control

 AArch64                                                                        (#422)
-  control flow: ... CCMN CCMP CSINC CSINV CSNEG CSEL ...
+  control flow: ... BRAB ...            # conditional selects never change pc
-  calls: BL BLRAA BLRAAZ BLRAB BLRABZ
+  calls: BL BLR BLRAA BLRAAZ BLRAB BLRABZ

 i386 / x86_64                                                                  (#422)
+  i386 branches: JECXZ JCXZ
+  x86_64 branches: JECXZ                # JRCXZ with an address-size prefix

Compressed (16-bit) RISC-V instructions are still not decoded by the pinned yaxpeax-riscv. That part of #420 is not addressed here, only noted on the disassembler, so #420 should stay open.

Fixes #419
Fixes #422
Refs #420

Evidence

  • Before: Disassembler::disassemble_to_string on jal panics; no unit test covered RISC-V classification.
    After: new unit tests pass:
    jal_is_formatted_without_panicking
    auipc_is_not_control_flow
    blt_is_a_signed_less_than_compare_of_both_sources
    slt_compares_its_sources_not_its_destination
    
    and the existing x86 classification tests now also check jecxz/jcxz (i386) and jrcxz/jecxz (x86_64).
  • cargo fmt --check, cargo clippy -r: clean. Lib unit tests: 41 passed (37 on main, 4 new).

Not run under SIMICS on RISC-V or AArch64 targets. The AArch64 list changes have no unit test.

Merge Danger

Door: two-way

Blast Radius: coverage

Edge coverage changes on RISC-V and AArch64: auipc and the AArch64 conditional selects no longer add edges, AArch64 blr/brab now do. Coverage maps and corpora from earlier runs on these architectures are not comparable edge for edge with new runs. x86 only gains the rarely used jecxz/jcxz.

🤖 Generated with Claude Code

Wenzel and others added 2 commits November 17, 2026 23:48
…ssification

- Formatting a jal for a full execution trace reached a todo!() in the pinned yaxpeax-riscv (J-type immediate) and panicked inside the instruction callback. jal is now formatted by tsffs.
- BLT was missing from the compare instructions, so signed less-than branches were never logged by cmplog.
- SLT, SLTU, SLTI and SLTIU logged (rd, rs1) instead of the two compared values.
- AUIPC was classified as a call and a return although it does not transfer control, which added an edge on every auipc.

Compressed (16-bit) instructions are still not decoded by the pinned yaxpeax-riscv. This is now noted on the disassembler.

Fixes intel#419
Refs intel#420

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- AArch64: BLR is now a call and BRAB a branch. CCMN, CCMP, CSEL, CSINC, CSINV and CSNEG never change pc and are no longer control flow.
- i386: JECXZ and JCXZ are branches (JRCXZ does not exist in 32-bit mode).
- x86_64: JECXZ (JRCXZ with an address-size prefix) is a branch.

Fixes intel#422

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control-flow classification gaps on AArch64 and i386 RISC-V: jal panics (todo!()) when full execution traces are enabled

1 participant