37. DDR memory cipher engine (DDRMCE)

37.1 MCE introduction

DDR memory cipher engine (DDRMCE) defines, in a given address space, one region in DDR-SDRAM with specific security setup (encryption). All system bus traffic going through an encrypted region is managed on-the-fly by the DDRMCE, automatically decrypting reads and encrypting writes if authorized.

In this section, and in this document, MCE acronym is used instead of DDRMCE.

37.2 MCE main features

37.3 MCE implementation

This product includes a single instance of MCE associated to the DDR controller. All traffic going through MCE is filtered by the TrustZone® address space controller for DDR (TZC). Refer to the TZC chapter for details.

MCE peripheral generates interrupts to the Cortex® CPU interrupt controller (mce_it).

37.4 MCE functional description

37.4.1 MCE block diagram

Figure 333 shows the memory cipher engine block diagram, associated with one or more memory interface peripheral.

Figure 333. MCE block diagram

Block diagram of the Memory Cipher Engine (MCE). The MCE block contains internal components: AXI Write Channel IN, filter, bypass, cipher, AXI Write Channel OUT, Registers, master key, AXI Read Channel OUT, filter, bypass, cipher, and AXI Read Channel IN. The AXI Write Channel IN connects to the filter, which connects to the bypass and cipher. The cipher connects to the AXI Write Channel OUT. The AXI Read Channel OUT connects to the filter, which connects to the bypass and cipher. The cipher connects to the AXI Read Channel IN. The Registers and master key are connected to the filter and cipher. The AXI Write Channel OUT and AXI Read Channel IN connect to the Memory I/F. External signals include mce_it (output), AXI (input/output), AHB config port (input/output), -mce_hck (input), and -mce_sck (input).

MSv65284V2

Block diagram of the Memory Cipher Engine (MCE). The MCE block contains internal components: AXI Write Channel IN, filter, bypass, cipher, AXI Write Channel OUT, Registers, master key, AXI Read Channel OUT, filter, bypass, cipher, and AXI Read Channel IN. The AXI Write Channel IN connects to the filter, which connects to the bypass and cipher. The cipher connects to the AXI Write Channel OUT. The AXI Read Channel OUT connects to the filter, which connects to the bypass and cipher. The cipher connects to the AXI Read Channel IN. The Registers and master key are connected to the filter and cipher. The AXI Write Channel OUT and AXI Read Channel IN connect to the Memory I/F. External signals include mce_it (output), AXI (input/output), AHB config port (input/output), -mce_hck (input), and -mce_sck (input).

37.4.2 MCE internal signals

Table 348 describes the user relevant internal signals interfacing the MCE peripheral.

Table 348. MCE internal input/output signals

Signal nameSignal type(1)Description
mce_sckinputAXI input clock
mce_hckinputAHB input clock for MCE
mce_itoutputMCE interrupt request

1. All digital.

37.4.3 MCE programming

Out of reset, or when there is an access to an area not belonging to an enabled region the default region filtering apply, that is any access is granted.

When application needs to use the encrypted region following sequence can be used, for example at boot time.

  1. 1. Application sets a start and end address using MCE_SADDR and MCE_EADDR registers.
  2. 2. Application finalizes the programming by configuring MCE_REGCRx setting up security parameters (encryption). Initializing encryption is detailed in Section 37.4.5
  3. 3. After final check on above configuration application enables the encrypted region, setting BREN bit in MCE_REGCR.

MCE configuration can be fixed until next SoC reset when GLOCK is set in MCE_CR register.

Above application must be privileged if PRIV bit is set in register MCE_PRIVCFGR.

37.4.4 MCE reset and clocks

MCE configuration port is clocked by the AHB bus clock.

MCE system bus interface is clocked by the AXI clock. AHB interface does not need to be clocked for the system bus to be usable.

When MCE is kept under reset, cleartext traffic can go through the system bus. Out of reset default firewall configuration applies, as described in Section 37.4.3.

37.4.5 MCE block cipher encryption mode

Figure 334 details the block cipher implementations in the MCE peripheral.

Figure 334. MCE implementation of block ciphers

Block diagram of MCE implementation of block ciphers. It shows the flow from DerivedKey_IN(i) and Address_i through a key derivation block to a 128-bit key, which then feeds into two consecutive block cipher decryption blocks along with 128-bit Data_IN (plain text i) and Data_IN (plain text i+1) to produce Data_OUT (cipher text i) and Data_OUT (cipher text i+1).

The diagram illustrates the MCE implementation of block ciphers. It shows a sequence of operations:

The diagram is labeled MSv65286V1 in the bottom right corner.

Block diagram of MCE implementation of block ciphers. It shows the flow from DerivedKey_IN(i) and Address_i through a key derivation block to a 128-bit key, which then feeds into two consecutive block cipher decryption blocks along with 128-bit Data_IN (plain text i) and Data_IN (plain text i+1) to produce Data_OUT (cipher text i) and Data_OUT (cipher text i+1).

1. Operation starts from the capture of the address.

Addressi is most significant bits of physical address of block (i) + block (i+1). Result of key derivation primitive can be used for two consecutive 16-byte data words. Since the normal key derivation function is leakage resilient the master key information is protected against side channel attacks (SCA).

MASTER_KEY must be stored in write-only MCE_MKEYRx registers.

Each time a key material has been successfully written in MCE, the following flag is set:

Bypass mode is selected instead of cipher mode if the selected key is not marked as valid with above flags. See ENC bitfield description for details.

A key derivation round takes 15 cycles. A block cipher round takes 11 cycles.

Note: With AES block cipher, writing (encryption) requires 11 extra cycles in order to perform the required key scheduling to obtain the encryption key.

37.4.6 MCE AXI traffic management

MCE includes a special AXI-64 read-write arbitration scheme, designed to speed-up multiple reads. More specifically, when no write is ongoing in MCE the two cipher cores can be allocated to decrypt two reads in parallel. In this case an incoming write request is stalled until the cipher core allocated to writes is free.

Note: Best performances are obtained when transactions are aligned on two 64-bit words. See Section 37.4.5 for details.

37.4.7 MCE encryption disable options

When MCE feature is not available in the product encryption/decryption feature of MCE is not usable. It means that reads (resp. writes) through MCE are not decrypted (resp. encrypted).

37.4.8 MCE error management

When an illegal access to a configuration register occurs (bad privilege) corresponding CAEF bit is set in MCE_IASR. Application cleans this flag using CAEF bit in MCE_IACR.

Read to write-only or write to read-only registers do not trigger an interrupt. Reading any MCE key register returns zeros.

37.5 MCE interrupts

There is one individual maskable interrupt source generated by the MCE, signaling the following error event:

This interrupt source is connected to the same global interrupt request signal mce_it.

Setting the appropriate mask bit in MCE_IAIER register enables the interrupt. The status of the individual interrupt events can be read from MCE_IASR, and cleared in MCE_IACR register.

Table 349 gives a summary of the available features.

Table 349. MCE interrupt requests

Interrupt acronymInterrupt eventEvent flag(1)Enable control bitInterrupt clear method
DDRMCEConfiguration access errorCAEFCAEIESet CAEF bit in MCE_IACR

1. Read in MCE_IASR register

37.6 MCE registers

37.6.1 MCE configuration register (MCE_CR)

Address offset: 0x000

Reset value: 0x0000 0000

Privileged read and write access only if PRIV is set in MCE_PRIVCFGR.

Writes are ignored if GLOCK is set in MCE_CR register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MK LOCKGLOCK
rsrs

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 MKLOCK: Master keys lock

Lock the master key configurations until next reset. This bit is cleared by default and once set it cannot be reset until MCE reset.

0: Writes to MCE_MKEYRx register is allowed

1: Writes to MCE_MKEYRx register is ignored until next MCE reset.

Bit 0 GLOCK: Global lock

Lock the configuration of most MCE registers until next reset. This bit is cleared by default and once set it cannot be reset until MCE reset.

0: MCE registers are writable

1: All writes to MCE registers are ignored, with the exception of MCE_IACR and MCE_IAIER registers.

37.6.2 MCE status register (MCE_SR)

Address offset: 0x004

Reset value: 0x0000 0000

Privileged read access only if PRIV is set in MCE_PRIVCFGR.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MK VALID
r

Bits 31:5 Reserved, must be kept at reset value.

Bit 4 Reserved, must be kept at reset value.

Bit 3 Reserved, must be kept at reset value.

Bit 2 Reserved, must be kept at reset value.

Bit 1 Reserved, must be kept at reset value.

Bit 0 MKVALID: Master key valid

0: A valid key has not been written in MCE_MKEYRx registers

1: A valid key has been written in MCE_MKEYRx registers (write R0 -> R1 -> R2 -> R3 or the reverse)

37.6.3 MCE illegal access status register (MCE_IASR)

Address offset: 0x008

Reset value: 0x0000 0000

Privileged read access only if PRIV is set in MCE_PRIVCFGR.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEF
r

Bits 31:1 Reserved, must be kept at reset value.

Bit 0 CAEF: Configuration access error flag

This bit is set when an illegal access to any MCE configuration register is detected. Bit is cleared by setting corresponding bit in MCE_IACR register. No additional details on the error is available.

37.6.4 MCE illegal access clear register (MCE_IACR)

Address offset: 0x00C

Reset value: 0x0000 0000

Privileged write access only if PRIV is set in MCE_PRIVCFGR.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEF
w

Bits 31:1 Reserved, must be kept at reset value.

Bit 0 CAEF: Configuration access error flag clear

Set this bit to clear CAEF bit in MCE_IASR register.

37.6.5 MCE illegal access interrupt enable register (MCE_IAIER)

Address offset: 0x010

Reset value: 0x0000 0000

Privileged read and write access only if PRIV is set in MCE_PRIVCFGR.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEIE
rw

Bits 31:1 Reserved, must be kept at reset value.

Bit 0 CAEIE: Configuration access error interrupt enable

0: Interrupt generation on configuration access errors is disabled

1: Interrupt generation when a configuration access error occurs (CAEF = 1)

37.6.6 MCE privileged configuration register (MCE_PRIVCFGR)

Address offset: 0x1C

Reset value: 0x0000 0000

Privileged write access only.

Any read is allowed. Writes are ignored if GLOCK is set in MCE_CR register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PRIV
rw

Bits 31:1 Reserved, must be kept at reset value.

Bit 0 PRIV: Privileged configuration

0: Privileged and unprivileged access are granted to MCE registers

1: Only privileged access are granted to MCE registers, excluding ID registers (MCE_HWCFGR1/2, MCE_VERR, MCE_IPIDR, MCE_SIDR)

37.6.7 MCE region configuration register (MCE_REGCR)

Address offset: 0x040

Reset value: 0x0000 0000

Privileged read and write access only if PRIV is set in MCE_PRIVCFGR. Writes are ignored if GLOCK is set in MCE_CR register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
ENCRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.BREN
rwrw

Bits 31:16 Reserved, must be kept at reset value.

Bit 15 ENC: Encrypted region

This bit is taken into account only if BREN is set.

0: No effect

1: All allowed read (resp. write) requests are decrypted (resp. encrypted) using the block cipher. If MKVALID = 0 bypass mode is selected instead.

Bits 14:9 Reserved, must be kept at reset value.

Bits 8:1 Reserved, must be kept at reset value.

Bit 0 BREN: Base region enable

0: Region is disabled. Access control of primary region (privileged or unprivileged, no encryption) applies to any access between this region start and end addresses.

1: Region is enable. Access controls and encryption option defined in this region apply to any access between this region start and end addresses.

BREN cannot be set if BADDRSTART > BADDREND.

37.6.8 MCE start address register (MCE_SADDR)

Address offset: 0x044

Reset value: 0x0000 0000

Privileged read and write access only if PRIV is set in MCE_PRIVCFGR. Writes are ignored if GLOCK is set in MCE_CR register, or if BREN is set in MCE_REGCR.

31302928272625242322212019181716
BADDRSTART[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:16 BADDSTART[31:16]: Region address start

This bitfield defines the absolute start address of the region on 64 Kbyte boundary (inclusive).

BREN cannot be set if BADDRSTART > BADDREND.

When MCE determines the region, the first 16 bits (LSB) and the last 2 bits (MSB) in this register are ignored, and when this register is accessed in read the 2 MSB bits and the 16 LSB bits return zeros (reference value in MCE).

Bits 15:0 Reserved, must be kept at reset value.

37.6.9 MCE end address register (MCE_EADDR)

Address offset: 0x048

Reset value: 0x0000 FFFF

Privileged read and write access only if PRIV is set in MCE_PRIVCFGR. Writes are ignored if GLOCK is set in MCE_CR register, or if BREN is set in MCE_REGCR.

31302928272625242322212019181716
BADDEND[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:16 BADDEND[31:16]: Region address end

This bitfield defines the absolute end address of the region on 64 Kbyte boundary (inclusive).

BREN cannot be set if BADDRSTART > BADDREND.

When MCE determines the region, the first 16 bits (LSB) and the last 2 bits (MSB) in this register are ignored, and when this register is accessed in read the 2 MSB bits return zeros and the 16 LSB bits return ones (reference value in MCE).

Bits 15:0 Reserved, must be kept at reset value.

37.6.10 MCE master key x (MCE_MKEYRx)

Address offset: 0x200 + 0x4 * x, (x = 0 to 3)

Reset value: 0x0000 0000

Privileged write access only if PRIV is set in MCE_PRIVCFGR.

Writes are ignored if MKLOCK or GLOCK bit is set in MCE_CR register.

31302928272625242322212019181716
MKEY{32 * x + i}
wwwwwwwwwwwwwwww
1514131211109876543210
MKEY{32 * x + i}
wwwwwwwwwwwwwwww

Bits 31:0 MKEY{32 * x + i}: Master key bit (i = 0 to 31)

This key is used by the MCE block cipher

37.6.11 MCE hardware configuration register 3 (MCE_HWCFGR3)

Address offset: 0x3E8

Reset value: 0x3B00 0102

31302928272625242322212019181716
CFG8[3:0]CFG7[3:0]CFG6[3:0]CFG5[3:0]
rrrrrrrrrrrrrrrr
1514131211109876543210
CFG4[3:0]CFG3[3:0]CFG2[3:0]CFG1[3:0]
rrrrrrrrrrrrrrrr

Bits 31:28 CFG8[3:0]: Hardware generic 8

This field returns the generic value ooo_enable | interconnect_enable.

Bits 27:24 CFG7[3:0]: Hardware generic 7

This field returns the generic value id_size.

Bits 23:20 CFG6[3:0]: Hardware generic 6

This field returns the generic value priv_enable_axi.

Bits 19:16 CFG5[3:0]: Hardware generic 5

This field returns the generic value rif_enable.

Bits 15:12 CFG4[3:0]: Hardware generic 4

This field returns the generic value sec_enable.

Bits 11:8 CFG3[3:0]: Hardware generic 3

This field returns the generic value priv_enable.

Bits 7:4 CFG2[3:0]: Hardware generic 2

This field returns the generic value nk_core.

Bits 3:0 CFG1[3:0]: Hardware generic 1

This field returns the generic value aes_core.

37.6.12 MCE hardware configuration register 2 (MCE_HWCFGR2)

Address offset: 0x3EC

Reset value: 0x1107 1444

31302928272625242322212019181716
CFG8[3:0]CFG7[3:0]CFG6[3:0]CFG5[3:0]
rrrrrrrrrrrrrrrr
1514131211109876543210
CFG4[3:0]CFG3[3:0]CFG2[3:0]CFG1[3:0]
rrrrrrrrrrrrrrrr

Bits 31:28 CFG8[3:0]: Hardware generic 8

This field returns the generic value nb_breg.

Bits 27:24 CFG7[3:0]: Hardware generic 7

This field returns the generic value nb_mkey.

37.6.13 MCE hardware configuration register 1 (MCE_HWCFGR1)

Address offset: 0x3F0

Reset value: 0x0000 1D10

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.CFG3[7:0]
rrrrrrrr
1514131211109876543210
CFG2[7:0]CFG1[7:0]
rrrrrrrrrrrrrrrr

37.6.14 MCE version register (MCE_VERR)

Address offset: 0x3F4

Reset value: 0x0000 0010

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
MAJREV[3:0]MINREV[3:0]
Res.Res.Res.Res.Res.Res.Res.Res.rrrrrrrr

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:4 MAJREV[3:0]: Major revision

This field returns the MCE major version.

Bits 3:0 MINREV[3:0]: Minor revision

This field returns the MCE minor version.

37.6.15 MCE identification register (MCE_IPIDR)

Address offset: 0x3F8

Reset value: 0x0017 0081

31302928272625242322212019181716
ID[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
ID[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 ID[31:0]: Identification code

This field returns the identification code of the MCE.

37.6.16 MCE size identification register (MCE_SIDR)

Address offset: 0x3FC

Reset value: 0xA3C5 DD01

31302928272625242322212019181716
SID[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
SID[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 SID[31:0]: Size identification code

This field returns the size identification code of the MCE as defined below:

Bits[31:8] = 0xA3C5DD (fixed code)

Bits[7:0] = 0x01 (1 Kbyte address decoding)

37.6.17 MCE register map

Table 350. MCE register map and reset values

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x000MCE_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MKLOCKGLOCK
Reset value00

Table 350. MCE register map and reset values (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x004MCE_SRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MKVALID
Reset value0
0x008MCE_IASRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEF
Reset value0
0x00CMCE_IACRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEF
Reset value0
0x010MCE_IAIERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CAEIE
Reset value
0x01CMCE_PRIVCFGRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PRIV
Reset value0
0x20ReservedRes.
0x040MCE_REGCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ENCRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.BREN
Reset value00
0x044MCE_SADDRBADDSTART[31:16]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000000000000
0x048MCE_EADDRBADDEND[31:16]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000000000000
0x200+0x4 * x, (x = 0 to 3)MCE_MKEYRxMKEY{32 * x + i} (i = 0 to 31)
Reset value00000000000000000000000000000000
0x3E8MCE_HWCFGR3CFG8[3:0]CFG7[3:0]CFG6[3:0]CFG5[3:0]CFG4[3:0]CFG3[3:0]CFG2[3:0]CFG1[3:0]
Reset value00111011000000000000000100000010
0x3ECMCE_HWCFGR2CFG8[3:0]CFG7[3:0]CFG6[3:0]CFG5[3:0]CFG4[3:0]CFG3[3:0]CFG2[3:0]CFG1[3:0]
Reset value00010001000001110001010001000100
0x3F0MCE_HWCFGR3Res.Res.Res.Res.Res.Res.Res.Res.CFG3[7:0]CFG2[7:0]CFG1[7:0]
Reset value000000000001110100010000
0x3F4MCE_VERRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MAJREV[3:0]MINREV[3:0]
Reset value00010000
0x3F8MCE_IPIDRID[31:0]
Reset value00000000000101110000000010000001
0x3FCMCE_SIDRSID[31:0]
Reset value10100011110001011101110100000001

Refer to Section 2.5: Memory organization for the register boundary addresses.

ST logo
ST logo