Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 82 additions & 35 deletions src/registers/esr_el1.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2018-2023 by the author(s)
// Copyright (c) 2018-2025 by the author(s)
//
// Author(s):
// - Andre Richter <andre.o.richter@gmail.com>
// - Berkus Decker <berkus+github@metta.systems>
// - Yan Tan <tanyan@kylinos.cn>

//! Exception Syndrome Register - EL1
//!
Expand All @@ -24,43 +25,89 @@ register_bitfields! {u64,
/// - The cause of the exception, for example the configuration required to enable the
/// trap.
/// - The encoding of the associated ISS.
///
/// Incomplete listing - to be done.
EC OFFSET(26) NUMBITS(6) [
Unknown = 0b00_0000,
TrappedWFIorWFE = 0b00_0001,
TrappedMCRorMRC = 0b00_0011, // A32
TrappedMCRRorMRRC = 0b00_0100, // A32
TrappedMCRorMRC2 = 0b00_0101, // A32
TrappedLDCorSTC = 0b00_0110, // A32
TrappedFP = 0b00_0111,
TrappedMRRC = 0b00_1100, // A32
BranchTarget = 0b00_1101,
/// Unknown reason
Unknown = 0b00_0000,
/// Trapped WF* instruction execution
TrappedWFIorWFE = 0b00_0001,
/// Trapped MCR or MRC access with (coproc==0b1111) (FEAT_AA32)
TrappedMCRorMRC = 0b00_0011,
/// Trapped MCRR or MRRC access with (coproc==0b1111) (FEAT_AA32)
TrappedMCRRorMRRC = 0b00_0100,
/// Trapped MCR or MRC access with (coproc==0b1110) (FEAT_AA32)
TrappedMCRorMRC2 = 0b00_0101,
/// Trapped LDC or STC access (FEAT_AA32)
TrappedLDCorSTC = 0b00_0110,
/// Access to SME, SVE, Advanced SIMD or floating-point functionality trapped
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also only available for FEAT_AA32.

Copy link
Copy Markdown
Member

@berkus berkus Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update, thanks for noticing!

TrappedFP = 0b00_0111,
/// Trapped execution of any instruction not covered by other EC values (FEAT_LS64)
Comment thread
berkus marked this conversation as resolved.
TrappedNotCovered = 0b00_1010,
/// Trapped MRRC access with (coproc==0b1110) (FEAT_AA32)
TrappedMRRC = 0b00_1100,
/// Branch Target Exception (FEAT_BTI)
BranchTarget = 0b00_1101,
/// Illegal Execution state (FEAT_BTI)
IllegalExecutionState = 0b00_1110,
SVC32 = 0b01_0001, // A32
SVC64 = 0b01_0101,
HVC64 = 0b01_0110,
SMC64 = 0b01_0111,
TrappedMsrMrs = 0b01_1000,
TrappedSve = 0b01_1001,
PointerAuth = 0b01_1100,
InstrAbortLowerEL = 0b10_0000,
InstrAbortCurrentEL = 0b10_0001,
PCAlignmentFault = 0b10_0010,
DataAbortLowerEL = 0b10_0100,
DataAbortCurrentEL = 0b10_0101,
SPAlignmentFault = 0b10_0110,
TrappedFP32 = 0b10_1000, // A32
TrappedFP64 = 0b10_1100,
SError = 0b10_1111,
BreakpointLowerEL = 0b11_0000,
BreakpointCurrentEL = 0b11_0001,
SoftwareStepLowerEL = 0b11_0010,
/// SVC instruction execution in AArch32 state (FEAT_AA32)
SVC32 = 0b01_0001,
/// Trapped MSRR, MRRS or System instruction execution in AArch64 state (FEAT_SYSREG128/FEAT_SYSINSTR128)
TrappedMSRR_MRRS = 0b01_0100,
/// SVC instruction execution in AArch64 state
SVC64 = 0b01_0101,
/// HVC instruction execution in AArch64 state
HVC64 = 0b01_0110,
/// SMC instruction execution in AArch64 state
SMC64 = 0b01_0111,
/// Trapped MSR, MRS or System instruction execution in AArch64 state
TrappedMsrMrs = 0b01_1000,
/// Access to SVE functionality trapped (FEAT_SVE)
TrappedSve = 0b01_1001,
/// Exception from TSTART instruction (FEAT_TME)
TrappedTSTART = 0b01_1011,
/// Exception from a PAC Fail (FEAT_FPAC)
PointerAuth = 0b01_1100,
/// Access to SME functionality trapped (FEAT_SME)
TrappedSME = 0b01_1101,
/// Instruction Abort from a lower Exception level
InstrAbortLowerEL = 0b10_0000,
/// Instruction Abort taken without a change in Exception level
InstrAbortCurrentEL = 0b10_0001,
/// PC alignment fault exception
PCAlignmentFault = 0b10_0010,
/// Data Abort exception from a lower Exception level
DataAbortLowerEL = 0b10_0100,
/// Data Abort exception without a change in Exception level
DataAbortCurrentEL = 0b10_0101,
/// SP alignment fault exception
SPAlignmentFault = 0b10_0110,
/// Memory Operation Exception (FEAT_MOPS)
MemoryOperationException = 0b10_0111,
/// Trapped floating-point exception taken from AArch32 state (FEAT_AA32)
TrappedFP32 = 0b10_1000,
/// Trapped floating-point exception taken from AArch64 state
TrappedFP64 = 0b10_1100,
/// GCS exception (FEAT_GCS)
GCSException = 0b10_1101,
/// SError exception
SError = 0b10_1111,
/// Breakpoint exception from a lower Exception level
BreakpointLowerEL = 0b11_0000,
/// Breakpoint exception taken without a change in Exception level
BreakpointCurrentEL = 0b11_0001,
/// Software Step exception from a lower Exception level
SoftwareStepLowerEL = 0b11_0010,
/// Software Step exception taken without a change in Exception level
SoftwareStepCurrentEL = 0b11_0011,
WatchpointLowerEL = 0b11_0100,
WatchpointCurrentEL = 0b11_0101,
Bkpt32 = 0b11_1000, // A32 BKTP instruction
Brk64 = 0b11_1100 // A64 BRK instruction
/// Watchpoint exception from a lower Exception level
WatchpointLowerEL = 0b11_0100,
/// Watchpoint exception taken without a change in Exception level
WatchpointCurrentEL = 0b11_0101,
/// BKPT instruction execution in AArch32 state (FEAT_AA32)
Bkpt32 = 0b11_1000,
/// BRK instruction execution in AArch64 state
Brk64 = 0b11_1100,
/// Profiling exception (FEAT_EBEP/FEAT_SPE_EXC/FEAT_TRBE_EXC)
ProfilingException = 0b11_1101
],
Comment thread
berkus marked this conversation as resolved.

/// Instruction Length for synchronous exceptions.
Expand Down
129 changes: 94 additions & 35 deletions src/registers/esr_el2.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2018-2023 by the author(s)
// Copyright (c) 2018-2025 by the author(s)
//
// Author(s):
// - Andre Richter <andre.o.richter@gmail.com>
// - Berkus Decker <berkus+github@metta.systems>
// - Bradley Landherr <landhb@users.noreply.github.com>
// - Yan Tan <tanyan@kylinos.cn>

//! Exception Syndrome Register - EL2
//!
Expand Down Expand Up @@ -36,43 +37,101 @@ register_bitfields! {u64,
/// - The cause of the exception, for example the configuration required to enable the
/// trap.
/// - The encoding of the associated ISS.
///
/// Incomplete listing - to be done.
EC OFFSET(26) NUMBITS(6) [
Unknown = 0b00_0000,
TrappedWFIorWFE = 0b00_0001,
TrappedMCRorMRC = 0b00_0011, // A32
TrappedMCRRorMRRC = 0b00_0100, // A32
TrappedMCRorMRC2 = 0b00_0101, // A32
TrappedLDCorSTC = 0b00_0110, // A32
TrappedFP = 0b00_0111,
TrappedMRRC = 0b00_1100, // A32
BranchTarget = 0b00_1101,
/// Unknown reason
Unknown = 0b00_0000,
/// Trapped WF* instruction execution
TrappedWFIorWFE = 0b00_0001,
/// Trapped MCR or MRC access with (coproc==0b1111) (FEAT_AA32)
TrappedMCRorMRC = 0b00_0011,
/// Trapped MCRR or MRRC access with (coproc==0b1111) (FEAT_AA32)
TrappedMCRRorMRRC = 0b00_0100,
/// Trapped MCR or MRC access with (coproc==0b1110) (FEAT_AA32)
TrappedMCRorMRC2 = 0b00_0101,
/// Trapped LDC or STC access (FEAT_AA32)
TrappedLDCorSTC = 0b00_0110,
/// Access to SME, SVE, Advanced SIMD or floating-point functionality trapped
TrappedFP = 0b00_0111,
/// Trapped VMRS access, from ID group trap (FEAT_AA32)
TrappedVMRS = 0b00_1000,
/// Trapped use of a Pointer authentication instruction (FEAT_PAuth)
TrappedPointerAuth = 0b00_1001,
/// Trapped execution of any instruction not covered by other EC values (FEAT_LS64/FEAT_SPEv1p5/FEAT_TRBEv1p1)
TrappedNotCovered = 0b00_1010,
/// Trapped MRRC access with (coproc==0b1110) (FEAT_AA32)
TrappedMRRC = 0b00_1100,
/// Branch Target Exception (FEAT_BTI)
BranchTarget = 0b00_1101,
/// Illegal Execution state
IllegalExecutionState = 0b00_1110,
SVC32 = 0b01_0001, // A32
SVC64 = 0b01_0101,
HVC64 = 0b01_0110,
SMC64 = 0b01_0111,
TrappedMsrMrs = 0b01_1000,
TrappedSve = 0b01_1001,
PointerAuth = 0b01_1100,
InstrAbortLowerEL = 0b10_0000,
InstrAbortCurrentEL = 0b10_0001,
PCAlignmentFault = 0b10_0010,
DataAbortLowerEL = 0b10_0100,
DataAbortCurrentEL = 0b10_0101,
SPAlignmentFault = 0b10_0110,
TrappedFP32 = 0b10_1000, // A32
TrappedFP64 = 0b10_1100,
SError = 0b10_1111,
BreakpointLowerEL = 0b11_0000,
BreakpointCurrentEL = 0b11_0001,
SoftwareStepLowerEL = 0b11_0010,
/// SVC instruction execution in AArch32 state (FEAT_AA32)
SVC32 = 0b01_0001,
/// HVC instruction execution in AArch32 state (FEAT_AA32)
HVC32 = 0b01_0010,
/// SMC instruction execution in AArch32 state (FEAT_AA32)
SMC32 = 0b01_0011,
/// Trapped MSRR, MRRS or System instruction execution in AArch64 state (FEAT_SYSREG128/FEAT_SYSINSTR128)
TrappedMSRR_MRRS = 0b01_0100,
/// SVC instruction execution in AArch64 state (FEAT_AA64)
SVC64 = 0b01_0101,
/// HVC instruction execution in AArch64 state (FEAT_AA64)
HVC64 = 0b01_0110,
/// SMC instruction execution in AArch64 state (FEAT_AA64)
SMC64 = 0b01_0111,
/// Trapped MSR, MRS or System instruction execution in AArch64 state (FEAT_AA64)
TrappedMsrMrs = 0b01_1000,
/// Access to SVE functionality trapped (FEAT_SVE)
TrappedSve = 0b01_1001,
/// Trapped ERET, ERETAA, or ERETAB instruction execution (FEAT_FGT/FEAT_NV)
TrappedERET = 0b01_1010,
/// Exception from TSTART instruction (FEAT_TME)
TrappedTSTART = 0b01_1011,
/// Exception from a PAC Fail (FEAT_FPAC)
PointerAuth = 0b01_1100,
/// Access to SME functionality trapped (FEAT_SME)
TrappedSME = 0b01_1101,
/// Instruction Abort from a lower Exception level
InstrAbortLowerEL = 0b10_0000,
/// Instruction Abort taken without a change in Exception level
InstrAbortCurrentEL = 0b10_0001,
/// PC alignment fault exception
PCAlignmentFault = 0b10_0010,
/// Data Abort exception from a lower Exception level
DataAbortLowerEL = 0b10_0100,
/// Data Abort exception without a change in Exception level
DataAbortCurrentEL = 0b10_0101,
/// SP alignment fault exception
SPAlignmentFault = 0b10_0110,
/// Memory Operation Exception (FEAT_MOPS)
MemoryOperationException = 0b10_0111,
/// Trapped floating-point exception taken from AArch32 state (FEAT_AA32)
TrappedFP32 = 0b10_1000,
/// Trapped floating-point exception taken from AArch64 state (FEAT_AA64)
TrappedFP64 = 0b10_1100,
/// GCS exception (FEAT_GCS)
GCSException = 0b10_1101,
/// SError exception
SError = 0b10_1111,
/// Breakpoint exception from a lower Exception level
BreakpointLowerEL = 0b11_0000,
/// Breakpoint exception taken without a change in Exception level
BreakpointCurrentEL = 0b11_0001,
/// Software Step exception from a lower Exception level
SoftwareStepLowerEL = 0b11_0010,
/// Software Step exception taken without a change in Exception level
SoftwareStepCurrentEL = 0b11_0011,
WatchpointLowerEL = 0b11_0100,
WatchpointCurrentEL = 0b11_0101,
Bkpt32 = 0b11_1000, // A32 BKTP instruction
Brk64 = 0b11_1100 // A64 BRK instruction
/// Watchpoint exception from a lower Exception level
WatchpointLowerEL = 0b11_0100,
/// Watchpoint exception taken without a change in Exception level
WatchpointCurrentEL = 0b11_0101,
/// BKPT instruction execution in AArch32 state (FEAT_AA32)
Bkpt32 = 0b11_1000,
/// Vector Catch exception from AArch32 state (FEAT_AA32)
VectorCatch32 = 0b11_1010,
/// BRK instruction execution in AArch64 state (FEAT_AA64)
Brk64 = 0b11_1100,
/// Profiling exception (FEAT_EBEP/FEAT_SPE_EXC/FEAT_TRBE_EXC)
ProfilingException = 0b11_1101
],

/// Instruction Length for synchronous exceptions.
Expand Down