ARM TrustZone Architecture
Hardware Security Architecture · Hardware Foundations track
11 min read
In this module
Two Worlds on One Chip
ARM TrustZone is a system-wide architecture that splits one physical processor into two virtual processors, each running in its own world. The Secure world handles the touchy stuff: key storage, biometric processing, DRM. The Normal world runs the rich OS and all user applications. Hardware draws the boundary at every level — CPU core, memory controller, bus interconnect, peripherals.
That dual-world setup means even a fully compromised Normal-world OS — root achieved, a kernel module loaded, some driver popped — still can't touch Secure-world memory or peripherals. Hardware enforces the line, not software privilege levels.
Every bus transaction in a TrustZone system rides an extra signal: the NS (Non-Secure) bit. Normal-world execution sets it to 1. Secure-world execution sets it to 0. Memory controllers, peripheral controllers, and interconnects sniff that bit on every transaction and reject anything violating the configured security policy.
The Non-Secure (NS) bit is the fundamental hardware mechanism of TrustZone. It propagates from the CPU core through the entire bus fabric, tagging every memory transaction with its origin world. Hardware decoders at every memory and peripheral boundary check this bit to enforce access policy. Software cannot forge or override it - only the monitor at EL3 can change the processor's world state.
Monitor Mode: The Gatekeeper
The Secure Monitor sits at Exception Level 3 (EL3) in AArch64, the highest privilege level in the system — above even the hypervisor at EL2. It's the only software that can switch the processor between Secure and Normal worlds.
When Normal-world software needs a secure service — say, pulling a random number from a hardware RNG that only the Secure world can reach — it executes the SMC (Secure Monitor Call) instruction. That throws a synchronous exception to EL3, much like a syscall trapping to the kernel. The monitor then:
- Saves the Normal-world register state (all general-purpose registers, stack pointer, program counter, system registers).
- Validates the request. The SMC calling convention defines which register holds the function ID and which hold parameters.
- Restores the Secure-world register state.
- Transfers execution to the Trusted OS in the Secure world (S-EL1).
Once the Trusted OS finishes, a reverse SMC bounces back to the monitor, which saves Secure-world state, restores Normal-world state, and resumes the rich OS.
Here's one complete round trip. Watch where the NS bit flips: only the monitor at EL3 touches it, and it does so while both worlds' contexts are parked.
The SMC Calling Convention
ARM standardises the SMC Calling Convention (SMCCC) so Normal-world software can invoke Secure-world services portably. The function ID in W0 is carved into fields:
- Bit 31: 1 for fast calls (run to completion without interruption), 0 for yielding calls (may take longer and can be pre-empted by Normal-world interrupts).
- Bit 30: calling convention. 0 for SMC32 (32-bit arguments in W registers), 1 for SMC64 (64-bit arguments in X registers).
- Bits 29-24: Owning entity. 0 for Arm Architecture calls, 1 for CPU service, 2 for SiP (silicon provider) service, 3 for OEM service, 4 for Standard Secure services (such as PSCI power management), 5 and 6 for standard and vendor hypervisor services, 48-49 for Trusted Application calls, 50-63 for Trusted OS calls.
- Bits 15-0: Function number within the service.
This convention lets the monitor dispatch incoming SMC calls to the right handler without parsing arbitrary data structures.
Memory Partitioning: TZASC and TZMA
The TrustZone Address Space Controller (TZASC) lives between the bus interconnect and the external DRAM controller. It carves the physical address space into regions, each marked Secure, Non-Secure, or Secure-read/Non-Secure-write. When a bus transaction lands, the TZASC matches the NS bit to the region's configuration and faults the access on a policy violation.
A typical configuration on a mobile SoC might look like:
| Region | Address Range | Security | Purpose |
|---|---|---|---|
| 0 | 0x0000_0000 - 0x3FFF_FFFF | Secure | Secure OS, keys, crypto buffers |
| 1 | 0x4000_0000 - 0x7FFF_FFFF | Non-Secure | Linux kernel and user space |
| 2 | 0x8000_0000 - 0x8FFF_FFFF | Secure | Trusted application memory |
| 3 | 0x9000_0000 - 0xFFFF_FFFF | Non-Secure | Normal-world DMA buffers |
The TrustZone Memory Adapter (TZMA) does the same job for on-chip SRAM, which sidesteps the external memory controller. TZMA splits on-chip SRAM into a Secure region (lower addresses) and a Non-Secure region (upper addresses) at a configurable boundary.
The TZASC protects external DRAM by defining security regions checked against the NS bit on every bus transaction. The TZMA protects on-chip SRAM by splitting it at a programmable boundary. Together, they ensure that Normal-world software cannot access any memory assigned to the Secure world, even via DMA.
Peripheral Partitioning: TZPC
The TrustZone Protection Controller (TZPC) partitions peripherals between the two worlds. Each one can be Secure-only or open to both. If a Normal-world bus master pokes at a Secure-only peripheral, the TZPC kills the transaction and returns a bus error.
Peripherals typically assigned to the Secure world include:
- Cryptographic accelerators: AES, SHA, RSA hardware engines that process key material.
- Hardware random number generators: True random number sources used for key generation.
- One-time programmable (OTP) fuse controllers: Where root keys and secure boot hashes are stored.
- Secure timers and watchdogs: To prevent the Normal world from interfering with Secure-world timing.
Display controllers, USB, and network interfaces stay in the Normal world because the rich OS needs them for everyday work.
Trusted Execution Environments
The Secure world runs a Trusted Execution Environment (TEE) — a tiny, stripped-back operating system for security-critical operations. The two most widely deployed open-source TEEs:
OP-TEE (Open Portable Trusted Execution Environment) is a Linux Foundation project originally built by Linaro and STMicroelectronics. It implements the GlobalPlatform TEE specifications, exposing a standard API for trusted applications (TAs). OP-TEE runs at S-EL1 and hosts multiple TAs at S-EL0, isolating them from each other via memory management.
Trusty is Google's TEE for Android devices. Same S-EL1 perch, hosting trusted apps like KeyMint (hardware-backed key storage, called Keymaster before Android 12), Gatekeeper (PIN/password verification), and Weaver (secure credential storage). On Pixel devices, Trusty mediates between Android and the Titan M security chip.
The GlobalPlatform TEE API
The GlobalPlatform TEE Client API provides a standard interface for Normal-world applications to communicate with trusted applications:
- The client opens a session to a trusted application (identified by UUID).
- The client invokes a command within the session, passing parameters through shared memory buffers.
- The trusted application processes the command in the Secure world.
- Results are returned to the client when the session completes.
The abstraction hides the SMC plumbing from app developers. The TEE driver in the Normal-world kernel turns API calls into SMC invocations.
TrustZone Limitations and Security Concerns
TrustZone delivers strong hardware-enforced isolation. It also comes with architectural limits:
Shared Microarchitectural State
Secure and Normal worlds share the same physical CPU core, which means they share:
- Caches: Both worlds use the same L1 and L2 caches. The NS bit tags lines, but the replacement policy can still leak. A Normal-world attacker can run Prime+Probe or Flush+Reload to glimpse Secure-world cache access patterns.
- TLB (Translation Lookaside Buffer): Shared between worlds. TLB timing channels can betray which virtual addresses the Secure world touched.
- Branch predictor: Branch prediction state is also shared, opening Spectre-style attacks across the world boundary.
These shared resources hand attackers side-channel surfaces that TrustZone's architectural isolation doesn't cover.
The Trusted Computing Base Problem
Everything in the Secure world — the monitor, the TEE OS, every trusted application — can reach every Secure-world resource. A flaw in any TA can hand the whole Secure world to an attacker. The Trusted Computing Base (TCB) is the sum of all that Secure-world code; keeping it small really matters.
Commercial TEEs have hit all of the usual hazards: buffer overflows in trusted applications, logic bugs in the Secure-world kernel, sloppy input validation on SMC calls. Researchers have demonstrated full Secure-world compromise on multiple mobile SoCs. Gal Beniamini's 2015-16 work on Qualcomm's QSEE chained a bug in a trusted application into code execution in the Secure world and then pulled out the key material that protected Android's full-disk encryption. CLKscrew (2017) needed no software bug at all: it drove the phone's frequency and voltage controls, which the Normal-world kernel owns, out of spec to inject faults into TrustZone code and extract an AES key.
No Hardware Memory Encryption
Unlike Intel SGX, baseline TrustZone doesn't encrypt Secure-world memory in DRAM. Anyone with physical access can potentially read it via cold boot, bus probing, or JTAG. ARM's CCA (Confidential Compute Architecture), introduced in ARMv9, attacks the problem from a different angle. Its core is access control (the Granule Protection Table described below); memory encryption arrives through the optional Memory Encryption Contexts (MEC) extension, so whether DRAM contents are encrypted depends on the implementation.
TrustZone protects against software attacks from the Normal world: a compromised OS, malicious applications, or a rogue hypervisor. It does not protect against physical attacks on DRAM, side-channel attacks through shared microarchitectural state, or vulnerabilities within the Secure world's own code. Understanding these boundaries is essential for correctly assessing what TrustZone can and cannot defend against.
TrustZone in Practice: Mobile Security
On a modern Android phone, TrustZone underpins several critical security features:
- Verified Boot: The Secure-world boot ROM verifies the first-stage bootloader. Each subsequent stage verifies the next, anchored by keys in Secure-world OTP fuses.
- KeyMint (Keymaster before Android 12): Hardware-backed key storage. Private keys never leave the Secure world. The Normal-world Android Keystore API hands every cryptographic op to KeyMint inside the TEE.
- Biometric Authentication: Fingerprint matching and face recognition run inside trusted applications. The template and matching algorithm sit in the Secure world, out of reach of the Normal-world OS.
- DRM: Content decryption keys for services like Widevine L1 stay in the Secure world. The encrypted media stream gets decrypted inside the TEE and travels through a secure video path straight to the display controller, never showing up in Normal-world memory as plaintext.
TrustZone hauled mobile security out of the purely-software pit and into a hardware-enforced architecture, laying the foundation every modern smartphone now leans on.
TrustZone Across ARM Versions
TrustZone has evolved across ARM architecture generations:
ARMv7 (32-bit): The original TrustZone. Monitor mode sits as its own processor mode alongside SVC, IRQ, and friends. The Secure world keeps its own banked copies of certain registers (stack pointer, link register, SPSR). The split is coarse — the monitor saves and restores a full register context on every world switch.
ARMv8 (AArch64): TrustZone got redesigned around the Exception Level (EL) model. EL3 is the Secure Monitor, EL2 is the hypervisor (Normal-world only in early versions), EL1 is the OS, EL0 is user space. The Secure world mirrors this: S-EL1 runs the Trusted OS and S-EL0 runs trusted apps. The cleaner layering gives the Secure world its own user/kernel split and its own memory management.
ARMv8.4-A: Introduced Secure EL2 (S-EL2), so you can run a hypervisor inside the Secure world. That lets multiple mutually isolated TEEs share one processor under a Secure-world hypervisor, addressing the monolithic-TCB problem by isolating trusted apps from each other rather than just from the Normal world.
ARMv9 (CCA): The Confidential Compute Architecture expands the two worlds to four: Normal, Secure, Realm and Root. A Realm is a confidential VM walled off from both Normal and Secure worlds, and Root is where the EL3 monitor now lives, above everything else. Realm memory can also be encrypted where the optional MEC extension is implemented. The Realm Management Extension (RME) layers in a Granule Protection Table (GPT) that tags each physical granule with its owning security state. CCA pushes TrustZone toward Intel TDX's confidential-computing model while staying compatible with existing TrustZone infrastructure.