OVP backend¶
OVP (Open Virtual Platforms) is the Imperas instruction-set simulator. On this backend HFIM runs your RISC-V program on the OVP RV64GC processor model (64-bit RISC-V with the standard G and C extensions) and corrupts integer registers, floating-point registers, the program counter, memory words and nine CSRs (control and status registers). As on every backend, each run applies one fault and HFIM compares the run with a fault-free golden run of the same program, so every fault gets its own verdict.
HFIM does not ship OVP. You install the OVP/Imperas SDK (software development kit), its RISC-V processor model and its license on the machine that runs the campaign. HFIM ships one small program of its own, the OVP driver, as source code, and builds it against your SDK. The driver is the only part of HFIM that talks to the simulator.
The backend runs one hart (hardware thread) or up to four harts of one processor. It runs its injections one after another, and every injection starts the program again from reset.
How a fault is injected¶
Each injection is one run of the driver, hfim-ovp-driver, in a directory of its own. HFIM's controller starts the driver and talks to it over a line-based protocol on the driver's standard input and output. Every record HFIM reads starts with @hfim, followed by a record name such as STOPPED and key=value fields. Every other line the driver prints is the simulator's own log.
The figure follows one register fault. HFIM sends a FAULT record that names the target and the instant, here register a0 before instruction 500 counted from reset. The driver runs the model until the hart has retired 499 instructions, stops it, reads a0 and reports the value in STOPPED.
HFIM then computes the faulty value from the fault model: a bit flip XORs the chosen bits, stuck_at_0 clears them and stuck_at_1 sets them. The driver does no fault arithmetic. It writes the value HFIM sends in WRITE, reads the target back and reports both in WRITTEN. After a memory write it also flushes the model's translation of that range, so the next instruction sees the new bytes.
HFIM sends RESUME only when the driver wrote exactly what HFIM asked for, to the target HFIM named. Anything else ends the run with ABORT, and the injection is recorded as infrastructure_failure, never as a guest outcome. After the resume the program runs to fim_exit. The driver reports how the run ended (END), the bytes of each observable variable (OBS) and DONE.
A CSR is the one target where the hart may keep a different value from the one written, because many CSR fields are read-only or accept only legal values. HFIM resumes the run either way and records what the hart kept, as described on the Control and status registers page.
A permanent fault adds one step. After the resume the driver watches the target. Each time the program writes to it, the driver stops, reports the new value (REWRITE), and HFIM either applies the fault again or answers that the fault changes nothing (KEEP).
What you need¶
The machine that runs the campaign needs four things:
- The OVP/Imperas SDK, installed, with
IMPERAS_HOMEpointing at it. HFIM checks forbin/Linux64/libRuntimeLoader.soand the RISC-V model atlib/Linux64/ImperasLib/riscv.ovpworld.org/processor/riscv/1.0/model.sounder that directory. - A license, named by
IMPERASD_LICENSE_FILEorLM_LICENSE_FILE. Either one is enough. - A C compiler and
make, to build the driver against the SDK's headers. - A RISC-V bare-metal program built with the HFIM SDK, so it has the
fim_init()andfim_exit()markers. HFIM refuses an ELF (Executable and Linkable Format) file without them.
The paths are the SDK's 64-bit Linux layout (Linux64), so the driver builds and runs on a 64-bit Linux machine.
Set the two variables, then install the simulator package. The package has only a native form, so the install command needs HFIM_RUNTIME=native: it then builds the driver from source against IMPERAS_HOME and registers it under your HFIM home. Nothing from the SDK is copied into the package.
export IMPERAS_HOME=/opt/imperas # where your SDK is installed
export IMPERASD_LICENSE_FILE=<port>@<server> # or LM_LICENSE_FILE
HFIM_RUNTIME=native hfim sim install ovp@0.6.9
hfim doctor
ovp is the short name of the package hfim-sim-ovp, and the full name works too. HFIM_RUNTIME=native hfim sim install ovp, without a version, installs the newest release.
If you work from a checkout of the package, build it in place with HFIM_RUNTIME=native hfim sim install --path <checkout>. The install stops with a message if IMPERAS_HOME is unset, or if the SDK lacks the header ImpPublic/include/host/op/op.h or the runtime loader.
The variables must also be set when the campaign runs. Before the golden run, HFIM checks that IMPERAS_HOME is set, that one license variable is set and that both runtime files exist, and it stops with a message naming whatever is missing. The license value is passed to the driver but never written to a result file. In each driver.log, HFIM replaces it with <licence>.
A campaign¶
The campaign below draws ten register faults on the Fibonacci benchmark from seed 7. HFIM ships no OVP campaign template, so the file is complete on its own: it states the benchmark and its observable instead of including a shared file.
# campaigns/fibonacci/ovp-register.yaml
benchmark: fibonacci
observable_outputs:
comparison: exact
variables:
- name: result
simulator: hfim-sim-ovp@0.6.9 # or the short ovp@0.6.9
simulator_backend: ovp
seed: 7
num_injections: 10
target_types: [register]
target_registers: [a0, a1, a2, a3, a4, a5]
fault_model: single_bit_flip
injection_mode: icount
hang_icount_factor: 3.0
timeout: auto
Two keys work differently from QEMU here. simulator must name the OVP package: without it HFIM would identify the run as a QEMU binary, so it refuses the campaign. hang_icount_factor is required and must be above 1.0. A run that reaches this multiple of the golden run's instruction count, counted from reset, ends as timeout.
The repository's board.yaml must name the board the package emulates, or no board at all:
board:
name: hfim-ovp-virt
architecture: riscv64
cpu:
cores: 1
The hfim-ovp-virt machine has 128 MiB of RAM at 0x80000000, the same bare-metal memory map as QEMU's virt machine. Every loaded segment of the ELF must lie in that RAM. A program linked with only -Ttext puts its headers below the RAM base, and HFIM refuses it before the golden run.
Run it like any other campaign:
hfim run campaigns/fibonacci/ovp-register.yaml
HFIM checks the whole campaign against the OVP backend before it builds or runs anything. Every problem is listed in one message, which starts with the OVP backend cannot run this campaign: and gives one line per key to change.
In icount mode, with the same seed, configuration and golden instruction counts, an OVP campaign draws the same fault list as a QEMU campaign. The draw is HFIM's, not the simulator's.
Fault targets¶
| Target | Selected by | Bits that can flip |
|---|---|---|
integer register x1 to x31 |
target_registers: [a0, t6] (ABI, application binary interface, names or xN names) |
0 to 63 |
floating-point register f0 to f31 |
target_registers: [fa0] |
0 to 63 of the raw 64-bit value |
| program counter | target_registers: [pc] |
0 to 63 |
| memory word in a section | section: .bss |
0 to 8 * memory_access_size - 1 |
| memory word in a variable | target_variable: result |
the same |
| memory word in an address range | memory_start and memory_end, given together |
the same |
| memory word in the live stack | section: .stack-live |
the same |
| CSR, from a fault list only | fault: csr and faultlist_csv |
0 to 63 |
x0 is refused because it is hardwired to zero. A memory fault touches one word of memory_access_size bytes (1, 2, 4 or 8; the default is 1), and the drawn bit can be any bit of that word. The word must lie inside the board's RAM and inside the section, variable or range the campaign names.
The nine CSRs are mstatus, mtvec, mepc, mcause, mtval, mscratch, fcsr, frm and fflags. CSR faults are replayed from a fault list, never drawn. See Control and status registers.
OVP models no caches, pipeline or memory controller. A campaign that asks for a cache, DRAM (dynamic RAM), TLB (translation lookaside buffer) or other microarchitectural target is refused with Caches, TLB and micro-architectural targets are not modelled.
Fault models and persistence¶
| Model | Keys | What happens |
|---|---|---|
| single-bit flip | fault_model: single_bit_flip |
one bit is XORed once |
| multi-bit flip | single_bit_flip with multi_bit_count: N |
N distinct bits, each position drawn independently, XORed once |
| stuck-at | fault_model: stuck_at_0 or stuck_at_1 |
the bits are cleared or set once |
| permanent stuck-at | stuck-at with fault_persistence: permanent |
the bits are forced again after every program write to the target |
| inverted cell | single_bit_flip, fault_persistence: permanent, ovp_permanent_model: inverted_cell |
the bits flip at the fault, and every later program write V is stored as V XOR mask |
The default is a transient fault: HFIM writes it once and the program may overwrite it. A permanent fault on OVP has two meanings, and you choose one. A stuck-at holds the bits at 0 or 1. The inverted cell, an OVP-only model, keeps inverting the faulted bits of whatever the program writes. A permanent single_bit_flip without ovp_permanent_model: inverted_cell is refused, because a permanent bit flip has no agreed meaning across backends.
On a memory target a permanent stuck-at watches the whole word. The inverted cell watches only the byte that holds the flipped bits, so a store to another byte of the word does not invert it again; for the same reason, all its flipped bits must lie in one byte. Both models are described on Stuck-at.
When the fault lands¶
injection_mode sets how the instant is counted. Every mode counts the same thing: instructions executed by the RISC-V model, from reset.
| Mode | The instant is | Notes |
|---|---|---|
icount (default) |
instruction N from reset: the hart stops with N-1 instructions retired | a seeded draw picks N between the fim_init and fim_exit markers of the golden run |
breakpoint |
the (K+1)-th execution of a program address, counted from the entry of fim_init |
a seeded draw picks an address, then K from how often the golden run executed that address; injection_pc_exclude is honored |
stepi |
N single steps from a reset you declare | needs stepi_reset_steps; one hart only |
timer is refused. A list of instruction counts in injection_icounts works with one hart.
stepi exists to replay faults counted by single-stepping from a reference reset. stepi_reset_steps says how many steps that reset takes before the ELF entry point; 0 counts from the entry. A count inside those steps has no OVP instant and is refused. A seeded stepi draw also needs max_instructions stated. min_instructions defaults to 0 and must not be below stepi_reset_steps, so state it whenever the reset takes steps. The window must lie inside the golden run. HFIM refuses a window that does not fit, and never trims it.
Several harts¶
Set num_cores from 2 to 4 to run several harts of one processor. The driver builds the processor with that many harts and runs them in turns of a fixed time slice, 0.001 seconds of simulated time, set by the package. HFIM checks that every run used that slice and records a run that did not as infrastructure_failure.
Each fault names the hart it writes in the target_core column. In icount mode the instant is that hart's own instruction count. In breakpoint mode K counts executions of the address by every hart, and the hart that stops the run need not be the hart that is written. The evidence file keeps both hart numbers. memory_per_core works as on QEMU and moves each drawn address into the slice of memory that belongs to the drawn hart.
Several harts rule out some settings, and HFIM refuses each with a message:
- permanent faults and CSR targets;
stepimode;injection_icounts, because a list of summed counts names no hart (use afaultlist_csvwith atarget_corecolumn);.stack-liveoutsidebreakpointmode. A drawn.stack-livecampaign also needsstack_live_shared_reservation: {bottom: <symbol>, top: <symbol>, harts: [0, 1]}, which declares the one stack reservation every hart shares. At each stop HFIM checks that the stopping hart's stack pointer lies inside it, and refuses the fault otherwise.
More on hart selection: Multicore.
Parameters¶
| Key | Values | Default |
|---|---|---|
simulator |
hfim-sim-ovp@0.6.9, or the short ovp@0.6.9 |
required |
simulator_backend |
ovp |
qemu |
target_types or fault |
register, memory, csr |
required |
target_registers |
ABI or xN/fN names, pc |
required for a register draw |
section, target_variable, memory_start and memory_end |
where memory faults land | |
memory_access_size |
1, 2, 4, 8 bytes |
1 |
fault_model |
single_bit_flip, stuck_at_0, stuck_at_1 |
required |
multi_bit_count |
bits per fault | 1 |
fault_persistence |
transient, permanent |
transient |
ovp_permanent_model |
inverted_cell |
none |
injection_mode |
icount, breakpoint, stepi |
icount |
stepi_reset_steps |
integer, 0 or more | none; required for stepi |
hang_icount_factor |
number above 1.0 | none; required |
faultlist_csv |
a fault list to replay row by row | |
num_cores |
1 to 4 | 1 |
stack_live_shared_reservation |
{bottom, top, harts} |
none |
num_workers |
1 |
1 |
All keys: Configuration keys.
Results¶
An OVP campaign writes the same files as a QEMU campaign, plus the driver's own evidence:
results/<campaign_id>/
├── injections.csv one row per injection
├── faultlist.json what each injection was asked to do
├── metadata.json the configuration as it ran
├── provenance.json package, driver, model and runtime hashes
├── report.tsv
├── results.txt outcome distribution
├── ovp_evidence/
│ └── injection_0001.json what was requested and what the driver observed
└── ovp_runs/
├── golden/attempt_1/
└── injection_0001/attempt_1/
├── console.txt the program's console output
├── driver.log the driver's log, license removed
└── evidence.json every record of the exchange, in order
injections.csv has the QEMU columns. For a register, original_value is the value the driver read at the stop and faulty_value is the value it read back after the write. For memory, both are the word of memory_access_size bytes. In breakpoint mode hit_instance holds K, and with several harts target_core holds the hart written.
Each ovp_evidence/injection_NNNN.json has two halves. requested is what HFIM asked for: the target, the instant, the mask and the persistence (transient, permanent or permanent (inverted cell)). observed is what the driver reported: the stop count and program counter, the original value, the written value, the readback and how the run ended. A retry of an injection gets a new attempt_N directory and never reads an earlier attempt's files.
provenance.json names the package, a digest of the driver binary, the processor model and its variant, and the hashes of the SDK's runtime loader and model. It records which variable named the license, never its value.
The outcome comes from HFIM's common classifier, with the driver's report as evidence:
| How the run ended | Outcome |
|---|---|
the program reached fim_exit (or wrote the virt test device); observables equal to the golden run |
masked |
| the same, observables differ | sdc (silent data corruption) |
the same, with fim_exit(1) |
detected |
| the hart trapped and reached the reset trap vector, with no handler installed | crash; the message gives mcause, mepc and mtval |
the instruction budget from hang_icount_factor ran out |
timeout |
the driver reported an error, the host timeout killed it, the fault never landed or was not verified, the simulator stopped for another reason |
infrastructure_failure |
The last row matters on OVP. A run the wall-clock timeout kills is an infrastructure_failure, not a timeout, because only the instruction budget is evidence that the program hung. A fault whose instant the program never reached is not masked either: the fault never happened. A load or store outside memory can also stop the model on the access fault itself, before the hart takes the trap; the run is then an infrastructure_failure whose message names the exception and the program counter, for example OVP stopped for Read privilege exception (sr=0x5, pc=0x80000062, count=555) with no guest trap. In a 30-injection register campaign on Fibonacci, 2 runs ended this way. The full decision order is on Fault classification.
Limitations¶
- Your SDK and license. HFIM ships only its driver source. The driver runs only where the OVP/Imperas SDK and a license are installed, on 64-bit Linux.
- One injection at a time.
num_workersabove 1 is refused: each fault is one driver process and the campaign runs them in order. A Fibonacci campaign of 30 register or memory injections on a single host takes about 3 s per injection. auto_registersneeds a Linux objdump. It reads the ELF withriscv64-unknown-linux-gnu-objdump. With only a bare-metal toolchain, setobjdump_pathin the toolchain profile or list the registers intarget_registers.- No checkpoints. Every injection runs from reset.
checkpointandcheckpoint_locationsare refused. - Architectural state only. No caches, pipeline, TLB or memory controller.
- Up to four harts of one processor.
target_clusterother than 0 is refused. - Board. Only
hfim-ovp-virt. Aboard.yamlnaming another board stops the campaign withboard '<name>' is not one hfim-sim-ovp@0.6.9 emulates. - Observables. The verdict uses only the variables in
observable_outputs, and the driver reads at most 32 of them.
See also: Control and status registers · Stuck-at · QEMU backend · Configuration keys