Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

16.8 RAS handling and error injection

16.7 defined what the hardware records and signals. This section covers who handles it, how the result reaches the OS, and how to make errors happen on demand so that every path can be tested before a real DIMM fails in the field.

Firmware-first vs kernel-first

The split is set by three EL3 controls, plus the GIC group of the RAS interrupts:

ControlFirmware-first (FFH)Kernel-first (KFH)
SCR_EL3.EA1: External aborts and SErrors from all lower ELs go to EL30: they go to the OS’s EL (3.3)
SCR_EL3.TERR1: ERR*/ERX* System-register accesses from EL1 and EL2 trap to EL30: the OS reads records directly
Memory-mapped record framesSecure-only (TZC/PAS)Non-secure, described in AEST
FHI/ERI interruptsGroup 0 or Secure Group 1, handled at EL3 or in a Secure PartitionNon-secure Group 1, handled by the OS driver
What the OS seesCPER records in GHES status blocks, announced by a notificationthe raw records

FFH keeps one implementation of the platform-specific decode (which RAM, which DIMM, which die) in firmware, hides microarchitectural detail and Secure addresses, and can act on errors the OS cannot see (Secure memory, the SCP’s RAMs, interconnect errors). It costs latency and firmware complexity, and it needs a channel to the OS. KFH is simpler and faster. It needs an OS RAS driver that understands every node, and it cannot cover errors in Secure-only resources. Many servers mix the two: kernel-first for PE caches, firmware-first for memory and interconnect.

Even under KFH, EL3 is involved. An SError raised by lower-EL code can be pending when the PE enters EL3 (on an SMC, or on a Group 0 interrupt). With SCTLR_EL3.IESB, TF-A synchronizes it on entry (ESB, then DISR_EL1) and reflects it to the lower EL: it builds the exception entry to the lower EL’s SError vector as if the error had been taken there. TF-A detects a loop in which the reflected error is masked at its target and immediately re-enters EL3, and panics in that case. FEAT_E3DSE (delegated SError injection by EL3) is the architected fix for that corner case (3.4).

In TF-A the relevant build options are ENABLE_FEAT_RAS, HANDLE_EA_EL3_FIRST_NS (FFH), EL3_EXCEPTION_HANDLING (the Exception Handling Framework, EHF, which arbitrates RAS against other EL3 interrupts at PLAT_RAS_PRI), SDEI_SUPPORT, RAS_TRAP_NS_ERR_REC_ACCESS (sets TERR) and FAULT_INJECTION_SUPPORT (sets SCR_EL3.FIEN). Platforms describe their nodes with ERR_RECORD_SYSREG_V1(...) / ERR_RECORD_MEMMAP_V1(...) and map interrupts with REGISTER_RAS_INTERRUPTS().

The FFH hand-off: APEI, GHES and SDEI

ACPI’s Platform Error Interfaces (APEI) are the OS contract:

  • HEST lists error sources. For Arm, each is usually a GHESv2 entry: the address of an error status block that firmware fills with a UEFI CPER record (an ARM Processor Error section, a Memory Error section and so on), a notification method, and a Read Ack register that the OS writes when it has consumed the block.
  • BERT reports errors from the previous boot (for example a UC that reset the system).
  • ERST is persistent storage for error records. EINJ is the injection interface, described below.

Notification methods on Arm include an interrupt (GSIV), the “Arm SEA” and “Arm SEI” types (the OS is told during its own synchronous External abort or SError handling), and SDEI (Software Delegated Exception Interface, DEN0054). SDEI is the usual choice for asynchronous FFH. It gives firmware an NMI-like way into the OS:

  1. At boot the OS registers a handler for the event number taken from the HEST entry: SDEI_EVENT_REGISTER, SDEI_EVENT_ENABLE, then SDEI_PE_UNMASK on each PE.
  2. An FHI arrives as a Group 0 interrupt at EL3. EHF dispatches it to the RAS handler, which walks the records, builds the CPER record (in EL3, or in a Secure Partition reached over FF-A or MM, 12.3), clears the records and signals the event (sdei_dispatch_event() in TF-A).
  3. The SDEI dispatcher saves the interrupted Non-secure context and enters the OS handler at Non-secure EL1/EL2 with the event’s arguments. SDEI events are taken even when the OS has PSTATE.I masked, subject to the event’s priority (normal or critical) and the PE’s SDEI mask.
  4. The OS handler (in Linux, ghes_sdei_normal_callback/ghes_sdei_critical_callback) reads the status block, queues the CPER record, writes the Read Ack register, and calls SDEI_EVENT_COMPLETE (or SDEI_EVENT_COMPLETE_AND_RESUME). EL3 then restores the interrupted context.

For a synchronous External abort under FFH the same CPER is produced, but the notification is SEA. EL3 fills the block, then returns into the OS’s synchronous abort vector, as if the abort had been taken there. The OS finds the record through the HEST SEA source and runs memory_failure() on the page.

Bring-up note: the most common FFH failure is not in the RAS code. It is a GHES status block in memory that the OS maps with different attributes from the ones firmware used to write it, or a Read Ack that is never written, so that firmware considers the block busy and drops every later error. Check that the status block’s address is in memory the OS treats as reserved, that both sides agree on cacheability, and that the ack value matches the HEST Read Ack Preserve/Write fields.

Pseudo-fault generation

The Common Fault Injection Model (FEAT_RASv1p1, 16.7) gives each node that supports it (ERR<n>FR.INJ non-zero) three registers. They exist only in the node’s first record; for the node’s other records they read as RES0:

RegisterRole
ERR<n>PFGFFeatures, read-only: which error types and status bits can be injected (OF, UC, UEU, UER, UEO, DE, CE, CI, ER, PN, AV, MV), whether restart (repeat) mode exists (R), whether software supplies the IERR/SERR syndrome (SYN), and NA (whether an injected error needs an access to the protected structure to be recorded)
ERR<n>PFGCTLWhat to inject, using the same type bits (for example UC is bit 1). CDNEN (bit 31) loads the Error Generation Counter from PFGCDN and starts it, and R (bit 30) reloads it and repeats on reaching zero
ERR<n>PFGCDNCountdown value. When it reaches zero, the node generates the error

The PE-local versions are ERXPFGF_EL1, ERXPFGCTL_EL1 and ERXPFGCDN_EL1, accessible from EL1/EL2 only when SCR_EL3.FIEN == 1 (and HCR_EL2.FIEN == 1 for EL1 under a hypervisor). Otherwise they trap. The sequence (the same shape as TF-A’s test code):

    // inject an Uncontainable error into PE error record 0. Requires SCR_EL3.FIEN = 1
    msr   ERRSELR_EL1, xzr
    isb                             // the selection takes effect for later ERX* accesses
    mrs   x0, ERXCTLR_EL1
    orr   x0, x0, #1                // ED: enable error detection and reporting
    msr   ERXCTLR_EL1, x0
    mov   x0, #1
    msr   ERXPFGCDN_EL1, x0         // countdown of 1
    mrs   x1, ERXPFGF_EL1
    tbz   x1, #1, no_uc_injection   // PFGF.UC (bit 1): UC injection supported?
    ldr   x0, =0x80000002           // PFGCTL: CDNEN (bit 31) | UC (bit 1)
    msr   ERXPFGCTL_EL1, x0
    isb
1:  wfe                             // the SError arrives (SCR_EL3.EA decides where)
    b     1b

Two limits matter for test design:

  • It injects a report, not a fault. The node behaves as if it had detected the error. It sets up the record and raises the configured in-band or out-of-band signals, but it is IMPLEMENTATION DEFINED whether any data is actually corrupted or poisoned, and when, relative to the countdown, the error appears (PFGF.NA says whether the node waits for an access to the protected structure or records the error spontaneously). PFG tests the reporting and handling path. It does not test the ECC logic or real poison propagation, which need the memory controller’s or RAM’s own (IMPLEMENTATION DEFINED) injection.
  • The type is chosen by software, so incoherent combinations are possible. Validate that the handler copes with what hardware can really produce, and also with what PFG can produce. For example, a UER injected into a node that can never report precisely will still be reported as an SError.

ACPI EINJ and OS-driven injection

EINJ lets the OS ask firmware to inject an error, so that injection works without FIEN and on nodes whose PFG registers are Secure-only. The table holds a list of actions (BEGIN_INJECTION_OPERATION, SET_ERROR_TYPE, SET_ERROR_TYPE_WITH_ADDRESS, EXECUTE_OPERATION, CHECK_BUSY_STATUS, GET_COMMAND_STATUS, END_OPERATION, …), each implemented as register reads and writes. On Arm platforms EXECUTE_OPERATION usually rings a doorbell that runs firmware (EL3, Standalone MM or the SCP), and that firmware then programs PFG or a memory controller’s injector. From Linux:

modprobe einj
cd /sys/kernel/debug/apei/einj
cat available_error_type          # e.g. 0x00000008 Memory Correctable, 0x00000010 Memory Uncorrectable non-fatal
echo 0x10 > error_type
echo 0x2  > flags                 # param1/param2 (address and mask) are valid
echo $PA  > param1                # physical address of a page owned by a test process
echo 0xfffffffffffff000 > param2
echo 1 > error_inject             # firmware arms the error; the test process then reads $PA

The consumer then runs the normal path: an SEA or SDEI notification, GHES, memory_failure(), and SIGBUS to the process owning the page. The notrigger file suppresses the firmware trigger action where the platform supports it, so that the test’s own access is what triggers the error.

Injecting on FVP

The AEM FVP implements PE error records with the fault-injection registers, and TF-A’s CI tests both models on it with TFTF as the Non-secure payload:

# TF-A, firmware-first build with SDEI and fault injection
make PLAT=fvp DEBUG=1 ENABLE_FEAT_RAS=1 HANDLE_EA_EL3_FIRST_NS=1 \
     EL3_EXCEPTION_HANDLING=1 SDEI_SUPPORT=1 FAULT_INJECTION_SUPPORT=1 \
     BL33=<path-to>/tftf.bin all fip
# find the RAS-related model parameters for your FVP version
FVP_Base_RevC-2xAEMvA --list-params | grep -i -E 'ras|error'

The TFTF RAS test groups (fvp-single-fault, fvp-uncontainable, fvp-ras-ffh-nested, fvp-ras-kfh, fvp-ras-kfh-reflect) are good templates. The FVP reports injected errors functionally. It does not model ECC, timing or poison travelling through a modelled interconnect, so the cross-die and memory-controller rows below need RTL emulation or silicon (18.4).

A test matrix

#CaseInjectionExpected exception and syndromeExpected record and OS resultTypical failure signature
1CE below thresholdpreset the record’s standard CE counter (in ERR<n>MISC0) to two below its overflow point (all ones minus 1), then inject one CEnonecounter +1 (now all ones), STATUS.CE set. With a standard counter and CFI = 1, the CE FHI is raised only on counter overflow, so none yetan FHI per CE (no standard counter, or a node that ignores it), or a counter that does not move (PFG does not drive the counter)
2CE threshold crossinginject a second CEnonethe counter wraps and sets its overflow flag (ERR<n>MISC0.OF, not STATUS.OF), FHI raised once. The OS logs a corrected-error storm, or EL3 logs a CPER Corrected recordan FHI storm (overflow not cleared, or the counter not reloaded by the handler), or no FHI at all (interrupt not routed or not enabled in the GIC)
3UE on loadinject UER (or poison through the memory controller) on a line, then load it from a user processsync data abort, FSC 0b010000, SET = 0b00, FnV = 0, FAR = the VArecord UE, UET = UER, ADDR = the PA. KFH: SIGBUS and the page offlined. FFH: an SEA notification and then the same resultan SError instead of an abort (an IMPLEMENTATION DEFINED choice, so check against the TRM), FnV = 1, or a kernel panic because the error was classified fatal
4Poison into the instruction streampoison a line of a user text page, then branch to itsync instruction abort, EC 0x20, FSC 0b010000, SET validthe process is killed. For a clean page the OS may instead drop and re-read it. For kernel text: panicthe abort repeats forever (handler returns without isolating the page), or the error is silently corrected by an I-cache refetch, which is legal for clean lines but must then be logged as a CE
5Error in the interrupt patharm an injection with a short countdown, then trigger a Group 0 or Non-secure interrupt so the error is pending while EL3 or the OS is in its IRQ handler with PSTATE.A = 1SError taken after the handler’s ESB or when A is unmasked, attributed by ISS.IESB/DISR_EL1 to the right context (3.4)KFH: EL3 reflects to the lower EL (TFTF fvp-ras-kfh-reflect). FFH: EHF priority puts RAS above the in-progress interrupt, and the nested EA is handled on the SMC or IRQ entry path (fvp-ras-ffh-nested)a reflect loop and panic, a lost interrupt (an EOI skipped on the error path), or the SError blamed on the next world
6UCinject UCSError, AET = 0b000system panic or reset. BERT shows the error after rebootthe system continues, or no BERT record

For each row also check that the record is cleared (STATUS reads 0 afterwards), that ERRGSR agrees, and that a second identical injection behaves the same. Handlers that work once and then lose every later error are common.

Validation note: run rows 3–5 on every die of a multi-chiplet system, with the consumer on a different die from the memory controller that owns the line (17.5). The poison must cross the die-to-die link, and the error record that the OS sees must still name the original node (PN = 0 at the memory controller, PN = 1 along the path). A synchronous abort at the consumer that turns into an SError when it crosses a die means the link drops the poison attribute and reports a bus error instead. That is a containment bug, and the interconnect’s own error records will show a link error at the same time.

Checkpoint

Q16.8.1 A platform runs firmware-first for memory errors. Linux registers SDEI handlers, but after the first injected memory CE, all later CEs produce no OS log, although EL3 shows its RAS handler running each time. What is the most likely cause?

  • A. SCR_EL3.TERR is 1, so Linux cannot read the error records
  • B. The FHI is configured as Non-secure Group 1
  • C. SCR_EL3.FIEN is 0, so later injections fail
  • D. The OS never wrote the GHESv2 Read Ack register, or firmware does not check it correctly, so firmware considers the status block still owned by the OS and drops new records
Answer

D. The EL3 handler runs, so injection (C) and interrupt routing (B) work. Under FFH the OS is meant not to read the records, so A is by design. The symptom “only the first error arrives” is the signature of the GHESv2 acknowledgement handshake failing.

Read more: ACPI specification, APEI, Generic Hardware Error Source version 2 (GHESv2); SDEI (DEN0054), SDEI_EVENT_COMPLETE

Q16.8.2 A test injects UER with ERXPFGCTL_EL1 into a PE record and then performs a load, expecting a precise data abort. Instead, an SError arrives with AET = UER. What should the validation engineer conclude?

  • A. The core violates the architecture, because UER must always be reported synchronously
  • B. Nothing yet. PFG injects a report, and whether and how the error is signalled in-band is IMPLEMENTATION DEFINED. Check the core’s TRM for PFG behaviour before filing a bug, and use real poison to test precise reporting
  • C. SCR_EL3.EA was 0, which turns synchronous aborts into SErrors
  • D. The record’s ERXCTLR_EL1.UE bit converts aborts into SErrors
Answer

B. Pseudo-fault generation guarantees that the record is set up and the configured signals are raised. It does not have to tie the error to the next load as a precise abort, so A over-claims. SCR_EL3.EA changes the target EL, not the synchronous/asynchronous nature (C). UE enables the in-band error response at all, but does not choose between abort and SError (D).

Read more: RAS System Architecture (DDI0587), Common Fault Injection Model; Arm ARM (DDI0487), ERXPFGCTL_EL1

Q16.8.3 A kernel-first system (SCR_EL3.EA == 0) occasionally panics in TF-A with a “reflection loop” message while running an error-in-the-interrupt-path test. What sequence most likely causes it?

  • A. An SError caused by Non-secure code is pending when an interrupt enters EL3. EL3 reflects it to the lower EL, where PSTATE.A is masked in the interrupted context, so it stays pending and is synchronized again at the next EL3 entry
  • B. SCR_EL3.EA == 0 means that EL3 takes every SError, and the EL3 handler re-enables PSTATE.A too early
  • C. The FHI was configured as Group 0, so it preempts the reflection
  • D. IESB is disabled at EL3, so the SError is never synchronized
Answer

A. Under KFH EL3 can only hand an error to the lower EL. If that EL cannot take it (masked, or of lower priority than what is in progress), it comes back at every EL3 entry. This is the case that TF-A detects and that FEAT_E3DSE is meant to fix. With EA == 0, SErrors are not taken at EL3 (B). C does not create a loop. D removes EL3’s synchronization on entry, so EL3 would not see the error and would not reflect it at all. That is a different failure, not a loop.

Read more: Arm ARM (DDI0487), SCR_EL3.EA; Asynchronous exception masking; TF-A documentation, RAS support (Kernel First Handling)