6. System security

The STM32MP23/25xx 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.

6.1 Key security features

6.2 Resource isolation framework (RIF)

The resource isolation framework (RIF) is a comprehensive set of hardware blocks designed to enforce and manage the isolation of STM32MP23/25xx 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 8.

Figure 8. RIF principle

Figure 8. RIF principle diagram showing bus-connected masters and slaves with padlock icons indicating access control, alongside colored compartment blocks and a detailed legend explaining masters, dynamic/static slave resources, secure resources, and hardware compartment IDs.

Legend

MSv67821V1

Figure 8. RIF principle diagram showing bus-connected masters and slaves with padlock icons indicating access control, alongside colored compartment blocks and a detailed legend explaining masters, dynamic/static slave resources, secure resources, and hardware compartment IDs.

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

6.2.1 RIF security architecture

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

Figure 9. RIF block diagram

Figure 9. RIF block diagram showing CPUs, DMA, masters connected via RIMU to the system interconnect, communicating with RISA B/F/L units, encryption blocks, memories (Embedded RAM, OCTOSPI, SDRAM), and RISUP protecting peripherals (IAC, GPIO, PWR, RCC, EXTI, IPCC) via RIFSC controller.

Legend

MSv67820V2

Figure 9. RIF block diagram showing CPUs, DMA, masters connected via RIMU to the system interconnect, communicating with RISA B/F/L units, encryption blocks, memories (Embedded RAM, OCTOSPI, SDRAM), and RISUP protecting peripherals (IAC, GPIO, PWR, RCC, EXTI, IPCC) via RIFSC controller.

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

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 6.2.8).

Table 20. 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 20, 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.

6.2.2 RIF access control

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

Figure 10. RIF access control principle

Diagram of Figure 10: RIF access control principle. It depicts the flow of an initial access request with attributes SEC, EXE, PRIV, R/W, and ADDRESS passing vertically through four stages of permission logic: (1) Local access permission Logic (Cortex MPU/MMU) checking EXE, PRIV, R/W, ADDRESS; (2) Local security permission logic (Cortex SAU/MMU) checking SEC, EXE, ADDRESS; (3) RIF logic checking COMPARTMENT ID, SEC, PRIV, R/W, ADDRESS; (4) Execute-only or non-execute ad-hoc permission logic (peripheral level) checking EXE, ADDRESS.

MSv67822V1

Diagram of Figure 10: RIF access control principle. It depicts the flow of an initial access request with attributes SEC, EXE, PRIV, R/W, and ADDRESS passing vertically through four stages of permission logic: (1) Local access permission Logic (Cortex MPU/MMU) checking EXE, PRIV, R/W, ADDRESS; (2) Local security permission logic (Cortex SAU/MMU) checking SEC, EXE, ADDRESS; (3) RIF logic checking COMPARTMENT ID, SEC, PRIV, R/W, ADDRESS; (4) Execute-only or non-execute ad-hoc permission logic (peripheral level) checking EXE, ADDRESS.

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 11.

Figure 11. Accesses to secure memories and peripherals

Diagram illustrating access permissions between Cortex core execution (Secure and Non-secure) and Area declaration in MMU/MPU (Secure and Non-Secure).

The diagram shows the access permissions between Cortex core execution and Area declaration in MMU/MPU. On the left, Cortex core execution is divided into Secure and Non-secure. On the right, Area declaration in MMU/MPU is divided into Secure and Non-Secure. Accesses are shown as arrows between these regions, with red 'X' marks indicating prohibited access.

Legend: (X) Except for data accesses (RISAB only)

MSv67823V1

Diagram illustrating access permissions between Cortex core execution (Secure and Non-secure) and Area declaration in MMU/MPU (Secure and Non-Secure).

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 12. Accesses to secure memories and peripherals

Diagram illustrating access permissions between Cortex core execution (Privileged and Unprivileged) and Area declaration in MMU/MPU (Privileged and Unprivileged).

The diagram shows the access permissions between Cortex core execution and Area declaration in MMU/MPU. On the left, Cortex core execution is divided into Privileged and Unprivileged. On the right, Area declaration in MMU/MPU is divided into Privileged and Unprivileged. Accesses are shown as arrows between these regions, with red 'X' marks indicating prohibited access.

MSv67824V1

Diagram illustrating access permissions between Cortex core execution (Privileged and Unprivileged) and Area declaration in MMU/MPU (Privileged and Unprivileged).

6.2.3 Application interrupt management in RIF

As shown on Figure 8, 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 13 and Table 21 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 13. RIF interrupt connection types

Figure 13. RIF interrupt connection types

The diagram illustrates RIF interrupt connection types between peripherals and two CPUs (CPU#1 and CPU#2) in a dual-CPU context:

On the right side, CPU#1 TrustZone-aware (NVIC or GIC) and CPU#2 TrustZone-aware (NVIC or GIC) receive the IRQ lines. The legend indicates pink lines represent Secure interrupt. Identification code MSv67827V1 is shown at the bottom right.

Figure 13. RIF interrupt connection types

Table 21. 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.

6.2.4 RIF illegal access definition

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

Table 22. 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 23. RIF illegal access definitions (security)

Access type (see Table 22)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 24. RIF illegal access definitions (privilege)

Access type (see Table 22)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 25. 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 22, 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 6.2.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.

6.2.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 12: Illegal access controller (IAC) for more information on the way illegal accesses are managed.

6.2.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 14. Trusted domain chaining principle

Diagram showing two trusted domain chaining principles: one for Cortex-A35 as the runtime trusted domain and another for Cortex-M33 as the runtime trusted domain. It details the flow from boot to application across different security domains (secure, user-A, user-M).

The diagram illustrates two scenarios for trusted domain chaining between Cortex-A35 and Cortex-M33.

Scenario 1: Runtime trusted domain: Cortex-A35

Scenario 2: Runtime trusted domain: Cortex-M33

Legend: A pink box with "XXXX" represents a Trusted domain (TD) application.

Reference: MSv67825V1

Diagram showing two trusted domain chaining principles: one for Cortex-A35 as the runtime trusted domain and another for Cortex-M33 as the runtime trusted domain. It details the flow from boot to application across different security domains (secure, user-A, user-M).

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.

6.2.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 STM32MP23/25xx 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 STM32MP23/25xx devices.

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

6.2.8 Managing security in RIF-aware peripherals

The resources isolated by the RIF core framework defined in Section 6.2.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).

6.2.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 10.3: RISAB implementation (resp. Section 9.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 15. Wake-up CPU principle

Figure 15: Wake-up CPU principle. A sequence diagram showing the interaction between TDCPU, Power manager, and WUCPU. 1. Power manager sends 'Release CPU' to TDCPU. 2. TDCPU sends 'Go to Standby' to Power manager. 3. Power manager sends 'Release CPU' to WUCPU. 4. Power manager sends 'Release CPU' to TDCPU. A 'Cold boot trigger' and 'Wake-up event' are shown as pink lightning bolts. A 'Wake-up CPU preparation sequence' box is crossed out with an X. A 'Wake-up CPU sequence done' box is shown for the WUCPU. A note states 'From here, RIF access rights are restored as before STandby.'
sequenceDiagram
    participant TDCPU
    participant PM as Power manager
    participant WUCPU

    Note over PM: Cold boot trigger
    PM->>TDCPU: Release CPU
    Note over TDCPU: Wake-up CPU preparation sequence (crossed out)
    TDCPU->>PM: Go to Standby
    Note over PM: Wake-up event
    PM->>WUCPU: Release CPU
    Note over WUCPU: Wake-up CPU sequence done
    WUCPU->>PM: Done
    PM->>TDCPU: Release CPU
    Note over TDCPU: From here, RIF access rights are restored as before STandby.
  

MSv67826V1

Figure 15: Wake-up CPU principle. A sequence diagram showing the interaction between TDCPU, Power manager, and WUCPU. 1. Power manager sends 'Release CPU' to TDCPU. 2. TDCPU sends 'Go to Standby' to Power manager. 3. Power manager sends 'Release CPU' to WUCPU. 4. Power manager sends 'Release CPU' to TDCPU. A 'Cold boot trigger' and 'Wake-up event' are shown as pink lightning bolts. A 'Wake-up CPU preparation sequence' box is crossed out with an X. A 'Wake-up CPU sequence done' box is shown for the WUCPU. A note states 'From here, RIF access rights are restored as before STandby.'

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.

6.2.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 9.3: RIFSC implementation), as follows: