TLB¶
gem5 only, any CPU model. Fault models: single-bit flip; the injector always flips exactly one bit. fault: tlb.
In syscall-emulation mode, a tlb fault injects nothing
HFIM runs gem5 in syscall-emulation mode. There, RISC-V gem5 translates every address through the process page table and never fills the TLB. A tlb injection finds no valid entry, writes no fault, and every row of the campaign ends as infrastructure_failure. The rest of this page describes what the injector does when the TLB does hold entries, so you can recognize these rows and know why they appear.
A translation lookaside buffer (TLB) is a small cache of address translations. When a program uses a virtual address, the memory management unit (MMU) looks up the virtual page in the TLB and gets back the physical page that holds it, without walking the page table in memory. Each entry pairs a virtual page number (VPN) with a physical page number (PPN).
The tlb target flips one bit of the PPN in one valid entry of the data TLB. After the flip, every load and store to that virtual page reaches a different physical page, with no error from the hardware. As in every HFIM campaign, each run applies one fault, and HFIM compares the run with a fault-free golden run of the same program.
How HFIM applies the fault¶
At the injection instant, a committed-instruction count drawn from the campaign seed, the gem5 controller calls the TLB injector once. The injector works on the data TLB of the first hart (RISC-V hardware thread), hart 0, and goes through these steps:
- It lists the entries that are installed in the TLB, that is, entries that hold a live translation.
- If the list is empty, it stops. gem5 prints a warning, no fault is written, and the run continues as a fault-free run. This is what always happens in syscall-emulation mode.
- Otherwise it picks one installed entry at random.
- It flips one bit of the entry's physical address, chosen at random between bit 12 and the top bit of the simulated memory.
Bits 0 to 11 are the offset inside a 4 KiB page, so the flip never touches them: it changes the page, not the byte inside the page. The top of the range is the base-2 logarithm of the memory size, so the new page stays inside the simulated memory. With the 256 MB of the nezha-c906-gem5 template board, the bit is one of 12 to 27.
The entry and the bit come from gem5's own random generator, not from the campaign seed. The seed decides only the instant. The bit_position the faultlist draws for the row is not used, and neither are fault_mask and multi_bit_count. The injector always inverts the bit, so stuck_at_0 and stuck_at_1 behave like a flip.
The injector tries once per run. If it finds nothing at the injection instant, it does not try again later in the run.
A campaign¶
The nezha-c906-gem5 template does not ship a tlb campaign. You can write one next to its Fibonacci campaigns, in campaigns/fibonacci/tlb.yaml. The benchmark computes 64 Fibonacci numbers into the array result, which fibonacci.yaml names as the output HFIM compares:
include: fibonacci.yaml
campaign_name: fibonacci-tlb
simulator_backend: gem5
seed: 7
num_injections: 10
num_workers: 1
target_types: [tlb]
fault_model: single_bit_flip
timeout: 120
output_dir: results
Run it from the template folder:
hfim run campaigns/fibonacci/tlb.yaml
The campaign is accepted and runs every injection to the end. Because the template runs in syscall-emulation mode, the data TLB is empty at every injection instant, and gem5 writes this warning to gem5_stderr.log in each run's folder:
warn: UltraInjector failed: dtlb has no installed entries -- SE-mode RISC-V bypasses the TLB entirely (Process::pTable::translate); TLB injection requires an FS-mode workload
SE and FS in the message are gem5's short names for syscall-emulation mode and full-system mode.
When the last injection ends, hfim run sees that no run wrote a fault, prints a line that starts with No fault was injected: every injection is an infrastructure failure followed by a line of the first row's error message, and exits with status 1, so a script that runs the campaign does not mistake it for a measured result.
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/. In syscall-emulation mode every row of a tlb campaign looks the same:
outcomeisinfrastructure_failure. HFIM uses this outcome when a run wrote no fault, so the run says nothing about the program. It is never counted asmasked.error_messagestarts withinfrastructure failure: run finished without writing any fault (target never reached, or no resident state to flip); no injection_report.json, and may continue with the start of gem5's error output.- The run folder has no
injection_report.json, the file gem5 writes at the instant a fault lands.
infrastructure_failure describes HFIM, not the chip, so it tells you the campaign measured nothing. Every outcome and the order HFIM decides them in: Fault classification.
When gem5 does find an installed entry, the injector writes injection_report.json like the other gem5 targets. Its target field names the TLB, the entry index and the entry's virtual address, in the form dtlb[idx=<entry>,vpn=<virtual address>], and original_value and faulty_value hold the entry's physical address before and after the flip. The row then gets one of the usual outcomes, decided from the program's output.
Keys¶
| Key | Values | Default |
|---|---|---|
fault (or target_types) |
tlb |
required |
simulator_backend |
gem5 |
qemu |
fault_model |
single_bit_flip; stuck-at is accepted and applied as a flip |
required |
cpu_model |
AtomicSimpleCPU, TimingSimpleCPU, MinorCPU, DerivO3CPU |
the board's cpu.model (MinorCPU in the nezha-c906-gem5 template), else AtomicSimpleCPU |
fault_mask and multi_bit_count are accepted but have no effect on this target. The cache keys cache_set, cache_way, cache_ecc_enabled, cache_ecc_scope and cache_level_sweep are refused when the campaign loads, with fault: tlb does not use these keys: cache_set. One campaign = one fault type; .... Every key: Configuration keys.
Limits¶
- No effect in syscall-emulation mode. This is the mode HFIM runs gem5 in, so a
tlbcampaign produces onlyinfrastructure_failurerows. To study address-translation faults, a full-system workload whose TLB holds entries is needed; HFIM's gem5 campaigns do not provide one for this target. - Data TLB only. The injector has a path to the instruction TLB, but a campaign always reaches the data TLB. There is no key to choose the instruction TLB.
- First hart only. On a multicore campaign, the fault goes to hart 0's TLB.
- The entry and bit do not follow the campaign seed. They come from gem5's random generator, and the faultlist neither records nor sets them. A faultlist replay sets only the instant.
- One bit, always inverted. Multi-bit and stuck-at settings do not change what the injector does.
- 4 KiB pages assumed. The bit range starts at bit 12 whatever the page size of the entry. Large pages (2 MB and 1 GB) get the same range.
- The fault lasts only while the entry stays in the TLB. Only the cached translation changes, not the page table, so once the entry is evicted or flushed, the next page-table walk installs the correct translation again.
See also: gem5 backend · Memory · Single-bit flip · Configuration keys