Skip to content

Running campaigns

hfim run executes a campaign file. A campaign injects one fault per simulator run and compares each run with a fault-free reference run of the same program, the golden run. hfim run builds the benchmark when needed, runs the golden run when needed, then performs one run per injection and classifies each one.

The same campaign file runs on this machine or on a server; only the command line chooses where. This page covers both, then how to read the results and how to replay the exact faults of an earlier campaign.

Run locally

  1. Enter the campaign directory created by hfim init.
cd my-campaigns
  1. Run the campaign.
hfim run campaigns/fibonacci/register.yaml
  1. Read the end of the output.
Campaign complete: fibonacci_20261127_165328_734175
Results: results/fibonacci_20261127_165328_734175/injections.csv

Just above these lines, the log lists the outcome distribution: each outcome that occurred, with its count and percentage. The outcomes are masked (no visible effect), sdc (silent data corruption: wrong result, nothing noticed), detected, crash and timeout; Fault classification defines each one.

The results are in results/<campaign_id>/ (the campaign's output_dir, results by default). The campaign id is <benchmark>_<timestamp>, or <benchmark>_<campaign_label>_<timestamp> when the campaign sets campaign_label. The same seed on the same ELF (Executable and Linkable Format) file, the compiled benchmark, produces the same faults. To repeat a list of faults exactly, even on a changed setup, see Replaying exact faults.

hfim run prints one line per preparation step, with the reason. These lines come from a first run of fibonacci, where nothing exists yet:

fibonacci: build: build 404c0b04eb942838 does not exist yet
fibonacci: measure a new Golden: golden does not exist yet (it follows the new Build)

On the next run both are reused:

fibonacci: reuse: build 404c0b04eb942838 matches its Inputs
fibonacci: reuse: golden 9405de63bf505fbc matches its Inputs

The hexadecimal value is the record key, explained in The golden run. When a setting changed, the line names it, in the form golden <old key> is stale, this campaign needs golden <new key>: <group> <key> was <old value>, now <new value>.

Options

Option Effect
--workers N run N injections at once; overrides num_workers (see Parallel workers)
--inject-index I run only injection I, to reproduce one row of injections.csv
--campaign-id CID name the results directory instead of generating the name
--no-build never build the benchmark, even when no ELF exists
--no-golden never run the golden run; refuse when it is missing or stale
--allow-stale use the closest golden run when the matching one is missing, and record the difference in provenance.json
--explain print what would be built, measured or reused, the reason, and where the campaign would run; run nothing
--log-level LEVEL DEBUG, INFO, WARNING or ERROR
-v same as --log-level DEBUG
--log-file PATH log file; default logs/fim.log
--on NAME run on that server (see On a server)
--local run on this machine, whatever HFIM_ON or hfim remote use say

Each preparation step is also a command of its own:

hfim build benchmarks/fibonacci                                    # compile only
hfim golden fibonacci --config campaigns/fibonacci/register.yaml   # golden run only
hfim prepare campaigns/fibonacci/register.yaml                     # build, golden run and checkpoint when due

hfim prepare prints the same preparation lines as hfim run. With --json it prints one JSON (JavaScript Object Notation) object instead, with the record keys, the number of injections and the plan. --build-only builds when due but measures no golden run and takes no checkpoint. --no-build, --no-golden and --allow-stale work as for hfim run.

permission denied on /var/run/docker.sock The account cannot reach the Docker daemon. On Linux:
sudo usermod -aG docker $USER
newgrp docker
docker ps
`newgrp` applies the new group to the current shell; a new login applies it to every shell. Membership of the `docker` group is equivalent to root on that machine. On a shared machine, ask the administrator or use [rootless Docker](https://docs.docker.com/engine/security/rootless/).
cannot connect to the Docker daemon Docker is not running. Run `sudo systemctl start docker` (Linux) or open Docker Desktop (macOS), then `docker ps`.
Any other failure before the first injection Run `hfim doctor`. It reports the tool version, whether Docker is running, which simulators are registered, and whether the SDK (software development kit, which compiles the benchmark) is present and complete. A line marked `not installed` names the missing component.

The golden run

The golden run executes the benchmark once with no fault. It records the instruction count, the execution time and the values of the observable variables the campaign names (observable_outputs). Every injection is classified against it. The execution time sets timeout: auto (1.5 times the golden time, with a 30 s floor that covers simulator and debugger start-up; timeout_factor and timeout_floor change both).

hfim golden fibonacci --config campaigns/fibonacci/register.yaml

The log names each file the campaign includes and the keys it gave:

Using included file campaigns/fibonacci/fibonacci.yaml: benchmark, observable_outputs

Golden runs are stored under golden/<benchmark>/<record key>/. The record key is a hash of everything the golden run depends on, so several golden runs of one benchmark coexist and each campaign uses the one that matches it.

When the build and the golden run are repeated

hfim run compares content, not file dates. Every campaign key belongs to one group, and the group decides what a change to that key invalidates.

A change to Repeats Keys
the program build, golden run, checkpoint benchmarks/<name>/ sources, arch, build_optflag, build_runtime, build_toolchain; toolchain, build, build_inputs in hfim.yaml
the execution setup golden run, checkpoint xlen, simulator, simulator_backend, board, num_cores, injection_mode, observable_outputs, detection_string, completion_patterns, serial_pty, serial_feeder_cmd, cpu_model, cache_config, mem_backend, the qemu_* keys, and any key not listed in this table
the checkpoint settings checkpoint checkpoint, checkpoint_locations
the injection plan nothing; only the campaign result differs seed, num_injections, fault_model, target_registers, memory_start, memory_end, target_symbol, timeout, injection_timeout, crash_patterns, and the other fault and timing keys
a neutral key nothing campaign_name, campaign_label, description, num_workers, output_dir, log_level, ports and paths

The full classification of every key is in Configuration keys.

A build is due when no ELF exists or the benchmark's sources changed. The sources are benchmarks/<name>/ plus the files hfim.yaml lists under build_inputs. A rebuild always triggers a new golden run.

Every golden run also records the measurement version of the HFIM that measured it. A release that changes what a golden run records raises that version, and the first run of each campaign after the update measures a new golden run.

These flags can give wrong rates without an error

--no-build, --no-golden and --allow-stale skip these checks. A campaign run against a golden run of a different program produces plausible rates, not an error. Use them only when you know the files on disk are current.

Managing stored golden runs

Command Effect
hfim golden list each golden run under golden/: size, campaigns that use it, last use
hfim golden prune dry run: lists golden runs that no current campaign and no result uses, and golden runs keyed by an older HFIM version
hfim golden prune --yes removes them
hfim golden prune <key> --yes removes the named ones (<key> or <benchmark>/<key>)
hfim golden prune <key> --yes --force removes a named one even when a campaign or result still uses it

Parallel workers

A campaign runs N injections at once when num_workers is above 1, or with --workers N on the command line (the flag wins).

num_workers: 4
hfim run campaigns/fibonacci/register.yaml --workers 4

The fault list is generated once, from the seed, before any injection starts. The workers only consume it, so the same seed gives the same faultlist.json with any number of workers. Results are written to separate numbered directories (injections/0001/, injections/0002/, ...) and collected in injection order.

Backend One worker is
QEMU a thread with its own QEMU and GDB (GNU Debugger) process, own ports and a private copy of the disk image
gem5 a process in a pool; it starts one gem5 subprocess per injection

Rules:

  • hooks and coprocess.campaign run only in sequential mode. With more than one QEMU worker they are ignored, with a warning.
  • On a server, num_workers and --workers do not apply. See Parallel injections on a server.

Batches

A batch file describes several campaigns that share a configuration. defaults holds the shared keys; campaigns lists one entry per campaign with the keys that differ.

# campaigns/fibonacci/sweep.yaml: three campaigns, one per fault model
include: register.yaml

defaults:
  num_injections: 100

campaigns:
  - fault_model: single_bit_flip
    campaign_label: flip
  - fault_model: stuck_at_0
    campaign_label: stuck0
  - fault_model: stuck_at_1
    campaign_label: stuck1
hfim run campaigns/fibonacci/sweep.yaml

Each entry is the campaign of register.yaml with 100 injections and its own fault model. The labels put the three result directories side by side: fibonacci_flip_<timestamp>, fibonacci_stuck0_<timestamp> and fibonacci_stuck1_<timestamp>.

Rule Detail
Merge order top-level keys outside defaults and campaigns, then defaults, then the entry; the entry wins
Includes include: at the top, under defaults: or in an entry, paths relative to the batch file. An entry resolves as a campaign file that includes its own files, then those of defaults:, then those at the top, so the closer layer wins here too. See Sharing settings with include
Detection a file with a campaigns: list is a batch
Order entries run one after another on this machine
Golden runs each entry builds and runs its golden run as a single campaign does; entries with the same program share one
Result directories one per entry under its output_dir; give entries of the same benchmark distinct campaign_label values to tell them apart
Names each entry without a campaign_name in the batch file gets <name>-<i>: <name> is the batch file's name (sweep), <i> the entry's position
Failure a failed entry does not stop the others; the batch lists failures at the end and exits non-zero
On a server hfim run --on <server> campaigns/fibonacci/sweep.yaml submits the whole batch as one submission and spreads its injections across the workers

One campaign injects one kind of fault. A sweep over fault types is one entry per type.

Checkpoints

A checkpoint is a snapshot of the machine taken once, at an anchor symbol, and restored before every injection. Boot and initialization then run once per campaign instead of once per injection. Checkpoints work on QEMU only, through its savevm and loadvm commands over QMP (the QEMU Machine Protocol).

injection_mode: breakpoint     # required with checkpoint
checkpoint:
  anchor: fim_init
  restore: per_injection
  recycle_every: 0
Key Values Default
anchor a symbol (fim_init), {symbol: main, offset: 0x50}, or a hex address string "0x800002a4" required
restore per_injection per_injection
recycle_every integer, 0 or more: restart the campaign coprocess after every N injections; 0 never 0

Rules enforced when the campaign loads:

  • injection_mode must be breakpoint. A restore resets the instruction counter of the icount plugin (the QEMU plugin that counts retired instructions), so an instruction number from the golden run does not name the same instant after a restore. A program counter does.
  • simulator_backend must be qemu.
  • breakpoint_kind: soft is rejected.
  • A hex-address anchor is accepted with a warning: it is wrong after any recompile. Prefer a symbol, with offset if needed.
  • checkpoint_locations: [X] is an older form that names the same anchor as checkpoint: {anchor: X}. Setting both is an error.

The anchor must be reached exactly once before the injection window. fim_init meets that condition in every benchmark. The checkpoint is stored with the golden run, under golden/<benchmark>/<golden key>/checkpoints/<key>/, and is restored only into a campaign whose golden and checkpoint settings match it.

On a server

A server runs the HFIM server: an API (application programming interface) endpoint and a fleet of workers per account. The campaign file does not change. A server run goes through these steps:

  1. hfim on this machine sends the server the campaign files it lacks, and submits the campaign.
  2. The server prepares the program once in its workspace: the build, the golden run and the checkpoint.
  3. The worker fleet runs the injections against that build and golden run, and returns one result per injection.
  4. While the campaign runs, the server streams its log lines and progress to this machine.
  5. At the end, hfim copies the campaign directory into results/<campaign_id>/, with the same layout as a local run, and checks every file against its hash.

The build, the golden run and the checkpoint stay on the server, keyed by record key, and later submissions reuse them. They are never copied back: a golden run belongs to the simulator installation that measured it.

Add the server once

Each server is one entry in ~/.hfim/servers.yaml (another file with HFIM_SERVERS), written by hfim remote add. The entry names the transport (how to reach the server) and the credential (how to authenticate). It holds no secret.

Transport Use
direct the server has an open HTTPS (secure web) port
ssh-tunnel the API is reached through ssh
command a site tool opens the route
Credential Use
none no authentication
token access token
keychain access token in the system keychain, stored with hfim remote login
command a command prints the token (password manager)
peer the ssh account is the identity

A server reached through ssh, with an account fim-<you> and its key given by the server's administration:

hfim remote add lab \
    --transport ssh-tunnel \
    --set ssh=fim-<you>@<server address> \
    --set socket=/run/fim-<you>/api.sock \
    --set 'options=["-i", "~/.ssh/fim-<you>"]' \
    --credential peer \
    --site-hint "Connect to the site network first."

Resulting entry:

version: 1
default: local
servers:
  lab:
    site_hint: "Connect to the site network first."
    transport:
      kind: ssh-tunnel
      ssh: fim-<you>@<server address>
      socket: /run/fim-<you>/api.sock
      options: ["-i", "~/.ssh/fim-<you>"]
    credential: {kind: peer}
Other routes: an HTTPS port, or a site tunnel tool HTTPS port with an access token in the system keychain:
hfim remote add lab --api https://hfim.example.org --transport direct --credential keychain
hfim remote login lab < token.txt
Route opened by a site tool, token from a password manager:
servers:
  lab:
    transport:
      kind: command
      open: "vendor-tunnel --to hfim.internal:443 --listen 127.0.0.1:{local_port}"
      ready: stdout
    credential:
      kind: command
      command: "op read op://hfim/token"
      ttl: 3600

hfim remote add ends by running hfim doctor --on <name>. Run it again at any time:

hfim doctor --on lab

It checks the entry, the route, the credential, the API version, that the server runs the same HFIM version as this machine, that workers are live, and, inside a campaign repository, that the server has the pinned simulator. Each failed line names its fix.

Run

hfim run --on lab campaigns/fibonacci/register.yaml

hfim validates the campaign, sends only the files the server lacks, submits, and prints the log and progress as a local run does. At the end it fetches the campaign directory into <output_dir>/<campaign_id>/ and checks every file against its hash. It never overwrites an existing directory that holds other content.

Option Effect
--detach submit, print the follow-up commands, return
--no-fetch follow to the end, leave the results on the server
Ctrl-C detach; the submission keeps running

Ctrl-C detaches, it does not cancel

Ctrl-C never cancels a server run. hfim runs attach <id> follows it again; hfim runs cancel <id> stops it.

Exit code Meaning
0 every campaign succeeded and was fetched
1 refused before or during submission (the message names the reason and the fix), or a fetch failed
75 the route stayed lost for 10 minutes; the submission keeps running; hfim runs attach <id> resumes
130 Ctrl-C; the submission keeps running

A failed campaign returns its own exit code, as locally. --inject-index and --campaign-id do not apply on a server: hfim refuses them with exit code 2, because the server names and runs every injection itself.

Choose the server without the flag

The machine is chosen per user, never by the campaign file. First match wins:

  1. --on NAME or --local
  2. the HFIM_ON environment variable
  3. hfim remote use NAME, stored in .hfim/local/server in the repository (never committed)
  4. default: in ~/.hfim/servers.yaml
  5. this machine
hfim remote use lab       # this repository runs on lab
hfim remote use local     # back to this machine
hfim run --explain campaigns/fibonacci/register.yaml   # prints the choice and its source

Parallel injections on a server

num_workers and --workers do not apply. The server runs a QEMU campaign as one job per injection and runs as many at once as its cap allows: the smaller of the host's core count and the account's worker count, divided by the harts (hardware threads) each injection boots, rounded down, and at least 1. The log prints the cap for each campaign:

fibonacci_20261127_165328_734175: 8 injections, at most 1 at a time (1 harts per injection), Golden 9405de63bf505fbc

A gem5 campaign has no per-injection entry point, so the server runs it as a single job on one worker.

Follow, fetch and clean

Command Effect
hfim runs submissions of this repository
hfim runs --on lab --all submissions on lab from every repository of this user, not only this one
hfim runs show <id> each campaign, its progress and golden key
hfim runs attach <id> follow, then fetch (--latest for the newest)
hfim runs cancel <id> stop it, in any state
hfim runs fetch <id> copy its results here (--campaign CID for one campaign, --latest for the newest)
hfim runs clean <id> remove the server copy of campaigns fetched and verified here

An <id> is a submission id, a campaign id, or a unique prefix of either. hfim runs clean removes nothing that this repository has not fetched and verified.

Build or run the golden run only

hfim build --on lab benchmarks/fibonacci
hfim golden --on lab fibonacci --config campaigns/fibonacci/register.yaml
hfim golden list --on lab

These submit a preparation with no injection. Without --config, hfim uses the one campaign under campaigns/ whose benchmark: matches, and refuses when there are several. The result stays on the server for later hfim run --on.

Notifications

hfim remote notify lab --telegram --chat-id 123456789

The server messages that Telegram chat when a submission ends. --token-stdin reads a bot token from standard input; without it the server uses its own bot.

Inspecting results

hfim results list              # campaigns under results/, with outcomes
hfim report                    # HTML report of the most recent campaign
hfim report <campaign_id>      # HTML report of a named campaign

Both read results only and work on a machine that cannot run a campaign. Both take --results-dir (default $HFIM_RESULTS_DIR, else results); hfim report takes --output for the path of the HTML (HyperText Markup Language) page it writes.

results/<campaign_id>/
├── injections.csv      one row per injection: target, bit, value before and after, outcome
├── faultlist.json      what each injection was asked to do
├── metadata.json       the configuration as it ran
├── provenance.json     tool version, simulator version, hashes, golden key
├── results.txt         outcome distribution
└── injections/0001/
    ├── output.txt      console output of the run
    └── state.json      observable values, when they differ from the golden run

provenance.json records what is needed to re-run the campaign and compare it later. Every file and every column: Output files.

To move a campaign's bulk files to an archive, set results_store in the campaign or hfim.yaml, then:

Command Effect
hfim results push <campaign_id> <path> archive a campaign directory into the store
hfim results fetch <campaign_id> [dest] restore it from the store
hfim results url <campaign_id> print where it is stored

Replaying exact faults

A campaign normally draws its faults from seed: for each injection, the seed picks the instant, the target and the bit. With faultlist_csv, the campaign draws nothing. It injects the faults listed in a CSV (comma-separated values) file instead, one run per row, in the order of their injection_id.

Replay is how you run the same faults twice. For example, you inject the faults of an earlier campaign into a hardened build of the program, or you inject a fault list that another tool produced, so that both tools see the same faults.

Replay an earlier campaign

The injections.csv of any campaign is a valid fault list. This campaign file replays one campaign's faults with the settings of register.yaml:

# campaigns/fibonacci/replay.yaml
include: register.yaml
campaign_name: fibonacci-replay
faultlist_csv: results/fibonacci_20260916_120622_415852/injections.csv
hfim run campaigns/fibonacci/replay.yaml

The path is relative to the campaign repository, the directory you run hfim from. When the fault list loads, the log names the file and the number of faults it read:

Loaded pre-generated faultlist: <N> faults from <path> (seed/num_injections advisory in replay mode)

Each row of the new injections.csv keeps the injection_id of the row it replays, so you can compare the two campaigns row by row.

What a row needs

HFIM reads the columns in this table and ignores every other column, so the result columns of an injections.csv do no harm.

Column Required Meaning
injection_id yes integer; sets the order of the runs and the id of the result row. The ids do not need to run from 1 to N
instruction_count yes the instant: a retired-instruction count in icount mode, the program counter (in decimal) in breakpoint mode, a committed-instruction count on gem5
target_type yes register or memory
target_name yes a register name (x14) or a memory address (0x80000210)
bit_position yes the bit to change
bit_positions no the bits of a multi-bit fault, separated by ; (3;17;40)
hit_instance no breakpoint mode: which execution of the address the fault fires on, 0 for the first. Empty means 0
target_core no multicore: the hart that takes the fault. Empty means the campaign's target_core decides

A fault list that you write by hand needs only the five required columns. This one holds a single register fault, taken from a real fibonacci campaign in icount mode: flip bit 12 of x10 after 108 retired instructions.

injection_id,instruction_count,target_type,target_name,bit_position
2,108,register,x10,12

The row carries the instant, the target and the bits, but not the operation. The campaign's fault_model decides whether those bits are flipped or forced to 0 or 1. Its injection_mode decides how instruction_count is read, so keep the mode of the campaign that wrote the file.

Checks before the first run

HFIM checks the fault list against the program before any injection runs. A fault list drawn from one build names instants and addresses of that build, and they can be wrong for another one.

  • The build. When the CSV sits in a campaign result directory, HFIM reads the build key from the provenance.json beside it. If that build differs from the one this campaign runs, the campaign stops with the faultlist <path> was drawn from Build <key>, this campaign runs Build <key>: its PCs and hit counts may not exist any more. --allow-stale replays it anyway (PC: program counter). With --allow-stale the campaign runs and records the difference in provenance.json.
  • No provenance. A CSV with no provenance.json beside it, such as one you wrote by hand, runs unchecked, with the warning faultlist <path> names no Build (no provenance.json beside it); replaying it unchecked.
  • Every row. A missing required column, a value that is not an integer, a negative hit_instance or an unknown target_type stops the campaign with Invalid row in faultlist_csv <path>: ... and the reason.
  • Memory bits. A memory row must name a bit inside the bytes the injector writes: bits 0 to 7 on gem5, which changes one byte, and bits 0 to 8 * memory_access_size - 1 on QEMU, which writes the whole access. A bit outside that range is refused at load time.

How replay changes the other settings

The CSV decides how many faults run. seed and num_injections have no effect on the faults. When num_injections differs from the number of rows, the log warns faultlist_csv has <rows> rows but num_injections=<n>; the CSV is authoritative, running <rows> faults. On a server, the campaign is split across the workers by the number of rows in the CSV.

injection_pc_exclude only shapes the random draw, so it filters no replayed row. In breakpoint mode the log says so when both are set.

The contents of the CSV belong to the injection plan. Editing the fault list changes only the campaign result: it never repeats the build or the golden run.

Limits

  • Only register and memory rows replay. A row from a gem5 cache, DRAM or pipeline campaign has another target_type and is refused: faultlist row target_type must be 'register' or 'memory', got '<type>'.
  • A replay repeats the instant and the target of each fault, not the state of the machine around it. A replay on a different simulator or build can give a different outcome for the same row, which is usually the point of the comparison.
  • --allow-stale lets you replay a list drawn from another build, but its addresses and instruction counts still name places in the old program. Use it only when you know the two builds place the code and data at the same addresses.