Skip to content

feat :: audit-isa reports instructions a CPU target cannot run - #450

Merged
HaoZeke merged 13 commits into
developfrom
feat/isa-audit
Nov 27, 2026
Merged

HaoZeke merged 13 commits into
developfrom
feat/isa-audit

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

feat :: audit-isa reports instructions a CPU target cannot run

eb-local audit-isa PATH --target TARGET [--json] [--allow FILE] [--objdump PATH] runs objdump on every ELF file under PATH and prints, per file and feature, each instruction that needs a CPU feature the TARGET lacks, with a count and the first address.

  • TARGET is an EESSI subdirectory: x86_64/generic, x86_64/amd/zen2 to zen5, x86_64/intel/{haswell,skylake_avx512,cascadelake,icelake,sapphirerapids}, aarch64/{generic,neoverse_n1,neoverse_v1,neoverse_v2,a64fx}, aarch64/nvidia/grace, aarch64/google/axion, aarch64/aws/graviton{2,3,4}. A unique trailing part (zen3) works too.
  • Exit 0 when clean, 1 when any instruction exceeds the target, 2 on usage errors, a missing disassembler, or an objdump failure. --json keeps the codes.
  • x86-64: mnemonic, encoding (legacy, VEX, EVEX, XOP) and vector width pick the features from a table generated from iced-x86 (tools/isa_tables/gen.py). The report counts zmm instructions. RDSSP and INCSSP are not violations.
  • aarch64: mnemonic and operand rules for SVE, SVE2, BF16, I8MM, dot product, LSE, crypto, half-precision and pointer authentication outside the hint space.
  • Targets: archspec microarchitectures.json plus, for x86-64, the features GCC's -march enables for the same CPU. Sources and versions are in the header of src/isa/targets.tsv.
  • Code that selects its instruction set at run time (TBB, libomp, FFmpeg, x264, OpenSSL, libfabric, NumPy dispatch kernels, zlib-ng's AVX-512 kernels) is listed in src/isa/dispatch-allow.txt. A violation on a listed feature under /software/PACKAGE/ prints as dispatch and does not fail. --allow FILE replaces the list.
  • A feature or vector mnemonic the tables cannot judge prints as unclassified and never fails.

The code is in src/isa_audit.zig; main.zig only dispatches. Docs: the audit-isa section of the command reference, audit-isa.schema.json, a README line and a changelog entry.

Evidence

  • Unit tests (zig build unit): mnemonic to feature for x86-64 (EVEX zmm against ymm, VEX, XOP, BMI, assembler aliases) and aarch64 (SVE, SVE2, BF16, I8MM, LSE, FP16, hint-space PAC), target sets (zen3 has no AVX-512; zen4 has AVX-512 and BF16 but not VP2INTERSECT or FP16; icelake lacks BF16 and CLZERO, zen4 lacks SGX), objdump line parsing for both architectures, the allow list.
  • tests/test_audit_isa.py: recorded disassembly through a stand-in objdump for exit codes, per-feature counts, dispatch, --allow, --json against the schema, skipped architectures and objdump failure; and objects built with zig cc (-mcpu=znver4 -mprefer-vector-width=512 and znver3, neoverse_v1 SVE and neoverse_n1) audited with the host objdump, with exit 2 and the named reason where the host objdump cannot read the architecture.
  • On a build host, a znver4 object fails x86_64/amd/zen3 with AVX512F and passes x86_64/amd/zen4; a znver3 object passes both.
  • On installed libraries (libx265, libavcodec, libcrypto, 25.7M instructions) against x86_64/amd/zen3: AVX-512 families in all three, XOP and FMA4 in libavcodec and libcrypto (their CPU-dispatch code).

The command line is the one a CPU-target build step can call after a masked build: eb-local audit-isa <prefix> --target <target>, nonzero exit on failure.

Stack

Base: develop. This is the first of three PRs that merge in this order: feat/isa-audit (this one), feat/cpu-target, feat/cpu-target-vm. Each later branch contains this one and develop, so the three merge without conflicts. This PR contains nothing from the other two.

  • zlib is on the default dispatch list for avx512f, avx512bw, avx512dq, avx512vl and avx512vnni: zlib 2.3 is zlib-ng, whose functable.c and arch/x86/x86_features.c pick AVX-512 adler32, crc32, chunkset, compare256 and slide_hash kernels from a CPUID check at first use. A zen3-masked build of zlib-2.3.2-GCCcore-15.2.0 passes its audit with dispatch lines.

End-to-end evidence (Zen 5 host, EESSI 2026.06, audit-isa built from this branch)

  • zlib-2.3.2-GCCcore-15.2.0, built under the x86_64/amd/zen3 mask, audited against x86_64/amd/zen3: exit 0, dispatch: avx512f x204, avx512bw x81, avx512vl x73, avx512dq x9, avx512vnni x6 in libz.so.1.3.1.zlib-ng, then no instruction beyond x86_64/amd/zen3. The zen4-built tree against zen3: exit 0 with the same five features as dispatch.
  • Negative control, a local one-file library compiled with -march=native (ebl-vec): the zen3-built tree passes against zen3 and zen4 (exit 0, 79 instructions); the zen4-built tree against x86_64/amd/zen3 exits 1 with violation: avx512f x2, avx512dq x2, avx512vl x3, avx512vpopcntdq x2; against zen4 it exits 0.
  • bzip2-1.0.8-GCCcore-15.2.0 (no run-time dispatch): the zen4-built bunzip2 and bzcat fail against zen3 with avx512f x486, avx512bw x113, avx512vl x307, avx512dq x46, avx512vbmi x4 (exit 1); the zen3-built tree passes against zen3 and zen4.
  • zig build unit: 189 tests pass. zig build -Dtest-ops=true test: the same 43 failure lines as develop on this host, none new. CI: zig and shellcheck green (runs 45916897576 and 45916897568).

tools/isa_tables/gen.py writes the x86-64 mnemonic-to-feature table from
iced-x86, the aarch64 mnemonic rules, and the feature set of each EESSI
CPU target from archspec-json plus the GCC -march macros. The default
allow list of runtime-dispatch packages ships beside them.
… a CPU target

src/isa_audit.zig runs objdump on each ELF file under a prefix, maps each
mnemonic, encoding and vector width to the features it needs, and reports
the features the EESSI target lacks per file with counts. Runtime-dispatch
packages in the allow list are reported as dispatch. Exit 0 when clean, 1
for a violation, 2 on usage or tool errors.
…fer, and report work-directory errors by name
cli.md links json/audit-isa.schema.json, as it links the other schemas, but
only the org source tree had the file, so the pages build stopped on a
missing cross-reference target.
@HaoZeke
HaoZeke merged commit 5dad022 into develop Nov 27, 2026
12 of 13 checks passed
@HaoZeke
HaoZeke deleted the feat/isa-audit branch November 27, 2026 03:08
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.

1 participant