Skip to content

HFIM

HFIM (Fault-Injection Manager) is an automated framework for early reliability assessment of embedded microprocessors, both single-core and multicore. It supports three simulators, QEMU, gem5 and OVP (Open Virtual Platforms), real hardware boards, and a range of architectures. HFIM is designed for ease of use and includes scripts to:

  • start a campaign directory from a board's template and install the simulator and SDK (software development kit) it pins (hfim init)
  • diagnose incomplete installations (hfim doctor)
  • build binaries for a specific board or architecture (hfim build)
  • update HFIM (hfim update) and remove it again (hfim uninstall)
On this page Capabilities · Requirements · Install · Configure a campaign · Run a campaign · Support per simulator
Documentation Manual · Backends · Boards · Reference · Developers · Contributing

Summary of HFIM's capabilities

Fault injection targets

HFIM can inject faults into the following targets: - ISA (instruction set architecture) registers exposed by the target architecture - Control and status registers (CSRs), on OVP only, replayed from an explicit fault list (faultlist_csv) - Memory sections, selected by section name (.stack, .bss, .data, .text, etc.) - Memory regions, selected by address range - Global and static variables exposed in the symbol table - Cache memories (gem5 only) - Internal functional blocks exposed by the gem5 model

Details and configuration: Fault targets.

Fault models

HFIM implements the following fault models: - Single-bit: flips one bit of the target data - Multi-bit: flips two or more bits of the target data (multi_bit_count) - Stuck-at: forces a bit to 0 or 1. On gem5 and OVP the fault can be permanent (fault_persistence: permanent): it holds for the rest of the run; on QEMU it is applied once, at the injection instant - Inverted cell (OVP only): a permanent bit flip in which every value the program writes to the target is stored with the faulty bits inverted (ovp_permanent_model: inverted_cell) - Combined: combinations of the above (e.g., multi-bit + stuck-at-1)

Details and configuration: Fault models.

Fault classification

HFIM injects one fault per run and compares the output with a golden (fault-free) run. Each fault is classified as: - Masked: the program completes and its observable state is byte-identical to the golden run - SDC (silent data corruption): the program completes but its observable state differs from the golden run - Detected: the program completes and its own check reports the error (fim_exit(1)) - Crash: the program returns an exit code > 1 or crashes during simulation - Hang: the run exceeds the predefined execution-time or executed-instruction limit

Result files write these outcomes as masked, sdc, detected, crash and timeout (hang).

Methods for SDC and Hang/Crash classification

  • SDC: the campaign names the observable variables (observable_outputs). At fim_exit HFIM reads them from the simulated memory and compares them byte by byte with the golden run.
  • Hang: a wall-clock limit per injection, derived from the golden run by default (timeout: auto), and optionally an instruction limit (hang_icount_factor, required on OVP).
  • Crash: an exit code above 1, a CPU exception, or a console line listed in crash_patterns.

Full method: Fault classification.

Campaign acceleration by parallel workers

num_workers: N (or --workers N) runs N injections at once on one machine, with QEMU and with gem5. The fault list is drawn from the seed before any injection starts, so the results do not depend on the number of workers. OVP runs its injections one after another and refuses a num_workers above 1. hfim run --on <server> sends a QEMU campaign to a shared server's worker fleet. Full description: Running campaigns.

Requirements

Item Version Check
Linux or macOS
Python 3.9 or newer python3 --version
git any git --version
Docker running, usable without sudo docker ps
pipx any pipx --version
docker ps prints permission denied Your account cannot reach the Docker daemon. On Linux:
sudo usermod -aG docker $USER
newgrp docker
docker ps
On a shared machine, ask the administrator or use rootless Docker.
docker ps prints cannot connect to the Docker daemon Docker is not running. Run `sudo systemctl start docker` (Linux) or open Docker Desktop (macOS).

Install

1. Install HFIM.

The package is called hfim-cli on PyPI; the command it installs is hfim. Install it with pipx, or with pip in a virtual environment.

With pipx (install pipx first with sudo apt install pipx on Debian and Ubuntu, or brew install pipx on macOS):

pipx install hfim-cli
pipx ensurepath

Without pipx:

python3 -m venv ~/.hfim
~/.hfim/bin/pip install hfim-cli
echo 'export PATH="$HOME/.hfim/bin:$PATH"' >> ~/.bashrc    # ~/.zshrc on macOS

On Debian and Ubuntu, python3 -m venv needs the python3-venv package (sudo apt install python3-venv); without it, it stops with "ensurepip is not available".

A plain pip install hfim-cli outside a virtual environment fails on current Debian, Ubuntu and Homebrew Pythons (externally-managed-environment). On Apple's own python3 it installs into ~/Library/Python/3.9/bin, which is not on PATH; hfim doctor then prints the line that adds it. hfim update updates hfim whichever of these ways installed it.

Open a new terminal after changing your PATH. To install an unreleased revision, use pipx install git+https://github.com/HI-REST/hfim.git@<commit>.

2. Create the campaign directory.

hfim init

hfim init lists the templates, one per board and simulator. Move with the Up and Down arrow keys and press Enter; Esc cancels. It then asks for the folder, with the template's name as the default. It copies the template into that folder and installs what the template's hfim.yaml pins:

  • the simulator package, as a Docker image built from its release tag (several minutes, once), registered in ~/.hfim/simulators/
  • the SDK, the build script and the fim_init() / fim_exit() calls a benchmark links against, as the highest release inside the pinned range in ~/.hfim/sdk/<version>/
  • for a physical board, the probe package, the GDB server in front of the board

It prints one line per package installed, checks the machine with hfim doctor, and ends with the commands to run next:

Template: nezha-c906-qemu
Project folder [nezha-c906-qemu]:
installing simulator qemu-xuantie@9.0.2 ... done
installing sdk >=1.3,<2 ... done

Next:
  cd nezha-c906-qemu
  hfim run campaigns/fibonacci/register.yaml

The nezha-c906-qemu template includes the Fibonacci benchmark and register and memory campaigns for the Nezha C906. It runs on the XuanTie QEMU, whose compiler XuanTie publishes for x86-64 Linux only. Its image is linux/amd64 on every machine: an Apple Silicon Mac runs it emulated, slower, and builds the same ELF (executable and linkable format) binary as an x86-64 machine.

In a script, or anywhere without a terminal, name the template and, optionally, the folder: hfim init nezha-c906-qemu my-campaigns. --yes asks nothing, and --no-install only copies the template. If a package does not install, hfim init prints the end of its build output and the log file; hfim setup in the new folder checks each pin and tries again. If hfim init reports a version mismatch, follow its hfim update instruction.

Continue to Run a campaign. For an existing installation, see Updating or Uninstalling. To set up a shared worker, see Server administration.

Configure a campaign

my-campaigns/
├── benchmarks/fibonacci/main.c          code only
└── campaigns/fibonacci/
    ├── fibonacci.yaml                   benchmark: fibonacci + observable_outputs
    ├── register.yaml                    include: fibonacci.yaml + register campaign keys
    └── memory.yaml                      include: fibonacci.yaml + memory campaign keys

A campaign is one benchmark plus the settings of one experiment. All configuration lives under campaigns/; a benchmark directory holds code only. The template runs as it is, so the first run needs no change.

campaigns/fibonacci/fibonacci.yaml names the benchmark and what a correct run produces. It is not a campaign of its own: it says nothing about faults, so it is included, not run.

benchmark: fibonacci

observable_outputs:
  comparison: exact
  variables:
    - name: result

campaigns/fibonacci/register.yaml is the first campaign: 10 single-bit flips in the integer registers.

include: fibonacci.yaml

campaign_name: fibonacci-register

simulator_backend: qemu

seed: 7
num_injections: 10
num_workers: 1

target_types: [register]
target_registers: [x10, x11, x12, x13, x14, x15]
fault_model: single_bit_flip
injection_mode: icount

timeout: auto
output_dir: results

campaigns/fibonacci/memory.yaml is the second: 20 single-bit flips in result[], the program's .bss.

include: fibonacci.yaml

campaign_name: fibonacci-memory

simulator_backend: qemu

seed: 7
num_injections: 20
num_workers: 1

target_types: [memory]
memory_start: .bss
memory_end: .bss
fault_model: single_bit_flip
injection_mode: icount

timeout: auto
output_dir: results

include: names other YAML files under campaigns/, one path or a list, each relative to the file that names it; their keys fill the keys the campaign leaves unset. The file you run wins, then its includes in the order listed: an included file only fills what is still unset, and the first file of an include: list wins over the next.

Every key: Campaign configuration. The include rules in full: Sharing settings with include.

Run a campaign

1. Run the register campaign. hfim run installs a pinned simulator, SDK or probe that is missing, and builds the benchmark and runs the golden run first when they are missing.

hfim run campaigns/fibonacci/register.yaml

The run ends with a summary: the campaign ID, the number of injections (10 in this campaign) and the count and percentage of each outcome that occurred.

2. Read the results.

hfim results list      # every campaign on this machine
hfim report            # HTML report of the latest campaign

Each campaign writes results/<campaign_id>/. The main file is injections.csv: one row per injection with the target, the bit, the value before and after, and the outcome. All files: Output files.

Support per simulator

Capability QEMU gem5 OVP Hardware
Integer and float registers yes yes yes integer registers tested on PolarFire; floating-point registers unverified
Memory: section, address range, variable yes yes yes yes
Control and status registers (CSRs), from a fault list yes
Caches (L1D, L1I, L2), tags, ECC (error-correcting code) bits yes
DRAM (dynamic RAM) and NVM (non-volatile memory), through DRAMsim3 and NVMain yes
Microarchitecture (TLB, ROB, rename, branch predictor) yes
Coherence (Ruby directory, MSHR) yes
Bit-flip, multi-bit, stuck-at yes yes yes yes
Multicore, fault on one hart yes yes up to 4 harts yes
Parallel workers on one machine yes yes
Server worker fleet yes
Time per injection 1 to 3 s 10 to 60 s about 3 s about 13 s on the Discovery Kit, one board at a time

The microarchitecture abbreviations are the translation lookaside buffer (TLB), the reorder buffer (ROB) and the miss status holding register (MSHR). A hart is one hardware thread of a RISC-V processor.

OVP runs its 64-bit RISC-V model (variant RV64GC) with HFIM's own driver. You provide the OVP/Imperas SDK, its processor model and its license on the machine that runs the campaign; HFIM ships only the driver source. The OVP backend page lists what it refuses and why.

Documentation

To do this Read
Change what is injected, how many times and when Campaign configuration
Choose what is corrupted: registers, memory, a variable, caches Fault targets
Choose how the bits change: bit flip, multi-bit, stuck-at Fault models
Test your own program Writing a benchmark
Inject into caches, DRAM or the pipeline gem5 backend
Run long campaigns on a shared server Running campaigns
Look up a command, key or file Reference

Suggested citation

Please cite HFIM and include the release or commit used. Cite gem5, NVMain or McPAT when your campaign uses them.

Software licensing

HFIM's original software and this manual use the MIT License. See the third-party notices for bundled components and the license supplied with each simulator or firmware package.

Where the code lives

Repository What it is
hfim the hfim command, this manual and the optional server in server/
hfim-sim-qemu QEMU with the plugin and toolchain HFIM needs
hfim-sim-qemu-xuantie XuanTie's QEMU fork, with the real C906 models
hfim-sim-gem5 gem5 with the fault injector compiled in
hfim-sdk the build script and fim_init() / fim_exit()
hfim-template-nezha-c906-qemu a ready-to-run campaign repository for one board, on QEMU
hfim-template-nezha-c906-gem5 the same board on gem5: caches, coherence, non-volatile memory
hfim-template-polarfire-zephyr-qemu PolarFire SoC running Zephyr SMP on four U54 cores, on QEMU
hfim-template-polarfire-zephyr-hardware the same software on a PolarFire SoC Discovery Kit board
hfim-sim-ovp HFIM's driver for the OVP RISC-V model, built against your own OVP/Imperas SDK
hfim-probe-openocd OpenOCD, packaged as the debug probe for real boards
hfim-probe-openocd-esp32 Espressif's OpenOCD for ESP32 boards
hfim-index the list of templates and packages that hfim init and hfim sim install offer