Skip to content

Registers

QEMU, gem5, OVP and hardware. Fault models: single-bit flip, multi-bit, stuck-at. fault: register.

A register fault changes bits in one of the processor's architectural registers: an integer register such as a0 (x10), a floating-point register such as fa0 (f10), or, on some backends, the program counter. This is the classic single event upset: a particle strike flips one cell of the register file while the program runs. An HFIM campaign applies one such fault per run and compares the run with a fault-free golden run of the same program, so each fault gets its own verdict.

You choose which registers can be hit, either as an explicit list (target_registers) or by letting HFIM read the registers your compiled program actually uses (auto_registers: true). For every injection, HFIM draws one register from that pool, one bit and one instant.

Register x12 holds 0x1028. HFIM flips bit 4 of the 64-bit register, so it holds 0x1038; the zoomed low byte goes from 0x28 to 0x38. Register x12 holds 0x1028. HFIM flips bit 4 of the 64-bit register, so it holds 0x1038; the zoomed low byte goes from 0x28 to 0x38.

How HFIM applies the fault

Before the first injection, HFIM builds the fault list from the campaign seed. For each entry it draws, in this order, the instant (an instruction count, or a program counter in breakpoint mode), one register from the pool, the bit or bits to change, and, on a multicore campaign, the hart (hardware thread) that takes the fault. Each draw is independent of the others. The same seed gives the same list every time, but the pool is not covered as a grid: with 10 injections and 6 registers, some registers can be hit twice and others not at all.

Register names are normalized before anything runs. You can write the ABI (application binary interface) name (a0, s1, fa0) or the architectural name (x10, x9, f10); HFIM records the architectural name in the results. Duplicates are removed.

At the drawn instant, the backend stops the program, reads the register, applies the fault model and writes the new value back. The program then continues. A transient fault (the default) is gone once the program writes that register again, so a flip only matters if the corrupted value is read first.

An integer register is as wide as the hart: 64 bits on a 64-bit RISC-V (RV64) hart, so bits 0 to 63 can be drawn. A floating-point register is always handled as its raw 64-bit pattern (FLEN, the floating-point register width, is 64), even on a 32-bit hart. multi_bit_count flips several distinct bits of the same register. Each position is drawn independently, so the bits are usually not next to each other.

The backends differ in how they reach the register:

QEMU gem5 OVP Hardware
How the value is written GDB (the GNU Debugger) stops the guest, reads, writes back the injector compiled into gem5, at the drawn committed-instruction count HFIM's OVP driver stops the hart before the drawn instruction GDB through the board's debug probe
Integer registers x1 to x31 x1 to x31 x1 to x31 x1 to x31
Float registers f0 to f31 f0 to f31 f0 to f31 not verified on a board
pc yes, named explicitly no yes, named explicitly not verified
auto_registers yes yes not documented not documented
Width set by xlen yes no, always 64 no, always 64 yes
fault_persistence: permanent no yes, re-applied after every committed instruction stuck-at, or ovp_permanent_model: inverted_cell no

OVP (Open Virtual Platforms) runs one RV64 model with HFIM's driver and needs a few extra keys of its own; see the OVP backend.

A campaign

This is campaigns/fibonacci/register.yaml from the nezha-c906-qemu template, with its comments shortened. The Fibonacci benchmark fills a 64-entry array result[], each value the sum of the previous two, so a corrupted term that the program reads spreads to the end of the chain.

include: fibonacci.yaml          # benchmark: fibonacci, observable result[]

campaign_name: fibonacci-register

simulator_backend: qemu

seed: 7
num_injections: 10
num_workers: 1

target_types: [register]         # the same as fault: register
target_registers: [x10, x11, x12, x13, x14, x15]
fault_model: single_bit_flip
injection_mode: icount

timeout: auto
output_dir: results
hfim run campaigns/fibonacci/register.yaml

To let HFIM pick the registers instead, replace the target_registers line with auto_registers: true. HFIM then runs the toolchain's objdump over the benchmark ELF (Executable and Linkable Format) file and keeps every distinct register name that appears in the disassembly. Integer registers are included by default, float registers only with include_floats: true. The automatic pool covers the whole integer file, including ra, sp, gp, tp and fp when the code uses them, and it never contains x0 or pc. A target_registers list given together with auto_registers: true is added to the automatic pool, which is how you add pc.

Either way, the campaign log prints the resolved pool once, as Target registers: followed by the architectural names and their count. With auto_registers, an Autodetected N registers line comes first. Check that line before a long campaign: it is the pool your seed draws from.

What you see in the results

Each injection is one row of injections.csv in the campaign's results directory. These three rows come from a QEMU register campaign on the same Fibonacci benchmark, seed 1234:

injection_id,timestamp,instruction_count,target_type,target_name,original_value,faulty_value,bit_position,hit_instance,outcome,execution_time,exit_code,timed_out,hang_cutoff,sdc_details,state_match
1,2026-09-07T12:10:05.207033,1071,register,x22,0x0,0x4000,14,0,masked,6.920,0,False,False,,True
2,2026-09-07T12:10:05.204123,282,register,x12,0x1028,0x1038,4,0,masked,6.916,0,False,False,,True
3,2026-09-07T12:10:05.207026,962,register,x7,0x0,0x400,10,0,masked,6.921,0,False,False,,True

Row 2 is the figure above. instruction_count is the retired-instruction count at which the fault landed (282). target_name is the register in architectural form (x12, which is a2). original_value and faulty_value are the register before and after the write, and bit_position is the bit that changed. On gem5 and OVP, the two values come from the backend's own report of the injection. outcome is the verdict, and state_match says whether the program's observable state (here result[]) equals the golden run's.

All three rows are masked: the program finished with the same result as the golden run. A register the program does not read again before it overwrites it cannot change the result; x22 and x7 both held 0x0 here, a sign that the program was not using them at that point. A register that holds a live value gives sdc (silent data corruption: the program ends normally but result[] differs) when the value reaches the output. Flipping a pointer such as sp or ra can give crash (the program fails), and flipping a loop counter can give timeout (the run exceeds its time limit). How each outcome is decided: Fault classification. Every column: Output files.

Keys

Key Values Default
target_registers list of ABI names (a0, s1, t0, fa0) or architectural names (x10, f10), plus pc on QEMU and OVP required, unless auto_registers: true
auto_registers true: the pool is the registers the ELF uses; a target_registers list is added to it false
include_int with auto_registers: include integer registers true
include_floats with auto_registers: include float registers false
allow_zero_register true: accept x0 (zero) in the pool false
xlen 32 or 64: the hart's integer register width (QEMU, hardware) from the ELF
verify_injection true: read the register back after the write (QEMU, hardware) false

target_registers: auto is also accepted and behaves like auto_registers: true, with a warning that suggests the auto_registers form. All keys with their backends: Configuration keys.

Limits

  • One target family per campaign. A register campaign that also sets a memory or cache key is rejected before anything runs, for example fault: register does not use these keys: memory_start.
  • x0 is refused by default. It always reads 0, so a flip there is masked by definition. The error is Cannot target x0 register (hardwired to 0 on riscv64). Set allow_zero_register: true .... Opt in only to test that masking property. OVP refuses x0 in any case.
  • Unknown names are rejected at load, with the valid forms in the message: Invalid register 'q9' for riscv64. Valid: x1, x2, x3, x4, x5... or aliases: ra, sp, gp, tp, fp...; special: pc.
  • include_int and include_floats act only on the automatic pool. With an explicit list and no auto_registers, they are dropped with a warning. Setting both to false is rejected, because the pool would be empty.
  • auto_registers needs the toolchain's objdump. HFIM derives it from the toolchain's gdb_path (same directory, objdump in place of gdb); objdump_path in the toolchain profile overrides it. If neither resolves, setup stops with Cannot resolve objdump for target_registers: auto.
  • A 32-bit hart. With xlen: 32, QEMU limits an integer register fault to bits 0 to 31. The fault list draws from bit_width, which is 64 for registers unless you set it, and an injection that drew a bit above 31 fails instead of running. Set bit_width: 32 as well. Float registers stay 64 bits wide.
  • gem5 with cpu_model: DerivO3CPU. A register fault makes gem5 abort (Program aborted at tick), and the run is classified crash. On that CPU model, use physical registers (fault: phys_reg).
  • gem5 has no pc target. gem5 stops with FIMController: unknown register name 'pc'.
  • Transient on QEMU and hardware. fault_persistence: permanent is rejected there; the fault is written once and the program's next write to the register erases it.
  • Control and status registers (CSRs) are a separate target, csr, available only on OVP and only replayed from a fault list. See the OVP backend.
  • Multicore. On a campaign with several harts, target_core chooses which hart's registers take the fault. See Multicore.

See also: QEMU backend · Single-bit flip · Memory · Configuration keys