Campaign configuration¶
A campaign is one YAML file under campaigns/. It names the benchmark, how many faults to inject, what to inject into, when, and with which simulator, directly or through the files it includes. hfim run <file> reads it, checks it, and runs it. Every key with its type and default: Configuration keys.
Which file holds which setting, and which one wins: Sharing settings with include.
# campaigns/fibonacci/register.yaml
include: fibonacci.yaml
campaign_name: fibonacci-register
seed: 7
num_injections: 10
num_workers: 1
fault: register
target_registers: [x10, x11, x12, x13, x14, x15]
fault_model: single_bit_flip
injection_mode: icount
timeout: auto
output_dir: results
The benchmark, and what counts as a wrong answer, come from campaigns/fibonacci/fibonacci.yaml, which this file includes; see What counts as correct.
Sharing settings with include¶
All configuration lives under campaigns/, in any folders and file names. A benchmark directory holds code and its own build files only. Two campaigns share a setting only by naming the same file under include:.
# campaigns/fibonacci/fibonacci.yaml: shared by every campaign of fibonacci
benchmark: fibonacci
observable_outputs:
variables:
- name: result
# campaigns/fibonacci/register.yaml
include: fibonacci.yaml # one path, or a list: [fibonacci.yaml, ../shared/board.yaml]
seed: 7
| Rule | Detail |
|---|---|
| Paths | one path or a list, each relative to the file that names it |
| The file run wins | an included file fills only the keys the file above it leaves unset: absent, or empty (null or "") |
| Whole keys | a key is filled whole, never merged: two observable_outputs never mix their variable lists |
| Depth first | an included file's own includes fill it before it fills the file above, so the file closer to the one run wins |
| First listed wins | in one include: list, the first file fills first; a later file fills only what is still unset |
Inside campaigns/ |
every included file lies under campaigns/; a path that leaves it is refused |
| Refused before anything runs | a path outside campaigns/, a missing file (named with the file that includes it) and a cycle (named as the chain) |
| Any YAML file | can be included; only a complete campaign runs, and running an incomplete one names the keys it lacks |
| Keys | an included file holds campaign keys, checked as a campaign's are; include itself is not a setting |
| Batch files | include: at the top of a batch file, under defaults: or in an entry; each entry includes its own files first, then those of defaults:, then those at the top. See Batches |
hfim run <campaign> --explain prints every value with the file it came from, and for an included value the chain of files that led to it:
observable_outputs = {"variables": [{"name": "result"}]} [included file campaigns/fibonacci/fibonacci.yaml (included by campaigns/fibonacci/register.yaml)]
seed = 7 [campaign file campaigns/fibonacci/register.yaml]
The campaign's provenance.json lists every file of the chain with its content hash. The records that decide when a build or a golden run is repeated hash the resolved values, not the files, so a comment edit in a shared file rebuilds nothing.
Required keys¶
A campaign without any of these is rejected before it runs.
| Key | Value | Example |
|---|---|---|
benchmark |
the directory name under benchmarks/ |
fibonacci |
seed |
non-negative integer | 7 |
num_injections |
positive integer | 100 |
fault |
the target family, see What to inject | register |
fault_model |
single_bit_flip, stuck_at_0, stuck_at_1 |
single_bit_flip |
timeout |
seconds per injection, or auto |
auto |
A register campaign also needs target_registers or auto_registers: true. A memory campaign also needs target_symbol, section, or memory_start and memory_end.
target_types: [register] is the list form of fault: register and is accepted in its place. Setting both to different values is rejected.
Seed and number of injections¶
The faultlist is generated before the first injection and is a pure function of the seed, the benchmark ELF and the configuration. The same seed on the same ELF draws the same targets, bits and instants in the same order on any machine. faultlist.json in the result directory records the list.
| Key | Effect |
|---|---|
seed |
seeds the campaign PRNG; change it to draw a different set of faults |
num_injections |
number of faults; each is one run of the benchmark |
sampling_with_replacement |
true (default) draws every fault independently; false never repeats a complete fault |
Each injection is an independent draw: a target from the pool, a bit, and an instant. Coverage across the pool is uneven but reproducible. It is not one injection per register.
With sampling_with_replacement: false, HFIM redraws any fault that repeats an earlier one in the same campaign. A complete fault is the target, the set of bits, the instant, the breakpoint hit and, where they apply, the hart or cache cell. The same bit can still appear at another instant. After 1000 duplicate candidates in a row for one entry, the campaign stops with sampling_with_replacement=false could not draw a new complete fault. That limit does not prove the choices are used up; widen the target, the time window or the bits, or leave the default. With faultlist_csv, a duplicate row is an error and no row is dropped. The setting cannot be combined with memory_random_fallback: true, or with section: .stack-live in breakpoint mode, because the simulator picks the address after the list is drawn. The default keeps the faultlist of an existing seed unchanged. metadata.json, faultlist.json and provenance.json record the value.
The number of injections sets the error margin of every rate the campaign reports (Leveugle et al., DATE 2009), with p = 0.5 as the worst case:
N = z^2 * p * (1 - p) / e^2
num_injections |
Error margin | Confidence |
|---|---|---|
| 300 | about 5 % | 95 % |
| 500 | about 2.2 % | 95 % |
| 1000 | about 1.5 % | 99 % |
| 2000 | about 1 % | 99 % |
What to inject¶
fault selects the target family. fault_model selects how the bits change.
fault: register
target_registers: [a0, a1, s0]
fault_model: single_bit_flip
fault |
Selected by | Backend |
|---|---|---|
register |
target_registers: [a0, a1], or auto_registers: true |
QEMU, gem5 |
memory |
target_symbol: result, section: .bss, or memory_start / memory_end |
QEMU, gem5 |
cache_l1d, cache_l1i, cache_l2, dram, pipeline and coherence values |
see gem5 backend | gem5 |
One campaign injects one family. Keys of another family (for example target_registers in a memory campaign) are rejected at load. To sweep several families, write one batch entry per family, see Running campaigns.
Memory in brief:
fault: memory
target_symbol: result # a file-scope variable; address and size from the ELF
# or
section: .bss # a whole ELF section
# or
memory_start: 0x80000000 # an address range; either end also takes a section name
memory_end: 0x80000200
memory_access_size: 1 # alignment of the drawn address: 1, 2, 4 or 8
Every target, with its rules: Fault targets. Every fault model, multi-bit and persistent faults: Fault models.
When to inject¶
injection_mode is the campaign's clock: it decides how an instant is named, and therefore whether a replay hits the same instant.
| Mode | Instant named by | Reproducible | Speed | Use when |
|---|---|---|---|---|
icount (QEMU default) |
the N-th retired instruction | yes, on any machine | fast | the instruction count is stable between runs |
breakpoint |
a program counter and the K-th hit of it | yes, per address | fast | the instruction count varies (serial feeder, multicore QEMU, checkpoints, hardware) |
timer |
a wall-clock delay | no | fast | the icount plugin cannot follow the workload |
stepi |
single-stepping N instructions | yes | very slow | not recommended; icount reaches the same instant |
Omit injection_mode on gem5 unless the campaign needs a specific mode. HFIM resolves it to timer, and gem5 counts committed instructions internally. Hardware also defaults to timer. Select breakpoint to stop at a program address. Explicit icount requires QEMU.
icount¶
injection_mode: icount
The golden run records the instruction count at fim_init and at the end of the program. Each injection draws an instruction number from that window. A campaign in icount mode whose golden run has no instruction counts stops with an error; it does not fall back to another clock.
icount runs QEMU with one instruction per translation block, so the stop lands on the exact instruction. This costs run time on long benchmarks. Leave precise_stop_margin unset: it has no reliable effect.
To inject at fixed instants instead of drawn ones, list them. The faultlist consumes the list in order and cycles when num_injections is larger:
injection_icounts: [120000, 250000, 400000]
breakpoint¶
injection_mode: breakpoint
inject_at_symbol: work_step # optional: pin every injection to this symbol
inject_at_offset: 0 # optional: byte offset from it
Without inject_at_symbol or inject_at_addr, each injection draws an instruction address from the window the golden run executed, weighted by how often it ran. Without a golden hit count, the address is drawn from fim_init to the end of .text, 2-byte aligned. With them, every injection stops at that address. inject_at_symbol survives a rebuild that moves code; inject_at_addr takes a literal address.
An address inside a loop is reached many times. The golden run counts the hits of each address inside the window, and each injection draws one hit K uniformly from that count. injections.csv records it in hit_instance. When the golden run has no count for the address, K is 0 (the first hit). From the 1000th hit on, the icount plugin counts hits inside QEMU and stops only on the K-th; this needs the pc_hit_trigger feature in the simulator package's plugin_features. If the program reaches fim_exit before the K-th hit, the injection draws a new point.
To keep the random address draw out of startup code or a spin loop:
injection_pc_exclude:
- "0x80000000-0x800001ff" # a raw range
- {symbol: wait_for_input, offset_start: 0, offset_end: 0x40}
injection_pc_exclude affects only the random draw in breakpoint mode on QEMU. An address named with inject_at_symbol or inject_at_addr is used even inside an excluded range.
breakpoint is required with checkpoint, with num_cores above 1 on QEMU, and with a serial feeder.
timer¶
injection_mode: timer
timer_scale_factor: 0.00001 # seconds per instruction
The drawn instruction number is converted to a delay with timer_scale_factor. Two runs with the same seed can inject at different points. hang_icount_factor cannot be used with timer on QEMU. min_instructions and max_instructions narrow the window in timer and stepi modes.
stepi¶
injection_mode: stepi
GDB single-steps the program to the instant, at about 0.2 s per step. Use icount instead.
Time limits¶
Every injection has a wall-clock limit. A run that exceeds it is classified timeout.
timeout: auto # derive from the golden run
timeout_factor: 1.5 # default
timeout_floor: 30 # seconds, default
With auto, the limit is:
timeout = max(timeout_floor, ceil(timeout_factor * golden_execution_time))
The floor covers simulator and debugger start-up, which takes seconds whatever the benchmark length. Raise it on a loaded host. The resolved value is in the campaign log:
timeout=auto resolved to 30s (1.5x golden 3.048s, floor 30s)
| Key | Effect |
|---|---|
timeout: 120 |
fixed limit of 120 s per injection |
timeout: auto |
limit derived from the golden run as above |
injection_timeout: 120 |
exact limit in seconds; replaces timeout, auto included |
hang_icount_factor: 3.0 |
also stop a run that executes more than 3 times the golden instruction count |
A wall-clock limit depends on host load: the same injection can finish on an idle host and time out on a loaded one. hang_icount_factor is deterministic and comparable across machines. It is unset by default. On QEMU it needs injection_mode: icount; on gem5 it sets --max-insts. Keep timeout as well: a run stalled on a device executes no instructions, so only the wall-clock limit ends it.
Workers¶
num_workers: 8
num_workers is the number of injections run at once. hfim run --workers N sets it from the command line. QEMU and gem5 campaigns run that many injections at once on one machine; OVP refuses more than 1.
Which simulator¶
simulator: hfim-sim-qemu@9.2.3 # or qemu@9.2.3; a package installed with `hfim sim install`
simulator_backend: qemu # qemu, gem5, gem5-ruby, hardware
| Key | Effect |
|---|---|
simulator |
names an installed simulator package as name@version; its manifest gives QEMU, GDB and the plugin. The version must match exactly |
simulator_backend |
selects the backend; default qemu |
qemu_path, gdb_path |
use these binaries instead of a package |
hfim.yaml also names a simulator, but only hfim doctor reads it, to check the installation. The campaign runs on its own simulator:, so keep the two the same.
A campaign that names neither simulator nor qemu_path takes QEMU and GDB from the toolchain configuration for the benchmark's architecture. Backend-specific keys: QEMU, gem5, Hardware.
What counts as correct¶
These keys state what a correct run is. They are campaign keys like any other, and they usually sit in the file every campaign of the benchmark includes, so all of them judge correctness the same way:
| Key | Meaning |
|---|---|
observable_outputs |
variables compared with the golden run at fim_exit |
detection_string |
console line that ends the run as detected |
state_capture_function |
symbol at which observables are read; default fim_exit |
A key the campaign sets itself wins over an included one. The log names each included file and the keys it gave:
Using included file campaigns/fibonacci/fibonacci.yaml: benchmark, observable_outputs
# campaigns/fibonacci/fibonacci.yaml
benchmark: fibonacci
observable_outputs:
comparison: exact # exact | tolerance
variables:
- name: result # type and size come from the ELF
- name: error
type: double # optional: overrides the ELF type
tolerance: 0.001 # read only with comparison: tolerance
An observable must be a file-scope (global or static) and volatile variable. Without observables, the console output is compared with the golden run instead. How each outcome is decided: Fault classification.
Recording an observable at the instant of injection
observable_outputs:
record_at_injection: true # every variable below
variables:
- name: result
- name: loop_count
record_at_injection: false # opt one out
- name: phase
record_at_injection: true
compare: false # recorded, not compared
Output¶
output_dir: results # default
campaign_label: run-a # optional: added to the directory name
results:
save_per_injection: true # a directory per injection
save_uart_output: true # output.txt
save_register_dump: false # registers.json
save_observable_state: true # state.json, for sdc outcomes
cleanup_injections: false # delete injections/ when the campaign ends
Each campaign writes <output_dir>/<benchmark>[_<campaign_label>]_<timestamp>/. campaign_name is recorded in provenance.json and is not part of the directory name.
Warning
The save_* keys are read only inside the results: block. At the top level they are ignored and the defaults apply.
Every file: Output files.
A board that boots firmware¶
For a board that boots its own firmware, which then loads the program:
qemu_machine: microchip-icicle-kit # QEMU -machine
qemu_memory: 2G # QEMU -m
firmware_path: build/hss.elf # what every hart starts in
sd_image_path: build/sd.img # SD card the firmware boots from
elf_path: build/zephyr.elf # the program, read for its symbols only
guest_uart_serial: results/guest_uart.log
crash_patterns: ["ZEPHYR FATAL ERROR"]
qemu_args is appended last to every QEMU command line, golden run included; changing it requires a new golden run. What the board itself needs (clusters, exit device, boot time) is in the template's board.yaml, not in the campaign. Full walkthrough: PolarFire Zephyr.