5. System security

The STM32MP21xx devices are designed with a comprehensive set of security features, some of which being built on top of the standard Arm TrustZone technology.

This section explains the different security features available on these devices.

5.1 Key security features

5.2 Secure boot

On an application reset, the Cortex-A35 always boots from the start of an on-chip ROM. This ROM code is used to authenticate and decrypt images loaded into the internal memory from an external flash memory, or through FMC, UART, USB, OCTOSPI, or JTAG.

The lifecycle state of the device is represented in the values of specific fuses. Transforming from one lifecycle state to the next always involves blowing fuses. The BootROM acts in accordance with what it finds to be the current lifecycle state.

Lifecycle states can be partitioned into two underlying categories: BSEC-open or BSEC-closed (refer to Section 6.3.7: Lifecycle management for more details). This is determined by hardware on every system reset by examining the state of the lifecycle fuses.

If the hardware determines at power-up that the device is BSEC-open, it immediately enables debug, and disables any access to fused secrets and secure parts of the ROM. This is referred to as non-secure boot. The device is in a BSEC-open lifecycle state at the start of manufacturing. It can be transformed back into a BSEC-open lifecycle state if there is a fault requiring the part to be returned for analysis.

If the hardware determines that the device is BSEC-closed, the debug remains disabled. The secure boot from ROM is then enforced, and the BootROM then consults additional fuses to determine the precise lifecycle state.

Devices are delivered to customers in a BSEC-closed state, so the BootROM execution is enforced.

On a BSEC-closed device, if the secure_boot fuse bit (see Section 7: OTP mapping (OTP)) is still unblown, then the BootROM behavior depends on the BOOTx pin:

BOOTx pins should be set to 0011 or 1010 for "development boot" mode (see datasheet boot sources table).

However, on a BSEC-closed device, once the secure_boot fuse bit is blown, authenticated secure boot is enforced.

STMicroelectronics supplies signing tools to allow customers to create signed and encrypted boot images. The boot image is sometimes referred as an FSBL (first-stage bootloader), or as an uRoT (updatable root-of-trust firmware).

5.3 Secure provisioning

ST supplies customers with an RSSe (Root Security Services extension) code image to implement SFI (secure firmware install) functionality. The BootROM authenticates this RSSe code with a hard-coded public key. ST also provisions an ST-certified device-unique key pair into fuses. When customers receive the device, they can boot the supplied SFI image to securely provision their own keys into fuses. The BootROM uses these keys, whenever it boots, to authenticate and decrypt the customer boot images. The ST-certified device-unique key pair ensures that this provisioning process is secure and counted. This protects against cloning.

The BootROM supports up to eight irreversible revocations of firmware signing keys.

The boot image header contains a constant decrypted by the BootROM using the provisioned firmware encryption key. This derived key is used to decrypt the actual image.

5.4 Resource isolation framework (RIF)

The resource isolation framework (RIF) is a comprehensive set of hardware blocks designed to enforce and manage the isolation of STM32MP21xx hardware resources, like memory and peripherals.

Application software can use RIF to assign hardware resources to dedicated processing environments that are isolated from each other using hardware isolation boundaries. Within these environments masters are assigned to a security domain and can be secure, non-secure, running privileged or unprivileged code, executing from a CPU, an MCU, or a complex hardware subsystem like a multimedia engine.

RIF-protected resources are assigned at boot time (and subsequently locked) or assigned at run-time. Some RIF-protected resources are exclusively assigned, some are shared, and some are unassigned, as shown in Figure 7.

Figure 7. RIF principle

Figure 7. RIF principle diagram showing a hierarchical bus system with masters and slaves. Masters are represented by rounded rectangles (green, blue, red), and slaves by squares (white, blue, red). Lock icons indicate static locking. Triangles represent hardware compartment IDs. A legend explains the symbols: Master (non-secure, secure), Resource (slave) dynamic/static locking, and Secure resource. Hardware compartment IDs are shown as colored triangles.

Legend

MSv67821V1

Figure 7. RIF principle diagram showing a hierarchical bus system with masters and slaves. Masters are represented by rounded rectangles (green, blue, red), and slaves by squares (white, blue, red). Lock icons indicate static locking. Triangles represent hardware compartment IDs. A legend explains the symbols: Master (non-secure, secure), Resource (slave) dynamic/static locking, and Secure resource. Hardware compartment IDs are shown as colored triangles.

Note: In the RIF, a security domain corresponds to a triplet (privilege, secure, compartment ID).

5.4.1 RIF security architecture

The resource isolation framework (RIF) is typically implemented as described in the figure below.

Figure 8. RIF block diagram

Figure 8. RIF block diagram showing the system architecture. Masters (CPU with TrustZone, DMA, TustZone-aware master, Legacy master, CPU no TrustZone) connect to RIMUs, which then connect to the System interconnect. The interconnect connects to RISA blocks (B, F, L), RISUP, and peripheral controllers (GPIO, PWR, RCC, EXTI, IPCC). These lead to memory (SRAM, OCTOSPI, SDRAM) and external devices (flash, SDRAM). A device boundary separates internal components from external devices. A legend defines components and port types.

Legend

MSv67820V2

Figure 8. RIF block diagram showing the system architecture. Masters (CPU with TrustZone, DMA, TustZone-aware master, Legacy master, CPU no TrustZone) connect to RIMUs, which then connect to the System interconnect. The interconnect connects to RISA blocks (B, F, L), RISUP, and peripheral controllers (GPIO, PWR, RCC, EXTI, IPCC). These lead to memory (SRAM, OCTOSPI, SDRAM) and external devices (flash, SDRAM). A device boundary separates internal components from external devices. A legend defines components and port types.

The core components constituting the RIF are summarized below, and in Table 18:

When a peripheral needs a finer-grained filtering (like DMA, GPIO, or RTC), it becomes RIF-aware, implementing the needed resource isolation policy within itself (see Section 5.4.8).

Table 18. Overview of RIF core components

-RIFSCRISAFRISAB
RIMURISUPRISAL
Affecting targetInitiatorTarget
Resource typeFixedVariableFixed
Master portPeripheralAddress space regionsMemory block
Access filteringN/APrivilege, secure, compartment ID
Read/write filteringNoYes
Special featureSemaphoreN/ADelegation

Refer to the following sections for more details:

As shown on Table 18, the access filtering can be, depending on the case:

Depending on the device, a couple of special features are available:

Any RIF configuration of a resource can be locked at boot time.

5.4.2 RIF access control

The RIF access control principle is outlined in the figure below.

Figure 9. RIF access control principle

Figure 9. RIF access control principle diagram showing the flow of an initial access request through four stages of permission logic: (1) Local access permission Logic (Cortex MPU/MMU), (2) Local security permission logic (Cortex SAU/MMU), (3) RIF logic, and (4) Execute-only or non-execute ad-hoc permission logic (peripheral level).

The diagram illustrates the RIF access control principle. It starts with an 'Initial access request toward the interconnect' indicated by a blue arrow. This request passes through a series of permission checks represented by boxes: SEC, EXE, PRIV, R/W, and ADDRESS. The process is divided into four numbered stages by horizontal black lines:

Vertical grey arrows indicate the flow of the access request through these stages. The diagram is labeled MSv67822V1 in the bottom right corner.

Figure 9. RIF access control principle diagram showing the flow of an initial access request through four stages of permission logic: (1) Local access permission Logic (Cortex MPU/MMU), (2) Local security permission logic (Cortex SAU/MMU), (3) RIF logic, and (4) Execute-only or non-execute ad-hoc permission logic (peripheral level).

For Arm Cortex processors, each access to an hardware resource goes through the following steps:

  1. 1. Within the cores, the MPU or MMU performs filtering based on privilege, execute, and read/write criteria.
  2. 2. Still within the cores (when TrustZone is supported), a secure/non-secure access control is done, sometimes taking into account whether access is instruction or data.
  3. 3. The RIF verifies that the access is granted based on the compartment ID of the access initiator. Additional controls based on secure and privileged properties are also performed. Read/write extra control is supported for some RIF resources (such as embedded memory pages).
  4. 4. Finally, some resources performs extra-filtering like no-execute on banks of registers.

Accessing secure memories and peripherals

An application executing in non-secure state can only access non-secure memories and peripherals. An application executing in secure state can access both secure and non-secure memories and peripherals.

In the latter case, there is an important rule to follow: A secure application must access a non-secure memory or peripheral through a non-secure alias in the MMU/MPU table, as explained in Figure 10.

Figure 10. Accesses to secure memories and peripherals

Diagram showing access paths between Cortex core execution (Secure and Non-secure) and memory/peripherals (Secure peripheral, Non-secure peripheral, Non-secure memory) via MMU/MPU area declarations. Red X marks indicate prohibited access paths.

The diagram illustrates access permissions between Cortex core execution and system resources. On the left, 'Cortex core execution' is split into 'Secure' and 'Non-secure' modes. On the right, resources are categorized as 'Secure peripheral', 'Non-secure peripheral', and 'Non-secure memory'. Access is mediated by 'Area declaration in MMU/MPU' blocks. - From Secure execution to Secure resources: Allowed. - From Secure execution to Non-secure resources: Prohibited (marked with red X). - From Non-secure execution to Secure resources: Prohibited (marked with red X). - From Non-secure execution to Non-secure resources: Allowed. - From Non-secure execution to Secure resources via a non-secure alias: Allowed (indicated by a path through the Non-Secure MMU/MPU block to the Secure peripheral/memory). - A note specifies: '(*) Except for data accesses (RISAB only)'.

Diagram showing access paths between Cortex core execution (Secure and Non-secure) and memory/peripherals (Secure peripheral, Non-secure peripheral, Non-secure memory) via MMU/MPU area declarations. Red X marks indicate prohibited access paths.

MSv67823V1

More specifically, when a secure application wants to write data to the non-secure world, the secure data access is transformed automatically by the core into a non-secure data access, as the target region is mapped into a non-secure space in the MMU (Cortex-A) or SAU/IDAU (Cortex-M).

Note: This secure to non-secure conversion is also supported by the DMA, under the supervision of a secure application.

The RISAB supports the option of deactivating the secure read/write illegal access to non-secure memory (see SRWIAD bit in RISAB_CR).

Mapping peripherals in two address spaces (secure and non-secure) is optional for Cortex-A.

Accessing privileged memories and peripherals

An application executing in unprivileged state can only access unprivileged memories and peripherals. An application executing in privileged state can access both privileged and unprivileged memories and peripherals. Unlike with security, a privileged application can always access an unprivileged memory or peripheral, as shown in the figure below.

Figure 11. Accesses to secure memories and peripherals

Diagram showing access paths between Cortex core execution (Privileged and Unprivileged) and memory/peripherals (Privileged peripheral, Unprivileged peripheral, Privileged memory) via MMU/MPU area declarations. Red X marks indicate prohibited access paths.

The diagram illustrates access permissions between Cortex core execution and system resources based on privilege. On the left, 'Cortex core execution' is split into 'Privileged' and 'Unprivileged' modes. On the right, resources are categorized as 'Privileged peripheral', 'Unprivileged peripheral', and 'Privileged memory'. Access is mediated by 'Area declaration in MMU/MPU' blocks. - From Privileged execution to Privileged resources: Allowed. - From Privileged execution to Unprivileged resources: Allowed. - From Unprivileged execution to Privileged resources: Prohibited (marked with red X). - From Unprivileged execution to Unprivileged resources: Allowed.

Diagram showing access paths between Cortex core execution (Privileged and Unprivileged) and memory/peripherals (Privileged peripheral, Unprivileged peripheral, Privileged memory) via MMU/MPU area declarations. Red X marks indicate prohibited access paths.

MSv67824V1

5.4.3 Application interrupt management in RIF

As shown on Figure 7, a secure application can allocate or deallocate any resource to any compartment thanks to the RIF. The interrupt infrastructure between peripherals and CPU/MCUs must take into account this flexibility, with each compartment being able to see only the interrupt events of the resources allocated to its CPU/MCU.

Figure 12 and Table 19 describe the various interrupt management options in a dual-CPU context.

Note: When the compartment filtering is disabled (CFEN = 0), the interrupts are broadcasted to all CPU/MCUs. When a peripheral is not allocated to any compartment (CFEN = 1, SEM_EN = 1, and SEM_MUTEX = 0), no CPU/MCUs receive interrupts from this peripheral.

Figure 12. RIF interrupt connection types

Diagram showing RIF interrupt connection types between peripherals and two CPUs (CPU#1 and CPU#2) in a dual-CPU context. It illustrates various interrupt paths including RISUP, IRQ_GB, IRQA, IRQB, and IRQC, with a legend for secure interrupts.

The diagram illustrates the interrupt connection types between peripherals and two CPUs (CPU#1 and CPU#2) in a dual-CPU context. It is divided into four main sections labeled P1, P2, P3, and P4.

A legend at the bottom indicates that a pink line represents a 'Secure interrupt'. The diagram also shows 'CPU#1_IRQx' and 'CPU#2_IRQx' as the final interrupt lines for each CPU. The CPUs are labeled 'CPU#1 TrustZone-aware' and 'CPU#2 TrustZone-aware', each containing 'NVIC or GIC'.

Diagram showing RIF interrupt connection types between peripherals and two CPUs (CPU#1 and CPU#2) in a dual-CPU context. It illustrates various interrupt paths including RISUP, IRQ_GB, IRQA, IRQB, and IRQC, with a legend for secure interrupts.

MSv67827V1

Table 19. Interrupt connection types

Peripheral typeRIF aware(1)Global IT(2)Secure/non-secure ITInterrupt events destination
P1NoYesNoThe allocated CPU, for all events (secure and non-secure)
P2YesYes
P3
P4Yes(3)NoNoThe CPU concerned by its specific events (secure or non-secure, according to event resource setup)
  1. 1. If yes, the peripheral is RIF-aware. It manages resources that are associated to more than one CID.
  2. 2. If yes, a single interrupt line captures all the interrupt events.
  3. 3. Any interrupt status bit in this peripheral must be readable only by the correct CPU in the correct security and privileged mode.

Note: The debug domain does not manage interrupts.

5.4.4 RIF illegal access definition

When RIF access control is enforced, illegal access events are defined in following tables.

Table 20. Access-type definitions for Arm TrustZone cores

Processing environmentCore accessMPU(1)/MMU setupAccess type
SecureDataSecureSecure
Non-secureNon-secure
InstructionSecureSecure
Non-secureDenied(2)
Non-secureDataSecureDenied(2)
Non-secureNon-secure
InstructionSecureDenied(2)
Non-secureNon-secure
  1. 1. Actual configuration in Cortex-M33 is done as a mix of programmable SAU and fixed IDAU.
  2. 2. A fault is triggered within the core.

Table 21. RIF illegal access definitions (security)

Access type (see Table 20)Memory resourcePeripheral resource
SecureNon-secureSecureNon-secure
SecureDataOKSilent fail(1)(2)OKOK
Non-secureSilent fail(2)OKSilent fail(2)OK
SecureInstructionOKBus errorBus errorBus error
Non-secureBus errorOKBus errorBus error
  1. 1. Always OK for debug domain. Configurable as OK for any compartment if SRWIAD = 1 in RISAB_CR.
  2. 2. Secure illegal access event, also triggered toward the IAC.

Table 22. RIF illegal access definitions (privilege)

Access type (see Table 20)Memory resourcePeripheral resource
PrivilegedUnprivilegedPrivilegedUnprivileged
PrivilegedDataOKOKOKOK
UnprivilegedSilent fail(1)OKSilent fail(1)OK
PrivilegedInstructionOKOKBus errorBus error
UnprivilegedBus errorOKBus errorBus error

1. Privileged illegal access event, also triggered toward the IAC.

Table 23. RIF illegal access definitions (compartments)

Access typeMemory resourcePeripheral resource
CID1CID2CID1CID2
CID1DataOKSilent fail(1)OKSilent fail(1)
CID2Silent fail(1)OKSilent fail(1)OK
CID1InstructionOKBus error(1)Bus errorBus error
CID2Bus error(1)OKBus errorBus error

1. Compartment illegal access event, also triggered toward the IAC.

As shown in Table 20, for a core executing in a TrustZone secure processing environment, the memory and peripheral resources must be mapped into a secure space.

A silent fail is defined as read as zero (for data reads) and write ignored (for writes).
An illegal access signaling to the IAC usually also occurs (see Section 5.4.5).

A bus error is defined as read as zero and generation of an error on the system bus, so that the Cortex core can get the fault address. Bus errors do not raise any error flags in the device.

Note: A read as zero (RaZ) answer to an illegal instruction fetch also generates an HardFault in Cortex cores, because when decoding all-zero instruction code, the core triggers an HardFault exception.

Events not generating an illegal access

When a valid access tries to read (resp. write) to a read-only (resp. write-only) register protected by RIF, the access is denied (RaZ/write ignored), without the generation of an illegal access.

During a register read (resp. write) access, if at least one bitfield is not read (resp. write) xx-protected, meaning that at least one bitfield can be read (resp. written), then the output signal xx_ilac is not asserted (xx = sec, priv or cid).

For legacy peripherals protected by RISUP, no compartment access error is triggered when the semaphore is taken via one of RISC_PERY_SEMCR registers, unless the compartment of this access is not part of the white-listed compartments.

5.4.5 Managing illegal accesses with RIF

The RIF components do not use the standard interrupt lines toward NVIC or GIC concentrators. The IAC, captures all RIF interrupt events, called illegal access events.

Such events are triggered in the following cases:

See Section 11: Illegal access controller (IAC) for more information on the way illegal accesses are managed.

5.4.6 RIF special security domain: trusted domain

In the RIF, a master with a security domain that equals to secure, privileged, and CID = TDCID, is part of a special domain called the trusted domain. Such a master is initialized as part of the trusted boot in order to manage the critical RIF configuration.

The trusted domain compartment TDCID is fixed by default to 0x1, and is stored in RIMC_CR. The default TDCID corresponds to the boot ROM executing on Cortex-A35.

The devices support two trusted domain scenarios, shown in the figure below.

Figure 13. Trusted domain chaining principle

Diagram showing trusted domain chaining principle for Cortex-A35 and Cortex-M33. It illustrates two scenarios: one where TDCID is kept on Cortex-A35 and another where it is passed to Cortex-M33. The diagram shows the boot and runtime sequences for both cores, including Immutable Root-of-Trust (RoT), Updateable RoT, TD init, and user-level boots (user-A and user-M) leading to CPU and MCU applications.

The diagram is divided into two main sections: 'Runtime trusted domain: Cortex-A35' and 'Runtime trusted domain: Cortex-M33'.

Runtime trusted domain: Cortex-A35

Runtime trusted domain: Cortex-M33

Legend: (XXXX) Trusted domain (TD) application

Reference: MSv67825V1

Diagram showing trusted domain chaining principle for Cortex-A35 and Cortex-M33. It illustrates two scenarios: one where TDCID is kept on Cortex-A35 and another where it is passed to Cortex-M33. The diagram shows the boot and runtime sequences for both cores, including Immutable Root-of-Trust (RoT), Updateable RoT, TD init, and user-level boots (user-A and user-M) leading to CPU and MCU applications.

In the first scenario, a typical chain of trust executes on the default trusted CPU (Cortex-A35 secure privileged). In the second scenario, after securely installing MCU firmware in the embedded SRAM, the Cortex-A35 transfers the trusted domain ownership to the Cortex-M33 secure privileged, by setting TDCID = 0x2 in RIMC_CR.

Note: A TDCID transfer is possible only once.

5.4.7 RIF special security domain: debug domain

In the RIF, a privileged master with CID = DDCID, is part of a special domain called the debug domain. Such a master (usually a DAP peripheral) is initialized as part of the trusted boot to manage the debugging of a RIF protected device.

Note: In the STM32MP21xx devices, DDCID is fixed to value 0x7.

The debugging tools with debug domain access rights (privileged, DDCID) can access to all peripheral and memory resources in the device, if their security level is sufficient.

More specifically:

Note: The debug domain master is always privileged.

When the debug domain is activated, DDEN = 1 in RIMC_CR. It is always activated in STM32MP21xx devices.

The debugging tool access right setup by trusted application is detailed in Section 6.3.11: BSEC debug and trace control. For more information on RIF debug access port security, see Section 8: Resource isolation framework security controller (RIFSC).

5.4.8 Managing security in RIF-aware peripherals

The resources isolated by the RIF core framework defined in Section 5.4.1 are peripherals, fixed-sized embedded memory blocks, and variable-sized address space regions.

As a RIF framework extension, additional resources are available in this device (see corresponding sections for more details).

5.4.9 Activating RIF security

RIF state following a system reset

After a general reset (POR, power-on reset), all non RIF-aware peripherals become non-secure and unprivileged (RISC_SECCFGRx and RISC_PRIVCFGRx are zeroed).

For embedded SRAM protected by RISAB (resp. RISAL), default values are defined in Section 9.3: RISAB implementation (resp. Section 8.3: RIFSC implementation).

Address spaces protected by RISAF are by default secure, privileged, and TDCID only.

Note: Out-of-reset compartment-based filtering is bypassed only for peripherals and for memories protected by RISAB.

RIF wake-up from standby

When the device leaves the Standby state (see PWR), the RIF allows the Cortex-M33 to execute a RIF restoration sequence, temporarily upgrading CID = 0x2 as TDCID in RIFSC_RIMC.

Note: When the wake-up CPU option is enabled, the TDCID information out of reset from RIFSC is not RIFSC_RIMC_CR default value 0x1 (Cortex-A35), but the wake-up CID value 0x2 (Cortex-M33).

A typical wake-up CPU sequence is described in the figure below.

Figure 14. Wake-up CPU principle

Sequence diagram showing the wake-up CPU principle between TDCPU, Power manager, and WUCPU. It includes steps for cold boot trigger, wake-up event, and CPU release sequences.

The diagram illustrates the wake-up CPU principle across three components: TDCPU, Power manager, and WUCPU. 1. TDCPU: Starts with a 'Cold boot trigger' (pink lightning bolt). It then performs a 'Wake-up CPU preparation sequence' (yellow box, step 1). 2. Power manager: Receives a 'Release CPU' signal from TDCPU. It then triggers a 'Wake-up event' (pink lightning bolt). 3. WUCPU: Receives a 'Release CPU' signal from the Power manager. It performs a 'Wake-up CPU sequence done' (yellow box, step 3). 4. Power manager: Sends a 'Release CPU' signal back to TDCPU. 5. TDCPU: Executes a sequence (step 4) where 'RIF access rights are restored as before STandby' (yellow box). A 'Go to Standby' signal from TDCPU to the Power manager is crossed out with a large 'X', indicating it is not part of this wake-up sequence. The diagram is labeled MSv67826V1 in the bottom right corner.

Sequence diagram showing the wake-up CPU principle between TDCPU, Power manager, and WUCPU. It includes steps for cold boot trigger, wake-up event, and CPU release sequences.

The main steps are detailed below:

  1. 1. The trusted CPU executes following a cold boot trigger. The RIF is properly initialized while the applications are installed in the device.
  1. 2. The trusted CPU configures the device to allow the Cortex-M33 to quickly restore the context that is lost in Standby state. Following steps are expected:
    • – Store restoration firmware in RETRAM, writing reference CRC in RAMCFG.
    • – Set up wake-up event mode in the RCC, and adapt the EXTI2 configuration accordingly. The trusted domain also sets in the RCC, the necessary configuration to have wu_cpuen signal to RIFSC set.
    • – Enable automatic CRC and ECC protection in RAMCFG.
  2. 3. When a wake-up event occurs, the Cortex-M33 executes restoration firmware stored in the RETRAM, if CRC is correct and if no double-error detection (DED) occurred on the RETRAM. By hardware, WUCEN is also set in RIMC_SR. At the end of the restoration sequence, the Cortex-M33 sets WUCDONE in RIMC_CR. The TDCID value goes back to the original one, stored in RIMC_CR.
  3. 4. The power manager releases the CPUs to wake up. The device is fully functional.

5.4.10 Programming of RIFSC, RCC and IAC

In order to properly program the RISUP and the RCC, and to read back illegal access information in the IAC, refer to the peripheral index tables (in Section 8.3: RIFSC implementation), as follows: