Skip to content

Load/store queue

gem5 only, with cpu_model: DerivO3CPU. Fault models: single-bit flip, multi-bit. fault: lsq.

An out-of-order processor does not send a store to memory the moment it decodes it. The store waits in the store queue, one half of the load/store queue (LSQ), until it has executed, committed and been written to the cache. While it waits, the value it is going to write lives in a physical register: the slot of the renamed register file that holds the store's data operand, for example a1 in sd a1, 0(a0). This target corrupts that physical register for the oldest store in the queue. As in every HFIM campaign, each run applies one fault, and HFIM compares the result with a fault-free golden run of the same program.

The target is the data, not the address. A RISC-V store names two source registers: the address base (a0 above) and the data (a1). HFIM always corrupts the data source, so a hit store writes to the right place, and any wrong value it writes is the wrong value at the right address.

How HFIM applies the fault

The campaign seed draws the instant and the bits for each run. The instant is a committed-instruction count from the golden run. The bits are drawn from 0 to 63, because a physical register holds a 64-bit word; bit_width narrows that range. With multi_bit_count above 1, the seed draws that many distinct positions, each independently, so they are usually not next to each other.

gem5 runs the program until that many instructions have committed. Then HFIM's injector inside gem5 takes the store at the head of the store queue, the oldest one still waiting. It looks up which physical register that store reads its data from, as fixed when the store was renamed, and applies the mask to that register's 64-bit value with an exclusive OR (XOR): every bit set in the mask is inverted, the others stay as they were. Integer stores (sb, sh, sw, sd) and floating-point stores (fsw, fsd) are handled the same way.

Whether the store itself writes the wrong value depends on where it is in its life:

State of the oldest store at the instant What the fault changes
Not executed yet, data operand ready the store reads the corrupted register when it executes and writes the wrong value to memory
Not executed yet, data operand still being computed the producing instruction later writes the correct value into the same register, which erases the fault
Already executed (committed or not) the store copied its data into the queue entry at execute and writes the original value; only later readers of the register see the fault

The last row is common: the head of the queue is often a store that has committed and is waiting for the cache. In that case the fault behaves like a physical register fault on the register the store read. It matters only if the program reads that architectural register again before overwriting it.

The write happens once per run, at the drawn instant. If the store queue is empty at that instant, gem5 writes nothing and does not retry later.

A campaign

This campaign uses the Fibonacci benchmark of the nezha-c906-gem5 template, whose 64-number result array is the output HFIM compares. It is the template's campaigns/fibonacci/register.yaml with the target changed to lsq and the CPU model changed to DerivO3CPU. Save it as campaigns/fibonacci/lsq.yaml beside fibonacci.yaml.

include: fibonacci.yaml

campaign_name: fibonacci-lsq

simulator_backend: gem5
cpu_model: DerivO3CPU

seed: 7
num_injections: 10
num_workers: 1

fault: lsq
fault_model: single_bit_flip

timeout: 120
output_dir: results

cpu_model overrides the template board, which builds the in-order MinorCPU, a CPU with no load/store queue of this kind. No other key is needed: you do not name a store or a register, because gem5 takes the oldest store at the instant of the fault.

hfim run campaigns/fibonacci/lsq.yaml

The log names the campaign type with Creating ultra-injector fault campaign (target=lsq), then confirms the draw with Faultlist generated: 10 entries.

What you see in the results

Each run adds one row to injections.csv, the comma-separated values (CSV) file of the campaign. For this target:

  • target_type and target_name are both lsq.
  • instruction_count is the committed-instruction count at which the fault landed.
  • bit_position is the drawn bit, from 0 to 63. A multi-bit campaign also fills bit_positions, separated by ;.
  • original_value and faulty_value are the 64-bit value of the store's data register before and after the flip, as gem5 reported them.

The CSV does not say which store or register was hit. That is in injection_NNNN/injection_report.json, in the target field, written as lsq_store_data[tid=0,data_reg=<class>,phys=<N>]. <class> is integer or floating_point, the register file of the data operand, and <N> is the physical register number. The same file holds the mask and the instant, and HFIM checks both against the CSV row. If they disagree, the run is recorded as infrastructure_failure instead of a hardware outcome.

The outcome comes from the same rules as every other target. A run ends masked when the observables (the variables HFIM compares, here result) match the golden run. Typically the store had already copied its data, or the flipped bit lies above the width of a narrow store, and the register was then overwritten before anything read it again. A run ends sdc (silent data corruption: the program finishes normally with a wrong result) when a wrong value reaches memory the program reports, either through the store itself or through a later instruction that reads the register. Because the address is never touched, a wrong store does not jump to another location; crash and timeout come from a corrupted value that is later used as a pointer, a loop bound or a branch condition. See Fault classification for the full decision order.

Keys

Key Values Default
fault (or target_types) lsq required
simulator_backend gem5 qemu
cpu_model DerivO3CPU the board's cpu.model
fault_model single_bit_flip; stuck-at is accepted and applied as a flip required
multi_bit_count 1 to the bit width 1
bit_width 8, 16, 32, 64 64

Limits

  • DerivO3CPU only. On any other CPU model, gem5 stops at the instant of the fault with lsq injection requires DerivO3CPU. No fault is written, so HFIM records the run as infrastructure_failure. The check happens inside gem5, not when the campaign loads.
  • The register, not the queue entry. HFIM corrupts the physical register the store reads, never the data copy inside the store-queue entry. A store that has already executed writes its original value. A fault in the queue's own storage cells, after the copy, is not modeled.
  • Oldest store only. The injector always takes the head of the store queue of hardware thread 0 of the simulated CPU. You cannot choose the store, and younger stores are never hit.
  • Stuck-at is a flip here. stuck_at_0 and stuck_at_1 are accepted, but the injector XORs the mask, so the drawn bits are inverted, not forced. fault_persistence: permanent has no effect: the value is written once.
  • Narrow stores write only their low bits. A flip in bits 8 to 63 cannot reach memory through an sb, nor bits 32 to 63 through an sw or fsw. Such a flip can still matter if a later instruction reads the whole register.
  • An empty store queue records no fault. If no store is waiting at the drawn instant, gem5 warns UltraInjector failed: Store queue is empty, writes no injection report, and the row is infrastructure_failure.

See also: gem5 backend · Physical registers · Single-bit flip · Configuration keys