Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 52

ARMv8-A Architecture: AArch64 and Exception Levels

Recommended resources

Hello! Welcome to your next lesson in the "Advanced ARM Architectures" module.

In our last session, we focused on the practicalities of managing memory in ARMv7-A, specifically implementing cache maintenance operations to ensure coherency between the CPU and peripherals like DMA. We saw how crucial operations like clean and invalidate, paired with memory barriers, are for preventing subtle and serious bugs.

Today, we take a significant leap forward in the ARM timeline. We will explore the foundational changes introduced in the ARMv8-A architecture, which powers virtually all modern 64-bit embedded systems, including the advanced SoCs used in software-defined vehicles. This lesson directly addresses your interview preparation needs for "ARMv7/v8 architecture" by focusing on the core evolution between them.

Our learning goal is to describe the key differences in the ARMv8-A architecture, including the AArch64 execution state and the new exception levels (EL0-EL3).

From Modes to Levels: A New Privilege Model

Your experience with embedded systems likely includes familiarity with the classic ARM processor modes used in ARMv7 and earlier architectures (e.g., User, Supervisor, IRQ, FIQ). These modes provided different levels of privilege and access to system resources.

ARMv8-A replaces this model with a cleaner, more structured system of four Exception Levels (ELs). This hierarchical model is a cornerstone of the new architecture, providing a robust framework for virtualization, security, and managing complex software stacks.

The two most significant changes in ARMv8-A are:

  1. Introduction of a 64-bit execution state (AArch64).
  2. A new exception model based on Exception Levels EL0, EL1, EL2, and EL3.

Let's dive into what these levels are and why they are so important.


The Big Picture: Exception Levels and Security States

To get a comprehensive overview, we'll watch a video that explains the motivation behind the ARMv8-A architecture and provides an excellent breakdown of the exception levels and their real-world applications.

1. Introduction and Motivation | ARM-A (aarch64), in Pyjama!

This video from the 'inpyjama' channel, titled 'Introduction and Motivation', provides an intuitive explanation of the ARMv8-A architecture. It's particularly good at explaining the why behind the design choices, which helps in building deep understanding.

Please watch the following two segments: Exception Levels (EL0-EL3): Start at 04:35 and watch until 25:21. This part details each level, its purpose, and how they relate to applications, operating systems, and hypervisors. The cloud computing analogy is very helpful for understanding EL2. Secure vs. Normal Worlds: Continue from 25:21 to 39:51. This segment explains the concept of ARM TrustZone using a clear example of fingerprint authentication. It clarifies the role of EL3 and the need for hardware-enforced security domains. Focus on building a mental model of who 'lives' at each level and why this separation is necessary.

Now, let's consolidate what you've just seen.

ARMv8-A Exception Levels and Security States
This diagram illustrates the complete ARMv8-A architectural model. It shows the four Exception Levels (EL0-EL3) and their separation into a Non-Secure (Normal) World and a Secure World. Note the typical software components running at each level: Applications (EL0), OS/Guest OS (EL1), Hypervisor (EL2), and the Secure Monitor/Firmware (EL3).

AArch64 and AArch32 Execution States

As the video mentioned, a primary feature of ARMv8-A is its 64-bit capability. This is enabled by the AArch64 execution state.

  • AArch64: The new 64-bit state. It features a streamlined instruction set (A64), access to 31 general-purpose 64-bit registers (X0-X30), and fully utilizes the new exception model.
  • AArch32: This state provides backward compatibility, allowing the processor to run legacy 32-bit code from the ARMv7-A era without modification. It uses the older A32 and T32 (Thumb) instruction sets and register model.

This dual-state capability was crucial for a smooth industry transition to 64-bit computing. For new driver development on modern automotive platforms, you will almost exclusively work within the AArch64 state.

The Four Exception Levels

The hierarchy of privilege in ARMv8-A is strict: the higher the number, the greater the privilege. Code running at a certain level, ELn, can generally only access resources at its own level or lower.

  • EL0: User Applications

    • This is the lowest privilege level.
    • It's where all your user-space applications run (e.g., the media player in an infotainment system, a command-line utility in Linux).
    • Access to system hardware and critical configuration registers is restricted. To perform a privileged action, an application must request it from the operating system via a system call, which causes an exception and a controlled transition to EL1.
  • EL1: The Operating System Kernel

    • This level is designed for the OS kernel (e.g., Linux, QNX, AUTOSAR OS).
    • The kernel manages the system's resources, schedules processes running at EL0, and controls the hardware on their behalf.
    • In your AUTOSAR experience, the OS and the core parts of the BSW would conceptually reside here, managing the application layer.
  • EL2: The Hypervisor (Virtualization)

    • This level enables hardware virtualization. A hypervisor running at EL2 can manage and switch between multiple "guest" operating systems, each running in its own sandboxed environment at EL1.
    • This is incredibly important in modern automotive architecture. For example, a single powerful SoC can run a safety-critical RTOS (like QNX) for the instrument cluster and a rich infotainment OS (like Android Automotive) simultaneously, with the hypervisor ensuring they are strictly isolated from one another. Your work with gateways and software-defined vehicle platforms directly relates to this trend of consolidating functions onto powerful, virtualized processors.
  • EL3: The Secure Monitor (The Root of Trust)

    • This is the most privileged level in the processor and is the foundation of the system's security.
    • Code running at EL3, typically called the Secure Monitor, acts as the gatekeeper between the Normal World (where EL0, EL1, and EL2 typically operate) and the Secure World.
    • The Secure Monitor is responsible for booting the system securely, managing cryptographic keys, and handling transitions between the two worlds. This connects directly to concepts like secure boot, Hardware Security Modules (HSMs), and functional safety (ISO 26262), as EL3 provides the ultimate hardware-enforced protection for the most critical software.

The diagram below provides a useful comparison, mapping the old ARMv7 modes to the new AArch64 exception levels.

ARM Exception Levels Comparison: AArch32 vs. AArch64
This image contrasts the exception handling models. On the left, ARMv7's non-hierarchical modes. On the right, ARMv8-A's cleaner, hierarchical EL0-EL3 structure for both Normal and Secure worlds.
Test your understanding!

You are designing a system for an ADAS domain controller. It needs to run a safety-critical AUTOSAR stack for camera and RADAR fusion (ASIL-D) and a non-safety-critical Linux-based stack for logging and diagnostics. How would you map these software components to the ARMv8-A exception levels to ensure safety and isolation?

Show answer

A robust design would use virtualization. A hypervisor would run at EL2. It would host two guest operating systems:

  1. The safety-critical AUTOSAR OS and stack would run as one guest OS at EL1.
  2. The Linux OS would run as a separate guest OS at EL1.

The hypervisor at EL2 is responsible for partitioning hardware resources (memory, peripherals) and scheduling the two operating systems, ensuring that the non-critical Linux system cannot interfere with the safety-critical AUTOSAR system. The actual application software on both stacks would run at EL0.


Putting It All Together: A Quick Review

Let's watch one more short clip to reinforce these core concepts from a slightly different perspective, focusing on how a programmer interacts with these features.

2. Exploring the Programmers Guide | ARM-A (aarch64), in Pyjama!

This clip from the next video in the series, 'Exploring the Programmers Guide', offers a concise summary of the three key architectural concepts we've discussed.

Watch the segment from 20:59 to 24:19. It quickly recaps: Exception Levels (EL0-EL3) Security States (Secure/Non-secure) Execution Modes (AArch64/AArch32) This will help solidify the terminology.


Interview Corner

Understanding this architectural shift is critical for any role involving ARMv8. Here are some questions you can expect, drawn from resources like "Top 25 ARM64 Interview Questions".

Q1: What are the main architectural differences between ARMv7 and ARMv8?
A: The main difference is that ARMv8 introduces a 64-bit architecture. This comes with two key changes: a new 64-bit execution state called AArch64, which features a larger register file (31 general-purpose registers) and a modern instruction set. Secondly, it replaces the old processor modes with a hierarchical four-level exception model (EL0 to EL3), which provides a much more structured foundation for security and virtualization. While introducing AArch64, it maintains backward compatibility with ARMv7 through the AArch32 execution state.

Q2: Can you explain the purpose of the exception levels in ARMv8-A? Give an example of software that runs at each level.
A: The exception levels define a hierarchy of privilege.

  • EL0 is the least privileged and is for user applications, like a navigation app.
  • EL1 is for the operating system kernel, like QNX or Linux, which manages applications and hardware.
  • EL2 is for the hypervisor, which allows multiple operating systems to run on the same CPU, isolated from each other. For example, running a real-time OS for the instrument cluster and Android for infotainment on one chip.
  • EL3 is the most privileged level for the Secure Monitor, which manages the switch between the Normal World and the Secure World (TrustZone) and handles secure boot and firmware.

Q3: What is the relationship between Exception Levels and ARM TrustZone security?
A: ARM TrustZone technology partitions the processor into two 'worlds': a Normal World for general-purpose processing and a Secure World for security-sensitive operations. The exception levels exist in both worlds. However, EL3, the Secure Monitor, exists only in the Secure World and acts as the gatekeeper between the two. When the Normal World OS needs a secure service (like validating a signature), it executes a special instruction (SMC) that traps to the Secure Monitor at EL3. The monitor then saves the Normal World state and passes control to a trusted OS or application running in the Secure World at Secure EL1 or EL0. This provides hardware isolation for critical assets.


Conclusion

You have now covered the fundamental architectural principles of ARMv8-A. Moving from ARMv7's flat mode-based system to ARMv8-A's hierarchical, multi-world exception model is a major conceptual step, but it's one that enables the complex, secure, and virtualized systems that are defining the future of automotive electronics.

Key Takeaways:

  • ARMv8-A introduces the AArch64 64-bit execution state while retaining AArch32 for backward compatibility.
  • The old processor modes are replaced by four hierarchical Exception Levels: EL0 (User), EL1 (OS), EL2 (Hypervisor), and EL3 (Secure Monitor).
  • Privilege increases from EL0 to EL3.
  • The architecture is split into a Normal World and a Secure World (TrustZone), with EL3 managing the transitions.
  • This model is the foundation for modern virtualization and security in embedded systems.

Next Lesson Preview:
Now that we understand the structure of the ARMv8-A architecture, our next step is to look at how software actually executes on it. In the next lesson, we will analyze AArch64 assembly code to explain the procedure call standard for passing parameters and returning values. This will bridge the gap between high-level architectural concepts and low-level implementation.