Description:

 

When booting TF-M 2.3.0 on the STM32U5 platform with TFM_HDP_PROTECT_ENABLE=1, a Secure HardFault occurs in BL2 right before jumping to the primary image. The fault is caused by an instruction fetch error from the hidden memory area because the MPU configuration functions lack the necessary section attributes.

 

Execution Flow & Root Cause:

 

boot_platform_start_next_image() is called.

It invokes LL_SECU_UpdateRunTimeProtections(), which enables the hardware Hide Protection (HDP) firewall. From this point, most of the BL2 flash area becomes unreadable/unexecutable.

It then calls mpu_appli_cfg(). This function is correctly placed outside the firewall using __attribute__((section(".BL2_NoHdp_Code"))).

However, mpu_appli_cfg() calls mpu_armv8m_region_enable() (located in mpu_armv8m_drv.c).

 

BUG: mpu_armv8m_region_enable() does not have the .BL2_NoHdp_Code attribute. Since it resides in the standard .text section hidden by HDP, the CPU immediately throws a HardFault when trying to execute it.

 

Stack Trace:

mpu_appli_cfg @ 0x0c036182

LL_SECU_UpdateRunTimeProtections @ 0x0c03614e

boot_platform_start_next_image @ 0x0c036078

do_boot @ 0x0c014e38

main @ 0x0c01505e

 

Proposed solution:

 

Add __attribute__((section(".BL2_NoHdp_Code")) guarded by #ifdef BL2 to mpu_armv8m_region_enable() and mpu_armv8m_region_enable_check().

 

thank you,

Sławomir Piotrowski