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

2.1 Exception numbers, the vector table and priority grouping

Every exception has an exception number. The number indexes the vector table, and IPSR holds it while the PE is in Handler mode.

 #    Exception     Priority
 1    Reset         -4 (fixed)
 2    NMI           -2 (fixed)
 3    HardFault     -1 (fixed; Secure HardFault is -3
                        when AIRCR.BFHFNMINS == 1)
 4    MemManage     configurable   Main Ext. only
 5    BusFault      configurable   Main Ext. only
 6    UsageFault    configurable   Main Ext. only
 7    SecureFault   configurable   Main + Security Ext.
 11   SVCall        configurable
 12   DebugMonitor  configurable   Main Ext. only
 14   PendSV        configurable
 15   SysTick       configurable
 16+n external interrupt n (IRQn)

The vector table is a table of words at the address in VTOR, which is banked per Security state (VTOR_S, VTOR_NS). Word 0 holds the initial SP_main value: the PE loads it from the Secure table at reset (or from the only table without the Security Extension); for the Non-secure table, Secure software normally sets MSP_NS itself. Word n holds the handler address for exception n. Hardware fetches the vector itself, so there is no shared vector entry that software has to demultiplex. Bit[0] of each vector is copied to EPSR.T, so it must be 1 (Thumb).

Priority: a lower number means a higher priority. A configurable priority is an 8-bit field, but only an IMPLEMENTATION DEFINED number of its most significant bits is implemented (at least 3 with the Main Extension, 2 on Baseline). The unimplemented low bits are RAZ/WI.

Grouping (Main Extension only): AIRCR.PRIGROUP splits each priority value into a group priority, bits [7:PRIGROUP+1], and a subpriority, bits [PRIGROUP:0]. Writes to AIRCR must include VECTKEY = 0x05FA in bits [31:16].

  • Only the group priority decides preemption. A pending exception preempts only if its group priority is strictly higher than the current execution priority.
  • The subpriority, then the exception number (lower wins), only decide which of several pending exceptions with the same group priority is taken first.
  • On Baseline PRIGROUP is RES0, and with only bits [7:6] implemented the whole implemented field acts as the group priority.

Coming from A-profile: In A-profile the GIC’s priority mask (ICC_PMR) and binary point (ICC_BPRn) decide masking and preemption, and every IRQ arrives at the same IRQ entry of the VBAR_ELx table (one per source EL/stack), so software must read ICC_IAR to find out which interrupt it is. Here PRIGROUP plays the binary-point role, and the hardware fetches a separate handler address for each exception number.

Checkpoint

Q2.1.1 Assume at least 4 priority bits are implemented and AIRCR.PRIGROUP = 5, so the group priority is bits [7:6]. IRQ A (priority 0x50) is active. IRQ B (priority 0x40) becomes pending. What happens?

  • A. B preempts A immediately, because 0x40 is numerically lower than 0x50
  • B. B preempts A only if B has the lower exception number
  • C. B does not preempt A, because both have group priority 1. B is taken when A returns (typically by tail-chaining), ahead of other pending exceptions at that group priority with a higher subpriority value
  • D. B is discarded, because exceptions in the same priority group cannot both be pending
Answer

C. 0x40 = 0b01_000000 and 0x50 = 0b01_010000. With PRIGROUP = 5 both have group priority 0b01, and preemption needs a strictly higher group priority. Subpriority only orders pending exceptions. The tempting answer, ‘lower number preempts’, compares the full 8-bit value and ignores grouping.

Read more: Armv8-M ARM (DDI0553), Exception model: priority grouping, AIRCR.PRIGROUP

Q2.1.2 You are porting startup code from a Cortex-M33 (Mainline) to a Cortex-M23 (Armv8-M Baseline). Which of these exception handlers can still be taken on Baseline?

  • A. MemManage
  • B. SVCall
  • C. UsageFault
  • D. DebugMonitor
Answer

B. SVCall exists in both profiles. MemManage, BusFault, UsageFault and DebugMonitor need the Main Extension. On Baseline, the fault conditions that would raise MemManage, BusFault or UsageFault are reported as HardFault, and Baseline has only halting debug, so there are no DebugMonitor exceptions. A UsageFault handler installed on Baseline does nothing, because that vector is never used.

Read more: Armv8-M ARM (DDI0553), Exception numbers; Main Extension

Q2.1.3 A vector table entry for an IRQ holds an even address (bit[0] = 0). What does the architecture say happens when that IRQ is taken?

  • A. The handler executes in A32 state
  • B. The PE enters lockup immediately while fetching the vector
  • C. The PE silently sets bit[0] and executes the handler normally
  • D. EPSR.T is cleared, and executing the handler’s first instruction raises an INVSTATE UsageFault (or HardFault if it escalates)
Answer

D. Bit[0] of the vector is copied into EPSR.T. M-profile has no A32 state, so executing with T = 0 raises an INVSTATE UsageFault. If that UsageFault is disabled or cannot be taken, or on Baseline, it is reported as HardFault. It is a classic bring-up symptom of a toolchain that does not mark handler symbols as Thumb. The A32 answer is what an A-profile engineer might assume, but M-profile can only execute T32.

Read more: Armv8-M ARM (DDI0553), Exception entry: vector table; UFSR.INVSTATE