DRAM¶
gem5 only; on gem5-ruby every model becomes a single-bit flip (see Limits). Fault models: fault_model is required but not used; dram_error_model decides which bits change. fault: dram.
DRAM (dynamic random-access memory) is the main memory behind the caches. Its errors have shapes that a single bit flip does not capture: one cell upset by a particle, a cluster of neighboring cells upset together, several cells of one row disturbed by activity on nearby rows, or a cell that leaks its charge and loses a stored 1. The dram target corrupts gem5's main memory with one of these shapes, chosen by dram_error_model, and can add a DRAM ECC (error-correcting code) verdict on top.
An HFIM campaign runs your benchmark many times, with one fault per run, and compares each run with a fault-free golden run of the same program. A dram fault differs from a memory fault in where it lands: not in a variable or section you name, but at a random byte anywhere in main memory.
The figure shows the row model, the one that touches more than one byte. The other models change bits inside a single byte.
How HFIM applies the fault¶
Each injection fires at the instruction count the campaign draws for it. At that instant, gem5's fault injector picks one byte uniformly from the whole address range of main memory. The injector draws the address, the bits and the row count from gem5's random number generator, which it seeds for each injection from the campaign seed and the injection's number. Each injection of a campaign therefore draws its own address, and the same campaign run again draws the same ones. That range is all the memory gem5 gives the machine, so most of it holds nothing your program uses. The injector then applies the error model to that byte, or to its row, and lets the program continue.
The write goes straight into the memory's storage, below the caches. The program sees the change only when it next fetches that byte from main memory.
dram_error_model |
What changes | Bits counted |
|---|---|---|
none (default) |
the same as single_bit |
1 |
single_bit |
one random bit, 0 to 7, of the byte flips | 1 |
multi_bit |
dram_multi_bit_count adjacent bits of the byte flip; the lowest one is random, placed so that all of them fit in the byte |
dram_multi_bit_count |
row |
the row is the block of dram_row_size bytes, aligned to that size, that holds the byte. Between 1 and 8 byte addresses are drawn inside it, and one random bit flips in each |
number of bytes drawn |
retention |
one random bit of the byte is cleared to 0, as charge leaks away. If that bit was already 0, nothing changes | 1, or 0 when nothing changed |
multi_bit here is a burst of neighboring bits, unlike the multi_bit_count key of other targets, which draws independent bit positions. In row, the draws are independent, so the same byte can be drawn twice; if the same bit is drawn again, the second flip undoes the first.
DRAM ECC¶
Server memory usually carries SECDED ECC (single error correct, double error detect): extra check bits that let the memory controller repair one wrong bit and notice two. With dram_ecc_enabled: true, HFIM checks the bits counted in the table above against that rule:
fault: dram
dram_error_model: row # any value except none
dram_ecc_enabled: true
| Bits counted | SECDED would | target in injection_report.json |
|---|---|---|
| 1 | correct it | dram_ecc_corrected[0x<address>] |
| 2 | detect it, not correct it | dram[0x<address>,model=<model>,bits=2] |
| 3 or more | miss it | dram[0x<address>,model=<model>,bits=<n>] |
0 (a retention bit that was already 0) |
see nothing | dram[0x<address>,model=retention,bits=0] |
Only the one-bit case changes the record: it gets the dram_ecc_corrected label and a log message. A 2-bit or larger error is recorded exactly as with ECC off. In every case the flipped bits stay in memory: a corrected error is not undone, and a detected one raises no trap. The run's outcome therefore comes from the program alone, as with ECC off. The count is the total for the whole injection, so a row error that touches two bytes counts as 2, although real SECDED checks each memory word on its own.
dram_ecc_enabled needs a dram_error_model other than none. Without one, the campaign is refused before it runs:
dram_ecc_enabled acts only with a dram_error_model; this campaign sets none, so gem5 would ignore it.
A campaign¶
The nezha-c906-gem5 template has no DRAM campaign, but one fits next to its Fibonacci campaigns as campaigns/fibonacci/dram.yaml. The Fibonacci benchmark fills result[64] with the first 64 Fibonacci numbers, and fibonacci.yaml, which this file includes, sets the benchmark and compares result with the golden run:
# campaigns/fibonacci/dram.yaml
include: fibonacci.yaml
campaign_name: fibonacci-dram
simulator_backend: gem5
seed: 7
num_injections: 10
num_workers: 1
fault: dram
fault_model: single_bit_flip # required; the DRAM model decides the bits
dram_error_model: row
dram_row_size: 8192
dram_ecc_enabled: true
timeout: 120
output_dir: results
Run it from the repository root:
hfim run campaigns/fibonacci/dram.yaml
Each injection directory holds gem5's output in gem5_stdout.log and gem5_stderr.log. Look there for the message the injector prints when it arms the fault and, with ECC on and a one-bit error, the correction message. The values in angle brackets vary per run:
FIMController: armed for dram injection at instruction <N> (target=dram, model=bit_flip, mask=0x<mask>)
FIMController: ECC corrected 1-bit DRAM error at 0x<address>
The dram target does not use the mask in the first message or the fault_mask field of the report. HFIM passes no mask for this target, so gem5 also warns that it drew one itself; you can ignore that warning here.
What you see in the results¶
The record of a DRAM fault is the target field of injection_report.json, in each injection_NNNN/ directory. It holds the drawn address, the model and the bits counted. These are the target fields of five gem5 runs of the injector on the mmult benchmark, one per model or setting, each injecting at instruction 500000. The multi_bit run used a count of 3, and the last run is single_bit with ECC on:
dram[0x00000000032c5143,model=single_bit,bits=1]
dram[0x00000000032c5143,model=multi_bit,bits=3]
dram[0x00000000032c5143,model=row,bits=6]
dram[0x00000000032c5143,model=retention,bits=0]
dram_ecc_corrected[0x00000000032c5143]
For row, the address is the byte the row was found from; the bytes that changed inside the row are not listed. The five runs started from the same generator state, so they share one address; the injections of one campaign each draw their own. The retention run drew a bit that was already 0, so memory did not change and the run can only be masked.
In injections.csv, a DRAM row has target_type and target_name both dram. original_value is 0x0 and faulty_value is the number of bits counted, copied from the report (0x0 for an ECC-corrected fault). bit_position is the campaign's own draw and does not describe the fault. Read the address from the report.
The outcome column follows the usual rules. masked means the observed result matches the golden run; sdc (silent data corruption) means it differs and the benchmark did not report it; crash and timeout mean the program did not finish normally. Because the byte is drawn from all of main memory, a small program like Fibonacci rarely uses it, so expect mostly masked. The five outcomes and the order HFIM decides them in: Fault classification.
Keys¶
| Key | Values | Default |
|---|---|---|
dram_error_model |
none, single_bit, multi_bit, row, retention |
none |
dram_multi_bit_count |
1 to 8, the bits flipped by multi_bit; set it only with that model |
2 |
dram_row_size |
row size in bytes for row; set it only with that model |
8192 |
dram_ecc_enabled |
true adds the SECDED verdict; needs a model other than none |
false |
Each of these keys is gem5 only. On another backend, a value other than the default is refused at load with an error that names the key and the backend. A count or row size set with the wrong model is refused too, for example:
dram_multi_bit_count acts only with dram_error_model: multi_bit; this campaign uses row, so gem5 would ignore it.
Limits¶
- You cannot aim a DRAM fault at a variable or a section.
section,memory_startandmemory_endare refused withfault: dram, andtarget_symbolis accepted but not used. To corrupt bytes your program uses, usefault: memory. - Every DRAM fault is applied once.
fault_modelandfault_persistenceare accepted but not used, sostuck_at_0,stuck_at_1andpermanenthave no effect here. - The fault bypasses the caches. If the line is in a cache, the program keeps reading the cached copy, and a dirty line written back later overwrites the corrupted byte.
- A row is a block of physical addresses, not the device's real row, bank and column mapping. Neighbouring rows are never touched, so
rowdoes not model a disturbance that spreads from one row to the next. dram_multi_bit_countmust be between 1 and 8, because the burst stays inside one byte. HFIM does not check this.- The ECC verdict labels the fault but never removes it, and no DRAM ECC result produces the
detectedoutcome. - On
gem5-ruby, the Ruby script does not passdram_error_modelordram_ecc_enabledto the injector, so every DRAM fault there is asingle_bitflip without ECC. - There is no DRAM ECC check-bit target.
fault: ecc_parity_dramis refused at load, with a message that points tofault: dramanddram_ecc_enabled.
See also: gem5 backend · Memory · DRAM error models · Configuration keys