Ruby controllers¶
gem5 only, on Ruby with the MESI_Two_Level protocol, with two or more cores. Fault models: single-bit flip, multi-bit, stuck-at. fault: ruby_tbe, ruby_mshr, ruby_directory, ruby_message_buffer.
An HFIM campaign runs your benchmark many times, with one fault per run, and compares each run with a fault-free golden run. This page covers the four targets that corrupt the coherence machinery between the caches of a multicore chip, rather than a register or a memory cell.
Ruby is gem5's detailed memory system. It models cache coherence as a set of controllers that pass messages to each other. HFIM's Ruby build uses the MESI_Two_Level protocol, named after the four states a cached line can be in (Modified, Exclusive, Shared, Invalid): each core has a private L1 controller, the cores share one L2 controller, and a directory controller stands in front of main memory. While a line moves between cores, these controllers hold copies of its data in several places: in a cache entry, in a transaction buffer entry (TBE) while a request for the line is open, in messages on their way between controllers, and in the directory's copy in memory.
A ruby_* fault corrupts one byte of one line in one of those places. You choose the line with a variable of your program, ruby_target_symbol, and the fault value chooses the place.
How HFIM applies the fault¶
Before the first run, HFIM reads the address of ruby_target_symbol from the benchmark's ELF file. That is the program's own address of the variable. When the fault fires, gem5 translates it through the program's page table to the physical address Ruby uses, and aligns it down to the start of its 64-byte line. In the figure, pingpong_var sits at 0x77440 in the program and at 0x67440 in physical memory.
The campaign seed draws the instant and the bits. The instant is a count of committed instructions inside the golden run's measured window. The bit position is drawn from 0 to 63 and then folded into one byte: bit b becomes bit b mod 8. A drawn bit 11 therefore flips bit 3. gem5 runs the program to the drawn instant, applies the fault once, and lets the program continue.
ruby_tbe¶
A TBE holds a line's data in a cache controller while a coherence request for that line is open, for example while an L1 waits for the line to arrive from the L2. With ruby_tbe, HFIM looks for a cache controller (an L1 or the L2) that holds the target line in a TBE or in a valid cache entry. It skips controllers with no copy and controllers whose copy is invalid, and takes the first holder in the order gem5 lists them.
On that controller, HFIM reads the line, applies the fault model to the byte at the target address, and writes the line back. While a request for the line is open, the controller reads and writes the TBE's copy; otherwise it uses the cache entry's copy. The fault lands in that copy. With a 64-byte-aligned variable, that byte is the lowest byte of the variable.
If no cache controller holds the line at that instant, gem5 prints no cache-side controller holds block ... No state to flip; injection NOT performed, the run continues without a fault, and its row is infrastructure_failure.
ruby_mshr¶
A miss status holding register (MSHR) is the name classic caches give to the entry that tracks an outstanding miss. In MESI_Two_Level, that state is the TBE. ruby_mshr runs exactly the same injector as ruby_tbe, so with the same seed both produce the same rows. It exists so a campaign can use the classic name.
ruby_directory¶
The directory controller tracks which caches hold each line and reads and writes main memory. With ruby_directory, HFIM reads the line through the directory: from the directory's own TBE when a memory transaction for the line is open, and from main memory otherwise. It applies the fault model to the target byte and writes the line back to both the TBE and memory.
This target corrupts the line's data as memory holds it, not the directory's record of sharers and owners. Whether the program ever sees it depends on which copy it reads next, as the results below show.
ruby_message_buffer¶
Controllers exchange requests and data in message buffers. With ruby_message_buffer, HFIM takes the first cache controller in gem5's list (L1Cache-0 in the template's runs) and rewrites the data field of every message in its buffers that is addressed to the target line. The new data is a zeroed 64-byte block with one byte, at an offset chosen by gem5's own random generator, set to the fault mask.
This is a stronger corruption than a bit flip: the whole 64-byte data block of each matching message is replaced. fault_model has no effect here. If no message for the line is in that controller's buffers at the drawn instant, gem5 prints hit no live state on controller ... report not written, the run continues without a fault, and its row is infrastructure_failure.
A campaign¶
The nezha-c906-gem5 template ships campaigns for ruby_tbe, ruby_mshr and ruby_directory in campaigns/pingpong/. Their benchmark, pingpong, starts a second hart (hardware thread), and the two harts take 256 turns each on one shared variable, pingpong_var: a hart waits until the value has its parity (even for hart 0, odd for hart 1), then adds one. Every turn moves the line from one L1 to the other, so there is nearly always coherence state to corrupt. Then hart 0 writes and reads back 512 KiB, more than the caches hold, and sums the result into checksum.
This is campaigns/pingpong/ruby_tbe.yaml:
include: pingpong.yaml
campaign_name: pingpong-ruby_tbe
simulator_backend: gem5-ruby
seed: 7
num_injections: 10
num_workers: 1
target_types: [ruby_tbe]
fault_model: single_bit_flip
timeout: 300
output_dir: results
The included pingpong.yaml sets benchmark: pingpong, num_cores: 2, ruby_target_symbol: pingpong_var and the observed variables checksum and pingpong_var. For another target, change target_types and campaign_name. Run it from the template's root directory:
hfim run campaigns/pingpong/ruby_tbe.yaml
Each injection directory holds gem5_stdout.log, which shows the address and mask gem5 received, and injection_report.json, which names the controller that took the fault and the physical address:
fault_type=ruby_tbe target_addr=0x77440 mask=0x8 at_instr=14699 num_cpus=2
"target": "ruby_tbe@67440 (controller L1Cache-1)",
What you see in the results¶
Row 4 of a real run of ruby_tbe.yaml, from injections.csv:
injection_id,timestamp,instruction_count,target_type,target_name,original_value,faulty_value,bit_position,hit_instance,target_core,target_cluster,outcome,execution_time,exit_code,timed_out,hang_cutoff,sdc_details,state_match
4,2026-10-22T13:07:56.316667,14699,ruby_tbe,ruby_tbe,0x9c,0x94,11,0,0,0,sdc,3.022,0,False,False,"checksum: expected 00f1010200222222, got e0ed010200222222; pingpong_var: expected 0002000011111111, got f801000011111111",False
instruction_countis the instant: 14,699 committed instructions, while the harts are still taking turns.original_valueandfaulty_valueare the corrupted byte before and after:0x9cbecame0x94.bit_positionis the drawn position, 11. The byte took it as bit 3, which is why the value dropped by 8.sdc_detailslists each observed variable that differs, with its bytes in memory order (lowest byte first).pingpong_varended 8 lower than golden, andchecksumdiffers too.
Bit 3 does not change the value's parity, so the turns went on and the run finished with wrong values: sdc (silent data corruption). A flip of bit 0 changes whose turn it is, which can leave a hart waiting for a turn that never comes; such a run ends as timeout.
Each template campaign has 10 injections and seed 7. One run of each gave:
| Campaign | masked |
sdc |
infrastructure_failure |
|---|---|---|---|
ruby_tbe.yaml |
0 | 10 | 0 |
ruby_mshr.yaml |
0 | 10 | 0 |
ruby_directory.yaml |
5 | 5 | 0 |
ruby_tbe.yaml with target_types: [ruby_message_buffer] |
1 | 0 | 9 |
ruby_tbe and ruby_mshr gave identical rows, because they are one injector. In the ruby_directory run, the five faults injected before instruction 37,323 were masked and the five injected after instruction 89,760 were sdc. Early on, a cache holds the line dirty, and its later writeback overwrites the corrupted memory copy. Late in the run, the line is read back from memory with the fault in it.
infrastructure_failure means no fault was written, so the row says nothing about the chip and is left out of the percentages. In the message-buffer run, 9 of the 10 drawn instants found no message for the line in L1Cache-0's buffers. Their error_message column says infrastructure failure: run finished without writing any fault. Every outcome and the order HFIM decides them in: Fault classification.
Keys¶
| Key | Values | Default |
|---|---|---|
fault or target_types |
ruby_tbe, ruby_mshr, ruby_directory, ruby_message_buffer |
required |
simulator_backend |
gem5-ruby; a ruby_* target selects the Ruby binary even with gem5 |
qemu |
num_cores |
2 or more for coherence traffic |
1 |
ruby_target_symbol |
a data symbol of the benchmark's ELF | pingpong_var |
ruby_target_addr |
the program's address of the line; replaces ruby_target_symbol |
0 (use the symbol) |
cpu_model |
TimingSimpleCPU, MinorCPU, DerivO3CPU |
the board's, else TimingSimpleCPU |
fault_model |
single_bit_flip, stuck_at_0, stuck_at_1; ignored by ruby_message_buffer |
required |
multi_bit_count |
bits per fault, folded into one byte | 1 |
Limits¶
- One byte per fault. Drawn positions above 7 fold into bits 0 to 7, so two positions such as 3 and 11 land on the same bit, and a multi-bit fault can flip fewer bits than
multi_bit_count. - One line per campaign: the line of
ruby_target_symbol. A variable that shares its line with others exposes them too; align it to 64 bytes, aspingpongdoes, to keep the fault in one variable. - With
num_cores: 1there is no coherence traffic. gem5 printsnum_cpus<2 means zero coherence trafficand the fault lands on state no other core reads. - A symbol absent from the ELF leaves no address: gem5 stops at the injection instant without writing a fault, and every row is
infrastructure_failure. Aruby_target_addrthat the program's page table does not map gives the same result. - The fault is applied once.
fault_persistence: permanentdoes not hold a Ruby fault; gem5 re-applies permanent faults only to registers. ruby_directorycorrupts the line's data in memory, not the directory's sharer and owner state. No target corrupts the coherence state bits of a Ruby line; the classic-cachecoherencetarget does that onsimulator_backend: gem5.ruby_message_bufferonly sees the buffers of the first cache controller, replaces whole data blocks, and draws its byte offset from gem5's random generator, not the campaign seed. In the run above, 9 of 10 rows wereinfrastructure_failure.- Ruby runs in syscall-emulation mode only, where gem5 runs the benchmark as a Linux program with no operating system underneath, and with the MESI_Two_Level protocol only.
AtomicSimpleCPUnever touches Ruby state. A campaign that leavescpu_modelunset runs onTimingSimpleCPU; one that statescpu_model: AtomicSimpleCPUis refused withcpu_model: AtomicSimpleCPU cannot reach target ....- The server's distributed workers run QEMU only, so a Ruby campaign runs on one machine.
See also: gem5 backend · Coherence · Multicore · Configuration keys