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

17.1 Reset

Reset is the one point where the architecture tells you almost nothing about the machine’s state, and makes you responsible for all of it. This section covers where a PE starts executing, what the two kinds of PE reset do and don’t reset, which state is defined, IMPLEMENTATION DEFINED or UNKNOWN, why UNKNOWN state is the main source of “passes on FVP, fails in RTL” bugs, and the instruction sequence TF-A runs before it has a stack. EL3 register initialisation itself is in 17.2, and what each boot stage hands to the next is in 12.2.

Where execution starts: RVBAR_ELx

On reset, the PE enters the highest implemented Exception level. When that is AArch64 EL3, the PE starts in EL3h, with:

  • PC = RVBAR_EL3 (Reset Vector Base Address Register). RVBAR_EL3 is read-only and its value is IMPLEMENTATION DEFINED. On Arm Cortex-A and Neoverse cores it is sampled from a per-core input bus (RVBARADDR) when the core leaves reset, so the SoC decides it, usually through a strap or a system-control register.
  • PSTATE.{D,A,I,F} all set, PSTATE.SP = 1 (SP_EL3 selected), PSTATE.EL = 3.
  • No exception syndrome: ESR_EL3, ELR_EL3, SPSR_EL3 and FAR_EL3 are UNKNOWN. A debugger showing “an exception” right after reset is reading garbage.

If EL3 is not implemented, the same applies with RVBAR_EL2 or RVBAR_EL1 at the highest implemented EL. Only the RVBAR of the highest EL exists. On cores that implement AArch32 at EL3 (Armv8-A only, see 2.1), the execution state at reset is chosen by an IMPLEMENTATION DEFINED input (AA64nAA32 on Arm cores) for a cold reset and by RMR_EL3.AA64 for a software-requested warm reset.

Because RVBAR_EL3 is fixed by hardware, there are two common platform designs:

DesignReset vectorConsequence for firmware
Fixed ROM vectorAlways BL1 in ROMBL1 must distinguish cold boot from warm boot (a core resuming from power-down) and send warm boots to BL31. TF-A does this with a mailbox (PROGRAMMABLE_RESET_ADDRESS=0).
Programmable vectorSoC register, rewritten by BL31 after cold bootWarm boots go straight to bl31_warm_entrypoint, and BL1 never runs again (PROGRAMMABLE_RESET_ADDRESS=1).

Cold reset and Warm reset

The Arm ARM defines two PE resets:

  • Cold reset is what happens when the Core power domain is powered up. It resets all of the PE’s logic in that domain, including the self-hosted debug and trace state.
  • Warm reset resets the PE’s execution logic but not the debug state. A Cold reset includes everything a Warm reset does, so a register field documented as “On a Warm reset, resets to X” also takes X on a Cold reset.

The register XML makes the difference visible. Most fields of SCR_EL3, MDCR_EL3 and CPTR_EL3 are described “On a Warm reset”, while the breakpoint and watchpoint registers (DBGBCRn_EL1, DBGWCRn_EL1) and the OS lock state are described “On a Cold reset”. For example, OSLSR_EL1.OSLK resets to 1 on a Cold reset, so the OS lock is set after power-up and survives a Warm reset (16.1). A debugger’s breakpoints therefore survive a Warm reset, which is the point: you can debug the reset path.

A Warm reset can be requested by software through RMR_EL3.RR, if the implementation provides it (whether RMR_EL3 is implemented, and whether RR does anything, is IMPLEMENTATION DEFINED). The documented pattern is DSB, ISB, write RR=1, then loop on WFI. The reset is only a request to the system, and the reset controller may not honour it.

Two clarifications prevent confusion in bring-up conversations:

  1. Neither reset is a system reset. The GIC Distributor and Redistributors, the system counter (CNTCR, 4.6), the interconnect, system caches and DRAM controllers have their own reset domains. After a PE reset, the GIC may still hold pending interrupts and the system cache may still hold dirty lines.
  2. “Warm boot” in TF-A is a software term. When a core powers up again after CPU_OFF or a power-down CPU_SUSPEND, its Core power domain was off, so architecturally it takes a Cold reset. TF-A calls this a warm boot because the system is already initialised and the core resumes into the PSCI warm-boot path (17.4). When you write a test plan, separate the architectural reset type from the firmware path.

Reset values: defined, IMPLEMENTATION DEFINED, UNKNOWN

Each register field’s reset behaviour falls into one of three categories, and the category decides what firmware must do:

CategoryExamplesFirmware obligation
Architecturally definedSCTLR_EL3.M, .C, .I reset to 0 (MMU, D-cache and I-cache off at EL3); OSLSR_EL1.OSLK = 1 on Cold resetMay rely on it, but only at the reset EL and only for that field
IMPLEMENTATION DEFINEDRVBAR_EL3; SCTLR_EL3.EE (from a configuration input such as CFGEND); MIDR_EL1, MPIDR_EL1; the reset values of CPU-specific registers such as CPUACTLR_EL1Read the core TRM; treat as platform data
Architecturally UNKNOWNMost of SCR_EL3, CPTR_EL3 and MDCR_EL3; VBAR_ELx; all of SCTLR_EL2/SCTLR_EL1 and most other lower-EL registers; CNTFRQ_EL0; CNTVOFF_EL2; X0–X30, SP_ELxWrite before any use, as a whole register

“UNKNOWN” has a precise meaning in the Arm ARM. The value is unspecified, may differ from one reset to the next and from one PE to another, and must not be relied on. The only guarantee is that it does not expose information that the current Exception level and Security state could not otherwise access. It is not “zero in practice”. It is often zero on FVP and on emulators, which is exactly why it is dangerous.

TF-A states the consequence in its EL3 entry macros: SCR_EL3 and CPTR_EL3 are initialised “setting all fields rather than relying on hw. All fields are architecturally UNKNOWN on reset”, and MDCR_EL3 likewise because “some fields are architecturally UNKNOWN on reset”. The rule that follows is: never read-modify-write a register whose reset value is UNKNOWN until you have written all of it once. mrs x0, scr_el3; orr x0, x0, #SCR_NS_BIT; msr scr_el3, x0 carries every UNKNOWN bit forward, including, for example, an SCR_EL3.EA or TWI that you never meant to set.

UNKNOWN state in simulation: X-propagation

In four-state RTL simulation, a flop with no reset starts as X, so UNKNOWN architectural state really is unknown there. How an X is handled depends on the simulator mode and tells you different things:

  • X-optimism (the default Verilog semantics for if/case): an X condition takes one branch, usually the else. A firmware read-modify-write of an UNKNOWN register then appears to work, and the bug is masked.
  • X-propagation or pessimism modes (enabled per tool, for example VCS -xprop or Xcelium’s X-propagation options): the X flows into everything it touches. A branch on a value derived from an UNKNOWN register drives X onto the PC, and the simulation fails visibly at the first instruction that depends on it. This is what you want during firmware-in-RTL bring-up.

Typical findings when X-propagation is switched on:

  • A read-modify-write of SCR_EL3, CPTR_EL3, MDCR_EL3, ACTLR_EL3 or an IMPLEMENTATION DEFINED CPU*CTLR register before it was fully written.
  • Use of X0–X3 from the boot ROM as “arguments” on a path where nothing set them (cold boot).
  • Uninitialised SRAM. Reading stack or .bss before it is written returns X. On silicon the same bug reads an ECC-uncorrectable word, which returns an external abort or poisoned data and surfaces as an SError at “the first memory access” (18.3). ECC-protected SRAM and DRAM must be initialised (scrubbed) by writes before the first read.
  • A DC or TLBI loop bound computed from a register that has not been read yet (for example a CCSIDR_EL1 read before CSSELR_EL1 was written; CSSELR_EL1 is UNKNOWN at reset).

Two-state platforms (emulators, FPGAs, FVP) turn X into 0 or a pseudo-random value and hide this whole class of bug (18.4).

Validation note: Run the reset path at least once in four-state RTL with X-propagation enabled, and treat any X reaching the PC, a branch condition or a memory address as a firmware or RTL bug until proven otherwise. On FVP, a cheap partial substitute is to run the first stages with different values in UNKNOWN registers: halt at the reset vector and use the debugger to write non-zero patterns into the registers whose reset value is UNKNOWN (SCR_EL3, CPTR_EL3, MDCR_EL3, X0–X30), then let the firmware run. A firmware build that behaves differently with different UNKNOWN values has a read-before-write bug.

The first ~100 instructions: TF-A’s EL3 entry

TF-A’s BL1 (bl1_entrypoint) and, for warm boots or RESET_TO_BL31, BL31 (bl31_entrypoint and bl31_warm_entrypoint) all start with the el3_entrypoint_common macro. Its parameters switch steps on or off for each image. The order is constrained at every step by what is still unavailable: no stack, no initialised memory, no vectors and no caches.

// Shape of el3_entrypoint_common (TF-A include/arch/aarch64/el3_common_macros.S), simplified
reset:
    // 1. SCTLR_EL3 first: EE before any data access, everything else to a known value
    mov_imm x0, (SCTLR_RESET_VAL & ~(SCTLR_EE_BIT | SCTLR_WXN_BIT | \
                 SCTLR_SA_BIT | SCTLR_A_BIT | SCTLR_DSSBS_BIT))
    msr     sctlr_el3, x0
    isb
    // 2. Cold or warm? (only when the reset vector is fixed)
    bl      plat_get_my_entrypoint      // stackless: x0-x17 and x30 only
    cbz     x0, do_cold_boot
    br      x0                          // warm boot: jump to BL31 warm entry
do_cold_boot:
    // 3. Vectors before anything that can fault
    adr     x0, bl1_exceptions
    msr     vbar_el3, x0
    isb
    // 4. CPU and platform reset handlers: errata workarounds, SMPEN (pre-DynamIQ)
    bl      reset_handler
    // 5. el3_arch_init_common: SCTLR_EL3.{I,A,SA}, SCR_EL3, MDCR_EL3, CPTR_EL3 from constants
    // 6. EL3 execution context: DAIF.A cleared, SCR_EL3.{EA,SIF}, MDCR_EL3.SDD, CPTR_EL3 bits
    // 7. Primary or secondary?
    bl      plat_is_my_cpu_primary
    cbnz    w0, do_primary_cold_boot
    bl      plat_secondary_cold_boot_setup   // hold pen or power off; never returns
do_primary_cold_boot:
    // 8. platform_mem_init, then the C runtime:
    //    invalidate the RW data range, zero .bss, copy .data from ROM (BL1),
    //    msr spsel, #0 (TF-A runs C code on SP_EL0 at EL3), plat_set_my_stack,
    //    stack-protector canary
    bl      bl1_main                    // C from here; the MMU is enabled in bl1_plat_arch_setup

Why each step sits where it does:

  1. SCTLR_EL3 first. EE has an IMPLEMENTATION DEFINED reset value, and it determines the endianness of every data access, including the mailbox read in step 2. TF-A clears A and SA here and sets them in step 5, sets IESB when FEAT_RAS is enabled (as an errata workaround on several cores), and leaves M and C at 0. Step 5 turns on I.
  2. Mailbox before anything else. On a fixed-vector platform every power-up of every core enters here. A warm-booting core must leave before it touches cold-boot state, such as the .data and .bss that the primary core is using. plat_get_my_entrypoint therefore runs without a stack and reads a location that is valid with the caches off. On FVP this is a trusted mailbox in memory that the cold boot path clears.
  3. Vectors before the reset handler. CPU errata code writes IMPLEMENTATION DEFINED registers. If one of those writes UNDEFs on the wrong core revision, you want a vector that reports it, not a jump through an UNKNOWN VBAR_EL3 (3.1).
  4. Reset handler. reset_handler calls plat_reset_handler and then the CPU-specific reset_func selected by MIDR_EL1. That function applies the errata workarounds that must be in place before caches or coherency are enabled (1.3) and, on Cortex-A53/A57/A72-class cores, sets CPUECTLR_EL1.SMPEN (8.8). It runs on every reset, cold or warm, because none of this state survives power-down.
  5. Architectural EL3 initialisation writes whole registers from constants (17.2).
  6. EL3 execution context. Only now, with vectors installed, does TF-A unmask SError at EL3 (msr daifclr, #DAIF_ABT_BIT) and route External aborts to EL3. An SError taken earlier would have gone through an UNKNOWN vector.
  7. Secondary cores leave before memory initialisation, because only the primary core may initialise shared memory.
  8. C runtime. The RW data range is invalidated by VA before use. TF-A’s comment gives the reason: an earlier boot stage may have left dirty lines for this memory in a system cache, and a later eviction would write them back over the freshly zeroed .bss. The PE’s own caches are invalidated by hardware at reset on Arm cores, but a system cache is outside the PE reset domain (9.3). With the MMU off, data accesses are Device-nGnRnE, so the zeromem and memcpy16 routines used here are written to avoid unaligned accesses and DC ZVA.

The MMU and D-cache are enabled only from C, in bl1_plat_arch_setup or bl31_plat_arch_setup. Everything before that runs uncached from ROM or SRAM, which is why the reset path is slow on silicon and painfully slow in RTL simulation.

Bring-up note: to see these instructions retire, put a hardware breakpoint at RVBAR_EL3 with the core held in reset (the Reset Catch debug event, EDECR.RCE, or a CTI halt request, 16.2). On QEMU, -d int,cpu_reset,in_asm -S -s and a gdb breakpoint at the reset address do the same. If the core never reaches the first instruction, the problem is not firmware: check the reset controller, the clock and RVBARADDR, and whether the ROM is mapped where the vector points.

Checkpoint

Q17.1.1 On a platform with a fixed ROM reset vector, a core powers up again after CPU_OFF. Which statement is accurate?

  • A. The core takes an architectural Warm reset, so its breakpoint registers and OS lock state are preserved, and BL1 can skip the mailbox check
  • B. The core resumes at the instruction after its WFI, because PSCI CPU_OFF preserves PE state
  • C. The core’s power domain was off, so architecturally this is a Cold reset at RVBAR_EL3. BL1 must read the warm-boot mailbox and branch to BL31’s warm entry point before touching any cold-boot state
  • D. The core enters at the ELR_EL3 value saved before power-down
Answer

C. Powering up the Core power domain is a Cold reset, even though TF-A calls the resulting software path a “warm boot”. With a fixed vector, every power-up enters BL1, so the _warm_boot_mailbox step must divert the core before it touches .data/.bss. Option A confuses TF-A’s “warm boot” with the architectural Warm reset. A core that is powered off keeps no state, so it cannot resume after its WFI (B) or at a saved ELR_EL3 (D). Resuming in place only happens from a retention state.

Read more: Arm ARM (DDI0487), Reset (Cold and Warm reset), RVBAR_EL3; TF-A firmware design, “Platform initialization: warm boot”

Q17.1.2 Early EL3 code does mrs x0, mdcr_el3; orr x0, x0, #MDCR_SDD_BIT; msr mdcr_el3, x0 as its first access to MDCR_EL3. It works on FVP and the emulator. In four-state RTL simulation with X-propagation, a later branch drives X onto the PC. What is the root cause?

  • A. Many MDCR_EL3 fields reset to an architecturally UNKNOWN value, and the read-modify-write carries them forward, so later behaviour that depends on them (a trap decision, a debug enable) is undefined. The register must first be written in full from a constant
  • B. The RTL is wrong: system registers must reset to 0
  • C. An ISB is missing after the MSR, so the write is not visible to the branch
  • D. MDCR_EL3 cannot be accessed before VBAR_EL3 is set
Answer

A. The architecture allows UNKNOWN reset values, and non-reset flops implement them, so the RTL is not at fault (B). Two-state platforms turn the UNKNOWN bits into 0 and hide the bug. A missing ISB (C) would change when the new value takes effect, not make it undefined. TF-A writes MDCR_EL3 from MDCR_EL3_RESET_VAL before any read-modify-write for exactly this reason.

Read more: Arm ARM (DDI0487), MDCR_EL3 field reset behaviour; Glossary, UNKNOWN

Q17.1.3 Why does TF-A install VBAR_EL3 before calling the CPU reset handler, and unmask SError at EL3 only after el3_arch_init_common?

  • A. VBAR_EL3 must be written before any ISB can execute
  • B. The reset handler uses the stack, and the stack pointer is derived from VBAR_EL3
  • C. SError must stay masked until the MMU is on, because external aborts are reported only for Normal memory
  • D. The reset handler writes IMPLEMENTATION DEFINED registers that may fault on an unexpected core revision, so a valid vector is needed first. Unmasking SError is safe only once vectors exist and SCR_EL3 routing has been written from a constant instead of an UNKNOWN value
Answer

D. Synchronous exceptions cannot be masked, so the vector must exist before the first instruction that might UNDEF or abort. SError is maskable, and TF-A keeps PSTATE.A set until both the vector and SCR_EL3.EA are defined. C is wrong: with the MMU off every data access is Device-nGnRnE and can still return an external abort. The reset handler is stackless (B), and nothing about ISB depends on VBAR_EL3 (A).

Read more: Arm ARM (DDI0487), Asynchronous exception masking, VBAR_EL3; TF-A el3_entrypoint_common