18.1 Decoding a crash end to end
A crash report is evidence, and it is only as good as your knowledge of when each register is valid. This section works through five realistic dumps, one bug class each. The field layouts come from 3.2 (EC, IL, ISS, the FAR_ELx validity rules), 5.8 (abort ISS fields) and Appendix D (the full EC and DFSC/IFSC card). Only the reasoning is shown here.
The decode procedure
Do these steps in the same order every time, because each one decides how to read the next:
- Which EL took it, and from where. Use the handler (which
VBAR_ELx, which of the four vector groups),SPSR_ELx.M[4:0](the EL and SP of the interrupted context, and AArch64 vs AArch32), and the EC’s own “lower EL” vs “same EL” split. - EC =
ESR[31:26]. This selects the ISS layout. Nothing else inESR_ELxmeans anything until you have it. IL(bit 25). It is 1 for every exception from A64 code and for classes with no associated instruction. It is 0 only for a 16-bit T32 instruction, so if it reads 0 in pure A64 firmware, you have misread the register.- ISS. Decode it per class, and check the “valid” bits (
ISV,FnV,CV,IDS) before you trust any subfield. FAR_ELx. Read it only if the EC is one that writes it andFnV == 0. Otherwise it is UNKNOWN, which includes “still holds a value from an older fault”.ELR_ELx. This is the preferred return address. For synchronous exceptions it is the faulting instruction (SVC/HVC/SMCare the exceptions: there it is the next instruction). For asynchronous exceptions it is only where the PE happened to be.
A small decoder is worth keeping in every firmware image, because it lets the panic path print fields rather than a hex word:
static void decode_esr(uint64_t esr, uint64_t far, uint64_t elr, uint64_t spsr)
{
unsigned ec = (esr >> 26) & 0x3f;
unsigned il = (esr >> 25) & 1;
unsigned iss = esr & 0x1ffffff;
printf("ESR=%016lx EC=0x%02x IL=%u ISS=0x%07x\n", esr, ec, il, iss);
printf("ELR=%016lx SPSR=%08lx (M=0x%lx)\n", elr, spsr, spsr & 0x1f);
switch (ec) {
case 0x20: case 0x21: case 0x24: case 0x25: {
unsigned fsc = iss & 0x3f;
printf(" xFSC=0x%02x WnR=%u S1PTW=%u CM=%u FnV=%u EA=%u\n", fsc,
(iss >> 6) & 1, (iss >> 7) & 1, (iss >> 8) & 1,
(iss >> 10) & 1, (iss >> 9) & 1);
if (!((iss >> 10) & 1))
printf(" FAR=%016lx\n", far);
break;
}
case 0x18:
printf(" %s S%u_%u_C%u_C%u_%u, x%u\n", (iss & 1) ? "MRS" : "MSR",
(iss >> 20) & 3, (iss >> 14) & 7, (iss >> 10) & 0xf,
(iss >> 1) & 0xf, (iss >> 17) & 7, (iss >> 5) & 0x1f);
break;
case 0x2f:
printf(" IDS=%u AET=%u EA=%u DFSC=0x%02x\n", (iss >> 24) & 1,
(iss >> 10) & 7, (iss >> 9) & 1, iss & 0x3f);
break;
}
}
Note that the FnV test applies to the data and instruction abort classes. For the other classes that write FAR_ELx (PC alignment, watchpoint) the rules in 3.2 apply.
Dump 1: translation fault just after MMU-on
The setting is BL31 on a new SoC, with the MMU enabled at EL3 a few hundred instructions earlier. The first printf after MMU-on never appears. The core is halted with the debugger, which finds it parked in the EL3 panic loop, and reads:
ESR_EL3 = 0x0000000096000046 ELR_EL3 = 0x000000000400a2c4
FAR_EL3 = 0x000000001c090000 SPSR_EL3 = 0x000003cd
SPSR.M = 0b01101(from0x3cd): EL3h, AArch64. The fault happened at EL3.- EC
0x25: Data Abort, same EL.IL = 1. - ISS
0x46:DFSC = 0b000110, a Translation fault at level 2.WnR = 1(a store).S1PTWandCMare 0, so it was not the walk itself and not a cache maintenance instruction.FnV = 0, soFAR_EL3is valid.ISV = 0, as the architecture requires for this fault at EL3 (ISV is 1 only for certain stage 2 aborts reported to EL2 and for FEAT_LS64 accesses), so do not look for the register number in the syndrome. FAR = 0x1c090000is the UART base.ELRis thestr w1, [x0]in the UART driver.
Conclusion: the walk reached a level 2 table and found an invalid entry for the 2 MB block that covers the UART. The MMIO region was missing from the memory map (in TF-A, from plat_arm_mmap[] or the platform’s MAP_REGION_FLAT list). Because the level is 2, the walk started correctly. A wrong T0SZ or TTBR0_EL3 would fault at the start level or produce garbage instead (9.3).
Bring-up note: confirm by hand with
AT S1E3Won the FAR, then readPAR_EL1.PAR_EL1.F == 1with the same FST and level reproduces the fault without taking it (5.9). IfATsucceeds but the store faults, suspect a stale TLB entry from an earlier table, which means a missingTLBI ALLE3before enabling.
Dump 2: EC 0x18, a trapped system register access
Linux boots on a new board and dies before the console comes up. The panic arrives at TF-A’s EL3 unhandled-exception path:
ESR_EL3 = 0x0000000062360820 ELR_EL3 = 0xffff8000800a1b38
SPSR_EL3 = 0x000003c9 FAR_EL3 = (not valid for this EC)
SPSR.M = 0b01001: EL2h. The exception came from the kernel running at Non-secure EL2 with VHE. WithHCR_EL2.E2H == 1, theTCR2_EL1encoding executed at EL2 accessesTCR2_EL2, but the syndrome reports the encoding as issued.- EC
0x18: trappedMSR/MRS/system instruction, AArch64. Note that it was taken to EL3, not EL2. That alone tells you the trap bit lives in an EL3 register. - ISS
0x360820:Op0 = 3,Op2 = 3,Op1 = 0,CRn = 2,Rt = 1,CRm = 0,Direction = 0. That isMSR S3_0_C2_C0_3, x1, which isTCR2_EL1(FEAT_TCR2).
Conclusion: the kernel saw ID_AA64MMFR3_EL1.TCRX != 0, enabled the feature, and wrote TCR2_EL1, but EL3 had left SCR_EL3.TCR2En == 0. This is the “feature arrives trapped until a higher EL enables it” pattern in its most common form (17.3). The fix is in EL3 (in TF-A, ENABLE_FEAT_TCR2), not in the kernel. The same signature with a different encoding points to other enables: an AMU register means CPTR_EL3.TAM, and HCRX_EL2 means SCR_EL3.HXEn.
The decode trap: had the kernel run at EL1 under a hypervisor, an EL2 control (HCRX_EL2.TCR2En, which also behaves as 0 while SCR_EL3.HXEn == 0, or a fine-grained trap) would take the same EC to EL2 first. The target EL is part of the diagnosis.
Dump 3: an SError with no obvious culprit
BL2 has just enabled the caches and is copying BL31 to DRAM when this appears:
ESR_EL3 = 0x00000000be000011 ELR_EL3 = 0x0000000004003a10
SPSR_EL3 = 0x000002cd FAR_EL3 = (UNKNOWN)
- EC
0x2F: SError. ISS:IDS = 0(architected syndrome),DFSC = 0b010001(asynchronous SError),AET = 0b000(Uncontainable),EA = 0. SPSR = 0x2cd: EL3h with onlyPSTATE.Aclear (D,I,Fset). The SError was taken as soon as it was unmasked.ELRpoints at anldpinmemcpy. Ignore it: unless FEAT_RASv2 setsISS.ELS, or anESBsynchronized the error,ELRsays nothing about which access caused it (3.4).
What the dump does say: an error was signalled asynchronously, and the PE classed it as Uncontainable, so the PE could not limit its effects. What it does not say: which agent, which address, or whether it was a read or a write. The next evidence is outside the PE: the RAS error records (ERRSELR_EL1 and ERXSTATUS_EL1 for the core’s own nodes, the memory-mapped ERRnSTATUS and ERRnADDR of the DMC and interconnect nodes) and the interconnect’s own error logs. In this case the DMC node had ERRnSTATUS.{V,UE,AV} == 1 with ERRnADDR in the destination range: a cache linefill (or a partial-line write that forced a read-modify-write at the DMC) read ECC DRAM that had never been initialised. The fix was to scrub, that is write, all of DRAM before the first cacheable use. The procedure is in 18.3.
Dump 4: BTI and PAC failures
Two dumps from the same branch-protected (-mbranch-protection=standard) EL1 test payload.
4a: Branch Target exception.
ESR_EL1 = 0x0000000036000002 ELR_EL1 = 0xffff00000012a400 SPSR_EL1 = 0x00000805 (BTYPE=0b10)
EC 0x0D is a Branch Target exception. ISS.BTYPE = 0b10, which a BLR produces. ELR is the target of the indirect call, and the instruction there is not a BTI c/BTI jc/PACIASP landing pad. Typical causes are a hand-written assembly function without BTI c at its entry, or a function pointer into a data table. SPSR.BTYPE holds the same value. Note that FAR_ELx is not written: the faulting PC is ELR_ELx, and the branch that got you there is not recorded anywhere architectural. Use BRBE or ETE trace if you need it (16.6).
4b: Pointer authentication failure. What you see depends on FEAT_FPAC.
-
With FEAT_FPAC (an optional feature; see DDI0487 A2 for the versions that permit it), a failed
AUTIASPfaults immediately:ESR_EL1 = 0x0000000072000000 ELR_EL1 = <address of the AUTIASP or RETAA>EC
0x1C:ISS[1](DnI) = 0 means an instruction key, andISS[0](BnA) = 0 means the A key. So the return address signed withAPIAKeydid not authenticate. Either the stack was corrupted, or the keys changed between sign and auth (a CPU-suspend path that does not restoreAPIAKeyLo/Hi_EL1is the bring-up favourite). -
Without FEAT_FPAC,
AUT*does not fault. It produces a corrupted, non-canonical pointer, and the fault comes on theRET:ESR_EL1 = 0x0000000086000004 ELR_EL1 = 0x002000004012b8f0 FAR_EL1 = 0x002000004012b8f0EC
0x21,IFSC = 0b000100: a Translation fault at level 0 on an instruction fetch, the fault an out-of-range VA reports.ELR == FARwith corrupted upper bits is the PAC signature. The exact bit pattern differs between the original PAuth error-code scheme and FEAT_PAuth2, so do not try to decode it; the payload here runs from TTBR0 addresses around0x4012_0000. Recover the caller fromx30in the saved frame record (x29chain), not fromELR.
Dump 5: alignment fault in early C
The first C function in a new BL1 port, with the MMU still off at EL3:
ESR_EL3 = 0x0000000096000061 ELR_EL3 = 0x0000000000002f48 FAR_EL3 = 0x000000000400c010
- EC
0x25,DFSC = 0b100001: Alignment fault.WnR = 1,CM = 0. ELRpoints atdc zva, x0inside the C library’smemset, called to zero.bss.
Why: with SCTLR_EL3.M == 0, data accesses are treated as Device-nGnRnE (6.2). Two A64 rules then bite, independently of SCTLR_EL3.A. Any unaligned access to Device memory takes an Alignment fault, and DC ZVA to Device memory always takes an Alignment fault. Compiled C freely emits both: memset/memcpy use DC ZVA and unaligned LDP/STP, and -O2 merges adjacent byte stores into unaligned wider ones. The fixes are to build early code with -mstrict-align and a memset that avoids DC ZVA, or to turn on the MMU and D-cache with .bss mapped Normal before running general C (TF-A clears .bss with its own assembly zeromem, which handles the MMU-off case).
Validation note: each of these five signatures makes a cheap directed test. Map a hole and store to it; write an EL3-gated register from EL1; inject a UE with the pseudo-fault generator (16.8); call a function without a landing pad;
DC ZVAwith the MMU off. Check that the reported EC, xFSC,FARvalidity and target EL match the values above exactly. A mismatch in a field the architecture leaves UNKNOWN or IMPLEMENTATION DEFINED, such as aFARvalue written for an EC that leaves it UNKNOWN, or theELRof an SError, is not a bug, because those fields are permitted to vary. But the EC, xFSC and target EL are architecturally fixed, and any difference there is an RTL or model bug. The framework is in 18.5.
Checkpoint
Q18.1.1 A crash log shows EC 0x18 in ESR_EL3 with ISS decoding to MRS x0, S3_3_C13_C4_0 (AMEVCNTR00_EL0, an AMU counter register), taken from Non-secure EL1. Where do you look first?
- A.
HCR_EL2.TID3, because ID and feature registers are trapped by EL2 - B. The kernel’s AMU driver, because EC
0x18means the instruction was UNDEFINED - C. The EL3 configuration of AMU access (
CPTR_EL3.TAM), because the exception was taken to EL3 - D.
ELR_EL3, because it holds the encoding of the register that was accessed
Answer
C. The target EL is part of the syndrome. A trap taken to EL3 is caused by an EL3 control. CPTR_EL3.TAM traps AMU register accesses from all lower ELs, so the fix is in firmware. A is tempting but describes a trap taken to EL2, and AMU counters are not ID registers. An UNDEFINED instruction would be EC 0x00, not 0x18.
Read more: Arm ARM (DDI0487), ESR_EL3, ISS encoding for an exception from MSR, MRS, or System instruction execution; CPTR_EL3
Q18.1.2 An SError arrives with ESR_EL3 = 0xBE000011. ELR_EL3 points into memcpy. What can you conclude from the PE’s state alone?
- A. An Uncontainable error was signalled asynchronously. The instruction at
ELR_EL3need not have caused it, and the source must be found from the RAS error records and interconnect logs - B. The
ldpatELR_EL3read poisoned memory, so the address is inFAR_EL3 - C. The error is corrected (CE), so it is safe to
ERETand continue - D.
IDS == 1, so the rest of the syndrome is IMPLEMENTATION DEFINED and nothing can be concluded
Answer
A. DFSC = 0b010001 (asynchronous SError) with AET = 0b000 (UC) and IDS = 0. With no ESB synchronization and no FEAT_RASv2 ELS indication, ELR is just where the PE was. B describes a synchronous External abort, which would have EC 0x25. FAR_EL3 is UNKNOWN for this SError. D misreads bit 24, which is 0 in 0xBE000011.
Read more: Arm ARM (DDI0487), ESR_EL3, ISS encoding for an SError exception; RAS (DDI0587), error records
Q18.1.3 On a core without FEAT_FPAC, a function returns and the PE takes an Instruction Abort with IFSC = 0b000100 and ELR == FAR, where the FAR has unexpected bits set above the VA range. What is the most likely cause?
- A. The vector table is not mapped
- B. The function is missing a
BTI clanding pad - C.
TCR_EL1.T0SZis too small for the return address - D.
AUTIASPfailed and produced a non-canonical return address, which faulted on theRET
Answer
D. Without FEAT_FPAC, an authentication failure does not fault. It corrupts the pointer’s upper bits so that its use faults: here, a level 0 translation fault on the fetch, at the bad address. B would be EC 0x0D at the landing site. C would affect every address, not only this return. A gives recursive exceptions at VBAR, not one clean abort.
Read more: Arm ARM (DDI0487), Pointer authentication in AArch64 state; FEAT_FPAC