2.4 PSTATE
PSTATE (“process state”) is not a register. In AArch64 there is no CPSR that you can read or write as a whole. PSTATE is an architectural collection of independent fields. Some have their own access instructions, some can be reached only through SPSR_ELx, and two (SM, ZA) are not saved in SPSR at all. On exception entry, the PE copies the AArch64 PSTATE fields into SPSR_ELx of the target EL, and ERET restores them from it. The exact entry-time changes to each field are listed in 3.2.
The fields
The bit positions are the positions in SPSR_ELx for an exception taken from AArch64. PSTATE itself has no bit layout.
| Field | SPSR bits | Feature | Meaning |
|---|---|---|---|
N,Z,C,V | [31:28] | base | Condition flags |
D,A,I,F | [9:6] | base | Mask debug exceptions, SError, IRQ, FIQ, each for exceptions targeting the current EL (what “masked” means when the target is a higher EL is in 3.3) |
EL | M[3:2] | base | Current Exception level. Read as CurrentEL |
SP | M[0] | base | Stack-pointer select at EL1+ (2.2) |
nRW | M[4] | base | Execution state: 0 = AArch64. Only meaningful in SPSR |
SS | [21] | base | Software step state (16.1) |
IL | [20] | base | Illegal Execution state (3.2) |
PAN | [22] | FEAT_PAN (v8.1) | Privileged accesses to EL0-accessible memory fault (5.5) |
UAO | [23] | FEAT_UAO (v8.2) | LDTR/STTR at EL1/EL2 use the current EL’s permissions, not EL0’s |
DIT | [24] | FEAT_DIT (v8.4) | Data-independent timing for the instructions the Arm ARM lists |
TCO | [25] | FEAT_MTE (v8.5) | Tag Check Override: suppress MTE tag checks (13.5) |
SSBS | [12] | FEAT_SSBS | 0 = hardware may not speculatively let a load bypass an earlier store to the same address (14.5) |
BTYPE | [11:10] | FEAT_BTI (v8.5) | Type of the last indirect branch, checked at the next instruction (13.1) |
ALLINT | [13] | FEAT_NMI (v8.8) | Masks all IRQ and FIQ, including those with Superpriority (4.3) |
SM, ZA | not in SPSR | FEAT_SME (v9.2) | Streaming SVE mode, and ZA storage enabled (15.2) |
PM | [32] | FEAT_EBEP | Masks the PMU exception used for exception-based event profiling (16.3) |
EXLOCK | [34] | FEAT_GCS (v9.4) | Exception-return state lock: while set, the current EL’s changes to its own exception-return state (ELR, SPSR, GCS pointer) are restricted (13.2) |
UINJ | [36] | FEAT_UINJ (v9.6, 2024 extensions) | Undefined-instruction injection: set by a higher EL in SPSR, so that after the return the target takes an Undefined Instruction exception |
SPSR bit [35] is PACM (FEAT_PAuth_LR), another SPSR-only bit. The SPSR layout grows upward from bit 32. SPSR_ELx has been a 64-bit register since v8.0, and save/restore code that keeps only the low 32 bits (str w1, [...] of a mrs x1, spsr_el3) silently drops PM, EXLOCK, PACM and UINJ on newer cores.
Access methods
Each field is reached in one or more of four ways:
- MSR (immediate), the
op0 = 0“PSTATE field” formmsr <field>, #imm. It needs no scratch register and is the canonical way to flip a single bit. - MRS/MSR (register) using a special-purpose register name (
NZCV,DAIF,PAN, …). The value is presented at the field’sSPSRbit position. - Via
SVCR, for the SME bits only. SPSRonly: no direct access, so the field can be changed only by an exception return.
| Field | MSR immediate | MRS/MSR register | Lowest EL with direct access | Notes |
|---|---|---|---|---|
| NZCV | — | NZCV | EL0 | Also written by flag-setting instructions |
| D,A,I,F | DAIFSet, DAIFClr | DAIF | EL1 (EL0 if SCTLR_EL1.UMA = 1) | |
| EL | — | CurrentEL (read-only) | EL1 | UNDEFINED at EL0 |
| SP | SPSel | SPSel | EL1 | |
| PAN | PAN | PAN | EL1 | |
| UAO | UAO | UAO | EL1 | |
| DIT | DIT | DIT | EL0 | |
| SSBS | SSBS | SSBS | EL0 | Direct access needs FEAT_SSBS2. With FEAT_SSBS only, the field is SPSR-only plus the SCTLR_ELx.DSSBS entry default |
| TCO | TCO | TCO | EL0 | |
| ALLINT | ALLINT | ALLINT | EL1 | HCRX_EL2.TALLINT traps EL1’s MSR ALLINT, #1 to EL2 |
| PM | PM | PM | EL1 | |
| SM, ZA | SVCRSM, SVCRZA, SVCRSMZA (= SMSTART/SMSTOP) | SVCR | EL0 | Subject to the SME enables in CPACR_EL1/CPTR_ELx/SMCR_ELx |
| nRW, SS, IL, BTYPE, EXLOCK, UINJ, PACM | — | — | — | SPSR only. BTYPE is also set implicitly by BR/BLR |
msr pan, #1 // immediate form: no register needed
mrs x0, daif // read all four masks (bits [9:6])
msr daifset, #0b0011 // set I and F (bit order D A I F = 8 4 2 1)
mrs x1, currentel
lsr x1, x1, #2 // x1 = EL number
smstart sm // = msr svcrsm, #1
Visibility of a write. The Arm ARM guarantees that the side effects of a PSTATE write by MSR are visible to later instructions in program order and invisible to earlier ones, with no ISB needed. This is unlike most system-register writes (2.5). The guarantee covers the PE’s own interpretation, such as PAN checks on the next load. It does not make a newly unmasked pending interrupt arrive at a particular instruction boundary. That is the interrupt-taking model in 3.3, and the GIC’s PMR is a separate register with its own synchronization rules.
Fields that need particular care
SM and ZA are not saved on exception entry. They live in SVCR, are not copied into SPSR, and exception entry does not change them. A handler at a higher EL that may be entered in Streaming mode therefore runs with PSTATE.SM = 1. It must either avoid FP/SIMD entirely, rely on the SME traps to catch it, or execute SMSTOP and restore the state later. This is why EL3 context management must save and restore SVCR explicitly across worlds (15.3).
SPSR-only fields are policy in the hands of the higher EL. BTYPE and IL carry in-flight state across an exception: the interrupted code’s pending BTI check, or its illegal-state flag. An EL that fabricates an SPSR (for a first entry into a lower EL, or a signal frame) must set them deliberately, normally to 0. UINJ turns this into an explicit tool: rather than synthesising an Undefined Instruction exception into the lower EL by hand (writing the lower EL’s ESR, ELR and SPSR and redirecting to its vector), firmware sets SPSR_EL3.UINJ and returns.
SSBS has two kinds of default. SCTLR_ELx.DSSBS sets the value PSTATE.SSBS takes on exception entry to ELx. EL0 can change its own value only with FEAT_SSBS2. A kernel that wants the speculative-store-bypass mitigation everywhere sets DSSBS = 0 and sanitises SPSR.SSBS on return.
Security note:
PAN,UAO,TCOandDIThave security meaning, and all four are saved and restored throughSPSRon every exception. An EL1 kernel that runs withPAN = 1relies on its own exception entry, controlled bySCTLR_EL1.SPAN, and on everyERETrestoring the intended value. A higher EL that builds a returnSPSRfor EL1 by hand (a hypervisor injecting an exception, or EL3 resuming a world) must preserve these bits from the saved context rather than zeroing them. A zeroedPANorDITis a silent hardening loss that no test catches by crashing.
Bring-up note: When decoding an
SPSRfrom a crash dump, decode at least bits [36:0]. A value like0x4_0000_03c5on a GCS-enabled system is “EL1h, all of DAIF masked,EXLOCKset”. That is not an exotic corruption, only a field older tools don’t print.
Checkpoint
Q2.4.1 A hypervisor runs at EL2 with Streaming SVE mode active (PSTATE.SM = 1) and takes an SMC to EL3. EL3’s handler is built with -mgeneral-regs-only. Which statement is correct?
- A. The handler runs with
PSTATE.SM = 1, because SM is not saved inSPSR_EL3or changed on exception entry. Whether that matters depends on EL3’s SME traps and whether the handler touches FP/SIMD state - B. Exception entry clears SM, and
SPSR_EL3records the old value soERETrestores it - C. The SMC is UNDEFINED while
PSTATE.SM = 1 - D. Exception entry clears both SM and ZA, so ZA contents are lost
Answer
A. SM and ZA are held in SVCR. They are neither copied to SPSR nor modified by exception entry. A general-regs-only handler is unaffected in practice, but any EL3 code that does use FP/SIMD, or a world switch, must handle SVCR explicitly. B is the natural assumption from how every other PSTATE bit behaves.
Read more: Arm ARM (DDI0487), SVCR, and “Process state, PSTATE” in the AArch64 exception model; SME supplement chapters
Q2.4.2 Which pair of PSTATE fields can be changed only by an exception return, with no MSR or MRS form?
- A.
PANandUAO - B.
SSBSandTCO - C.
BTYPEandIL - D.
ALLINTandPM
Answer
C. BTYPE is written implicitly by indirect branches, and IL by illegal returns. Neither has a direct access instruction, so software can set them only through SPSR on ERET. All the others have MSR immediate and MRS/MSR register forms, although SSBS gets them only with FEAT_SSBS2, which makes B tempting on an SSBS-only core.
Read more: Arm ARM (DDI0487), “Process state, PSTATE” and SPSR_EL1
Q2.4.3 An EL1 kernel executes msr pan, #1 and on the very next instruction performs an ldr from a user page. Which statement is correct?
- A. An
ISBis required between them, or the load may still be checked withPAN = 0 - B. No
ISBis needed: a PSTATE write by MSR is architecturally visible to all later instructions - C. A
DSB ISHis required to make the PAN change visible to the MMU - D. The write only takes effect at the next exception return
Answer
B. Writes to PSTATE fields are guaranteed to affect later instructions and not earlier ones, without a context synchronization event. This differs from writes to a system register such as SCTLR_EL1, which generally do need an ISB (7.8). Option A applies that system-register rule to PSTATE.
Read more: Arm ARM (DDI0487), “Process state, PSTATE” (writes to PSTATE fields); PAN