What are ARM exception levels EL0 to EL3?
Short answer: EL0 runs applications, EL1 normally runs the OS kernel, EL2 supports virtualization, and EL3 supports secure monitor functions. Availability depends on implementation.
MRS X0, CurrentEL // privileged code
1. Privilege levels
| Level | Typical software |
|---|---|
| EL0 | Application |
| EL1 | Linux kernel and drivers |
| EL2 | Hypervisor |
| EL3 | Secure monitor |
2. Transition example: A userspace syscall executes SVC, normally entering EL1. The kernel validates arguments, performs work and returns with ERET. A guest may encounter traps routed to EL2.
3. Why isolation matters: EL0 cannot freely program privileged system registers or access kernel-only mappings. An illegal operation can cause an exception.
Interview takeaway: Exception levels provide privilege separation. Higher ELs are not stages that every instruction passes through; routing depends on configuration.
Example: a Linux guest under an ARM hypervisor
Guest application (EL0) -- SVC --> guest kernel (EL1)
Guest kernel -- selected trap / stage-2 fault --> hypervisor (EL2)
Hypervisor -- ERET --> guest execution
Secure monitor (EL3), when present, handles defined secure transitions
The ordinary guest syscall need not exit to EL2. Hypervisor control registers determine which operations trap. The guest's stage-1 tables manage guest virtual addresses, while the hypervisor's stage-2 tables restrict access to host physical memory.
A conventional non-VHE host kernel runs at EL1, but with VHE the host kernel can execute at EL2. Not every CPU implements every exception level or security extension. EL0 cannot directly modify privileged translation registers; entry through the configured exception mechanism is required. Exception level describes privilege within an execution context, whereas Secure/Non-secure state concerns security attribution.