Skip to content

Cache tags

gem5 only. Fault models: single-bit flip, multi-bit. fault: cache_tag, cache_tag_parity.

Every line in a cache carries a tag: the upper bits of the memory address the line holds. When the processor (CPU) loads or stores, the cache compares the tag of the address with the tags stored in one set, and a match is a hit. These two targets flip bits in the stored tag of one valid line of the L1 data cache (L1D), so the line stops answering for its own address and starts answering for another one. 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 two targets differ in what they report. cache_tag rewrites the tag and lets the program show what happened, through the five usual outcomes. cache_tag_parity leaves the stored tag alone, applies the flip at every tag compare, and records what the compare did instead: a hit that became a miss, a miss that became a hit on the wrong line, or no change.

Two panels with the same L1D line, address 0x80008140 in set 5 with tag 0x40004. HFIM flips tag bit 1, so the tag reads 0x40006. Left: a lookup of 0x80008140 does not match and misses, tag_false_miss. Right: a lookup of 0x8000c140, which misses in the golden run, now matches and reads the data of 0x80008140, tag_false_hit. Two panels with the same L1D line, address 0x80008140 in set 5 with tag 0x40004. HFIM flips tag bit 1, so the tag reads 0x40006. Left: a lookup of 0x80008140 does not match and misses, tag_false_miss. Right: a lookup of 0x8000c140, which misses in the golden run, now matches and reads the data of 0x80008140, tag_false_hit.

The numbers above fit the template's L1D (32 kB, 4-way, 64-byte lines): 128 sets, so the tag starts at address bit 13. The mechanism is the same for both targets; the outcome names in the chips are the ones cache_tag_parity records.

How HFIM applies the fault

At the injection instant, a committed-instruction count drawn from the campaign seed, the gem5 controller lists every valid line of the L1D and picks one at random. The bits come from the campaign seed too: with single_bit_flip one bit, with multi_bit_count several distinct bits, all among tag bits 0 to 7. Flipping tag bit b moves the address the line answers for by 213+b bytes on the template's L1D, so between 8 kB and 1 MB away, always in the same set.

What happens next depends on the target:

cache_tag cache_tag_parity
Stored tag rewritten with the flipped bits unchanged; HFIM keeps the flip mask for that set and way
Next lookup of the line's own address misses, and the line is fetched again misses, and the line is fetched again
Lookup of the other address hits and reads this line's data hits and reads this line's data
Dirty line written back to the address of the faulty tag to its own address
How long the fault lasts until the line leaves the cache the rest of the run, also for a later line in the same set and way
Outcome masked, sdc, detected, crash or timeout, from the program tag_false_hit, tag_false_miss or tag_latent, from the tag compares

With cache_tag, the fault is ordinary corrupted state: a write-back to the wrong address corrupts memory there, a hit on the wrong line returns wrong bytes, and the classifier, the HFIM step that compares each run with the golden run, decides the outcome from the program's output. A clean line that is evicted takes the fault with it.

With cache_tag_parity, the fault is a shadow record. Every lookup that visits the faulted set and way compares the lookup tag twice, once with the stored tag and once with the stored tag XOR (exclusive OR) the mask, and writes the verdict to gem5_stderr.log:

Marker in gem5_stderr.log When
FIM-TAG registered the fault is in place (set, way and mask)
FIM-TAG false_miss the clean tag matches, the faulty one does not: the lookup skips the line
FIM-TAG false_hit the faulty tag matches, the clean one does not: the lookup returns this line
FIM-TAG latent both or neither match: the compare gives the golden answer
FIM-TAG latent_unconsumed at the end of the run, no lookup ever visited the faulted entry

A campaign

The gem5 template ships this campaign as campaigns/fibonacci/cache_tag.yaml. It flips one tag bit in each of 10 runs of the Fibonacci benchmark, whose 64-number result array is the output HFIM compares:

include: fibonacci.yaml

campaign_name: fibonacci-cache_tag

simulator_backend: gem5

seed: 7
num_injections: 10
num_workers: 1

target_types: [cache_tag]
fault_model: single_bit_flip

timeout: 120
output_dir: results

Run it from the template folder:

hfim run campaigns/fibonacci/cache_tag.yaml

For the parity variant, copy the file to campaigns/fibonacci/cache_tag_parity.yaml and change target_types to [cache_tag_parity] and campaign_name to fibonacci-cache_tag_parity, the label HFIM records for the campaign. The CPU is the board's MinorCPU. A target in a cache needs a CPU model with caches, so a campaign that leaves cpu_model unset on a board with AtomicSimpleCPU runs on TimingSimpleCPU, and a campaign that sets cpu_model: AtomicSimpleCPU is refused before the first run.

What you see in the results

Each run writes one row of injections.csv, the comma-separated values (CSV) file of the campaign, and one folder, injection_NNNN/. For both targets, target_type and target_name hold the target name, and original_value and faulty_value hold the whole tag before and after the flip. For cache_tag_parity, faulty_value is the tag the compares see; the stored tag never changes.

The set and way of the line are in the run's injection_report.json, in its target field: cache_tag[set=S,way=W] for cache_tag and cache_tag_shadow[set=S,way=W] for cache_tag_parity. The set and way columns of the CSV do not show them, and the cache_level column reads tag or parity, not l1d.

A cache_tag row gets one of the five common outcomes. A flip on a clean line ends masked when the line is fetched again or evicted before anything reads the other address. An sdc (silent data corruption, a wrong result with no error reported) needs the program to load from the other address while the line is still resident, or a dirty line written back over data the program reads later.

A cache_tag_parity row gets one of three outcomes of its own, and tag_fault_engaged is True. When the log holds several verdicts, the worst one wins:

Outcome Meaning
tag_false_hit at least one lookup matched the faulty tag where the golden run would miss: the CPU read the wrong line's bytes
tag_false_miss at least one lookup missed where the golden run would hit, and none hit wrongly: the line was fetched again
tag_latent no lookup changed its answer, or none visited the entry before the run ended

These three replace the classifier's verdict, even a crash or timeout: the row records what the tag compares did, not whether result differs from golden. Summaries count each of the three as its own outcome, not as sdc or masked. Every outcome: Fault classification.

Keys

Key Values Default
fault (or target_types) cache_tag, cache_tag_parity required
fault_model single_bit_flip; stuck-at is accepted and applied as a flip required
multi_bit_count 1 to 8 distinct tag bits 1
cpu_model TimingSimpleCPU, MinorCPU, DerivO3CPU; AtomicSimpleCPU is refused the board's, else TimingSimpleCPU

Limits

  • L1D only. Both targets always fault the L1 data cache. There is no instruction-cache or L2 variant, and cache_level_sweep does not apply.
  • cache_set and cache_way do not steer the fault. They belong to the cache family, so they are accepted, but the tag injectors pick a random valid line. The CSV echoes the values you set in its set and way columns even though the line may be another one; trust injection_report.json.
  • The line choice does not follow the campaign seed. The bit and the instant come from the seed; the line is drawn by gem5's own random generator among the lines valid at that instant.
  • Stuck-at is a flip here. stuck_at_0 and stuck_at_1 are accepted, but both tag injectors XOR the mask, so the bit is inverted, not forced. fault_persistence: permanent has no effect on these targets.
  • No parity check. Despite its name, cache_tag_parity does not compute parity or signal an error: no row becomes detected because of the tag. cache_ecc_scope: tag does not add one either.
  • The parity mask outlives the line. In cache_tag_parity the mask is tied to the set and way, so a line that fills that way later inherits it. In real hardware, writing a new tag would replace the flipped bit.
  • An empty cache records no fault. If the L1D has no valid line at the injection instant, gem5 warns UltraInjector failed: No valid cache blocks, writes no injection report, and the row is infrastructure_failure, the outcome HFIM gives a run in which no fault was written.

See also: gem5 backend · Cache data · Single-bit flip · Configuration keys