4.2 Interrupt types and lifecycle
INTID space
| Type | INTID range | Scope | Config lives in | Trigger | Active state |
|---|---|---|---|---|---|
| SGI | 0–15 | Per PE, generated by software (ICC_SGI*R_EL1) | Redistributor SGI_base | Edge (fixed) | Yes |
| PPI | 16–31; extended PPI 1056–1119 (GICv3.1) | Per PE (timers, PMU overflow, GIC maintenance, TRBE, …) | Redistributor SGI_base | Level or edge (GICR_ICFGR1) | Yes |
| SPI | 32–1019; extended SPI 4096–5119 (GICv3.1) | Shared, routed by GICD_IROUTER<n> | Distributor | Level or edge (GICD_ICFGR<n>) | Yes |
| Special | 1020–1023 | Returned by acknowledge reads, never configured | — | — | — |
| LPI | 8192 and up (limited by GICD_TYPER.IDbits, GICR_PROPBASER.IDbits) | Per target Redistributor, Non-secure Group 1 only | Memory tables (4.4) | Edge (message) | No |
The special INTIDs tell software what an acknowledge or HPPIR read found:
| INTID | Meaning |
|---|---|
| 1020 | (EL3, Group 0 read) highest pending is Secure Group 1 |
| 1021 | (EL3, Group 0 read) highest pending is Non-secure Group 1 |
| 1022 | Highest pending interrupt is an NMI, ICC_IAR1_EL1 was used and SCTLR_ELx.NMI == 1. With FEAT_NMI, NMIs must be acknowledged with ICC_NMIAR1_EL1 (4.3) |
| 1023 | Spurious: nothing pending that this read is allowed to acknowledge, or it cannot preempt |
1020 and 1021 are what let an EL3 FIQ handler find out that a Group 1 interrupt caused the FIQ, and hand it to S-EL1 or the Normal world without acknowledging it. TF-A’s plat_ic_get_pending_interrupt_type() is built on this. Sizes are discovered at run time: GICD_TYPER.ITLinesNumber (N) gives the maximum SPI INTID as 32×(N+1) − 1, so up to 32×N SPIs, GICD_TYPER.ESPI_range gives the extended SPIs, and GICR_TYPER.PPInum gives the extended PPIs.
The state machine
Every SGI, PPI and SPI has four states. They are visible and writable through the set/clear register pairs (GICD/GICR_ISPENDR/ICPENDR, ISACTIVER/ICACTIVER):
assert / set-pending acknowledge (IARn read)
Inactive ------------------------> Pending ----------------------------> Active
^ | ^
| re-assert (edge) or | |
| still asserted (level) v |
+-- deactivate (EOImode=0 EOI, or DIR) -------------------- Active and pending
from Active -> Inactive, from Active and pending -> Pending
The trigger type decides how the line maps onto this:
- Level-sensitive: the pending state follows the input. If the peripheral still asserts the line when the interrupt is acknowledged, it goes to active and pending, and it becomes pending again after deactivation. That is why a handler must clear the source before EOI, and why the clear must have completed, not merely been issued (see 7.9). Otherwise the interrupt is taken again straight away.
- Edge-triggered: each rising edge (or message, such as
GICD_SETSPI_NSRor an ITS write) sets pending. Edges that arrive while the interrupt is pending merge into one. An edge that arrives while it is active gives active and pending, so it is not lost.
While an interrupt is active it is not signalled again. A second instance can only arrive once it has been deactivated. This is the mechanism that serialises one INTID across all PEs.
Acknowledge, priority drop, deactivation
Handling an interrupt involves three distinct architectural events:
- Acknowledge: a read of
ICC_IAR0_EL1(Group 0) orICC_IAR1_EL1(Group 1) returns the INTID of the highest-priority pending interrupt of that group. That interrupt must be enabled, its group must be enabled, its priority must be higher thanICC_PMR_EL1, and its group priority must be higher than the running priority. The read moves the interrupt from pending to active, sets the bit for its group priority inICC_AP0Rn/ICC_AP1Rn, and so raises the running priority (ICC_RPR_EL1). The acknowledge is itself a side-effecting System-register read. That is one reason Linux followsICC_IAR1_EL1with aDSB SY(gic_read_iar()). - Priority drop: a write of the INTID to
ICC_EOIR0_EL1/ICC_EOIR1_EL1clears the highest set active-priority bit, which lowers the running priority so that lower-priority interrupts can preempt again. Priority drops must be done in the reverse order of acknowledges, and the EOIR group must match the IAR group used. - Deactivation: the interrupt moves from active to inactive (or from active and pending to pending), so the GIC can signal that INTID again.
ICC_CTLR_EL1.EOImode (with the EL3 copies ICC_CTLR_EL3.EOImode_EL3, EOImode_EL1S and EOImode_EL1NS) decides whether steps 2 and 3 are combined:
| EOImode | ICC_EOIRn_EL1 write | ICC_DIR_EL1 write |
|---|---|---|
| 0 | Priority drop and deactivation | Must not be used (behavior is not useful; see IHI0069 ICC_DIR_EL1) |
| 1 | Priority drop only | Deactivation |
EOImode = 1 has two main uses:
- Forwarding to a guest. A hypervisor acknowledges and drops priority on a physical interrupt but leaves it active. It then puts it in a list register with the HW bit set, so that the guest’s virtual EOI deactivates the physical interrupt directly. KVM runs the host with EOImode = 1 when it owns EL2 for this reason (11.4).
- Deferred handling of a level interrupt. The handler drops priority so other interrupts can run, and keeps the INTID active (so not re-signalled) until a thread has quietened the device. Then it writes
ICC_DIR_EL1.
The minimal EOImode = 0 handler at EL1:
irq_el1:
mrs x0, ICC_IAR1_EL1 // acknowledge: pending -> active, RPR raised
and w1, w0, #0xffffff // INTID field
sub w2, w1, #1020
cmp w2, #3
b.ls 1f // 1020-1023: special, nothing to EOI (LPIs are >= 8192)
dsb sy // as Linux does after IAR
bl dispatch // must quiesce the source (and complete the write)
msr ICC_EOIR1_EL1, x0 // priority drop + deactivate (EOImode == 0)
isb // redundant before ERET (itself a context synchronization event
// unless SCTLR_EL1.EOS == 0); needed if unmasking in place
1: eret // (register save/restore omitted)
A spurious 1023 must not be written to EOIR. Its usual cause is a race: the interrupt was withdrawn, or a higher-priority one was taken elsewhere, between signalling and acknowledge.
Type-specific details
- SGIs in GICv3 with affinity routing have no per-source state. The GICv2 “which CPU sent it” field in IAR is gone. An SGI that is sent again while still pending on the same target merges into one. Non-secure code can generate a Secure SGI only where
GICR_NSACRpermits. To make normal-memory data visible to the target’s handler before the SGI arrives, the sender needs aDSBbefore theICC_SGI1R_EL1write, because aDMBdoes not order against a System-register write. It also needs anISBafter the write to ensure the SGI is issued promptly. Linux’sgic_ipi_send_mask()usesdsb(ishst)… write …isb(). - PPIs are private to one PE: they are routed only to the PE they belong to, and must be configured through that PE’s Redistributor. Neither the GIC spec nor the Arm ARM fixes which PPI a source uses. BSA gives the recommended assignments, for example the EL1 physical timer (INTID 30), the EL1 virtual timer (27), the Non-secure EL2 physical timer (26) and the PMU (23); the platform’s firmware tables give the real ones.
- LPIs have no active state. Acknowledging an LPI makes it inactive straight away. The EOI is still needed for the priority drop, and
ICC_DIR_EL1for an LPI has no effect. A new MSI can set it pending again while the handler is still running, so LPI handlers must tolerate re-entry or the device must not re-signal. LPI configuration is cached, so a change to the property table needs an explicit invalidate (4.4).
Security note: The set-pending and set-active registers let a privileged agent fabricate an interrupt. Secure-group interrupts are RAZ/WI to Non-secure accesses in the Distributor and Redistributor (when
GICD_CTLR.DS == 0), which is what stops the Normal world injecting a Secure interrupt. If a platform ships withDS == 1, that protection is gone, and the boot chain should treat it as a configuration error on any system with a TEE.
Checkpoint
Q4.2.1 A level-sensitive SPI handler running with EOImode = 0 writes ICC_EOIR1_EL1 and then clears the device’s status register with a store to Device-nGnRE memory. The interrupt is taken a second time with nothing to do. What explains this?
- A. EOImode = 0 does not deactivate SPIs, so the interrupt stays active and is re-signalled
- B. The EOI deactivated the interrupt while the line was still asserted, so it went to pending (it was active and pending) and was signalled again before the device clear took effect
- C. Level-sensitive SPIs must be acknowledged twice, once for assertion and once for deassertion
- D. The running priority was not dropped, so the same interrupt preempted itself
Answer
B. For a level interrupt the pending state follows the input. Deactivating while the input is still high leaves it pending, and since the priority has dropped it is signalled again. The source must be quietened first, and that store must have completed (a DSB, or a read-back if the peripheral needs it) before the EOI. D cannot be right: an interrupt cannot preempt at its own running priority, and an EOI with EOImode = 0 does drop the priority.
Read more: GIC Architecture Specification (IHI0069), Interrupt handling state machine; level-sensitive and edge-triggered behavior
Q4.2.2 A hypervisor runs with EOImode = 1 at EL2. It acknowledges a physical SPI, writes ICC_EOIR1_EL1, and forwards the SPI to a guest through a list register with the HW bit set. What is the state of the physical SPI while the guest handles it?
- A. Inactive: EOIR deactivated it, and the HW bit only affects the virtual interrupt
- B. Pending: priority drop returns it to pending until the guest acknowledges
- C. Active, with the running priority of the PE still raised until the guest’s EOI
- D. Active, with the PE’s running priority already dropped, so it will be deactivated when the guest’s virtual EOI propagates through the HW bit
Answer
D. With EOImode = 1, the EOIR write only drops priority, so the PE can take other interrupts, including the maintenance and other physical interrupts the hypervisor needs. The physical SPI stays active, so it is not re-signalled. When the guest deactivates the virtual interrupt, the HW link deactivates the physical INTID. C is wrong because the priority drop has already happened. A would be the EOImode = 0 behavior.
Read more: GIC Architecture Specification (IHI0069), Priority drop and interrupt deactivation; ICC_CTLR_EL1.EOImode; ICH_LR<n>_EL2.HW
Q4.2.3 A core stores a message to a Normal-memory mailbox, executes DMB ISH, and then writes ICC_SGI1R_EL1 to signal another core. Occasionally the receiving handler reads the old message. Why?
- A.
DMBorders memory accesses only against other memory accesses. The System-register write that generates the SGI is not a memory access, so it needs aDSBbefore it - B. SGIs are delivered speculatively before the sender’s store, and only an
ISBon the receiver fixes it - C.
DMB ISHdoes not cover the receiving core;DMB OSHis required - D. The mailbox must be Device memory for any barrier to order it against an SGI
Answer
A. The SGI write is a System-register access with side effects outside the memory model’s ordering of explicit accesses. DMB does not order it after earlier stores, but DSB waits for those stores to complete before later instructions, including the MSR, execute. Both cores are in the same Inner Shareable domain, so C misidentifies the problem. Linux uses dsb(ishst) before the SGI write.
Read more: Arm ARM (DDI0487), Memory barriers, DSB; GIC Architecture Specification (IHI0069), ICC_SGI1R_EL1