From 104ec53ed1a86510ba12e50826c87f7db616f3bc Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Wed, 26 Feb 2025 12:01:54 +0100 Subject: [PATCH 1/2] refactor(stm32mp2): remove useless STM32MP_SEC_SYSRAM_SIZE The macro STM32MP_SEC_SYSRAM_SIZE only redefine STM32MP_SYSRAM_SIZE. Directly use the latter one and remove the STM32MP_SEC_SYSRAM_SIZE. Signed-off-by: Yann Gautier Change-Id: I9cca19fda7294be3f31ec74293ce122037541d12 --- plat/st/stm32mp2/include/platform_def.h | 4 ++-- plat/st/stm32mp2/stm32mp2_def.h | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plat/st/stm32mp2/include/platform_def.h b/plat/st/stm32mp2/include/platform_def.h index e720c02c9..d3167af20 100644 --- a/plat/st/stm32mp2/include/platform_def.h +++ b/plat/st/stm32mp2/include/platform_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved + * Copyright (c) 2023-2025, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: BSD-3-Clause */ @@ -74,7 +74,7 @@ * BL31 specific defines. ******************************************************************************/ #define BL31_BASE 0 -#define BL31_LIMIT (STM32MP_SEC_SYSRAM_SIZE / 2) +#define BL31_LIMIT (STM32MP_SYSRAM_SIZE / 2) /******************************************************************************* * BL33 specific defines. diff --git a/plat/st/stm32mp2/stm32mp2_def.h b/plat/st/stm32mp2/stm32mp2_def.h index b44150212..2b21178ad 100644 --- a/plat/st/stm32mp2/stm32mp2_def.h +++ b/plat/st/stm32mp2/stm32mp2_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved + * Copyright (c) 2023-2025, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: BSD-3-Clause */ @@ -76,8 +76,6 @@ #define RETRAM_BASE U(0x0E080000) #define RETRAM_SIZE U(0x00020000) -#define STM32MP_SEC_SYSRAM_SIZE STM32MP_SYSRAM_SIZE - /* DDR configuration */ #define STM32MP_DDR_BASE U(0x80000000) #define STM32MP_DDR_MAX_SIZE UL(0x100000000) /* Max 4GB */ @@ -113,7 +111,7 @@ enum ddr_type { #define STM32MP_BL2_SIZE U(0x00029000) /* 164 KB for BL2 */ /* Allocate remaining sysram to BL31 Binary only */ -#define STM32MP_BL31_SIZE (STM32MP_SEC_SYSRAM_SIZE - \ +#define STM32MP_BL31_SIZE (STM32MP_SYSRAM_SIZE - \ STM32MP_BL2_SIZE) #define BL31_PROGBITS_LIMIT STM32MP_BL31_SIZE From ac9abe7e597b1c5712a449b4a2366c859621e435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20M=C3=A9r=C3=A9?= Date: Tue, 10 Dec 2024 10:55:58 +0100 Subject: [PATCH 2/2] feat(stm32mp2): disable PIE by default on STM32MP2 platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow to disable ENABLE_PIE on STM32MP2. BL31 is loaded at the beginning of SYSRAM whatever the options set. Set ENABLE_PIE to 0 by default. This should allow us to reduce BL31 and BL2 size. Change-Id: Ie8c83c9205e81301eb1fdcf24b94216172586630 Signed-off-by: Maxime Méré --- plat/st/stm32mp2/include/platform_def.h | 9 ++++++++- plat/st/stm32mp2/platform.mk | 7 +++++-- plat/st/stm32mp2/stm32mp2_def.h | 2 -- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plat/st/stm32mp2/include/platform_def.h b/plat/st/stm32mp2/include/platform_def.h index d3167af20..523f9bb51 100644 --- a/plat/st/stm32mp2/include/platform_def.h +++ b/plat/st/stm32mp2/include/platform_def.h @@ -73,8 +73,15 @@ /******************************************************************************* * BL31 specific defines. ******************************************************************************/ +#if ENABLE_PIE #define BL31_BASE 0 -#define BL31_LIMIT (STM32MP_SYSRAM_SIZE / 2) +#else +#define BL31_BASE STM32MP_SYSRAM_BASE +#endif + +#define BL31_LIMIT (BL31_BASE + (STM32MP_SYSRAM_SIZE / 2)) + +#define BL31_PROGBITS_LIMIT (BL31_BASE + STM32MP_BL31_SIZE) /******************************************************************************* * BL33 specific defines. diff --git a/plat/st/stm32mp2/platform.mk b/plat/st/stm32mp2/platform.mk index a9f8d8fac..d5e278540 100644 --- a/plat/st/stm32mp2/platform.mk +++ b/plat/st/stm32mp2/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved +# Copyright (c) 2023-2025, STMicroelectronics - All Rights Reserved # # SPDX-License-Identifier: BSD-3-Clause # @@ -11,9 +11,12 @@ STM32_EXTRA_PARTS := 6 include plat/st/common/common.mk CRASH_REPORTING := 1 -ENABLE_PIE := 1 +# Disable PIE by default. To re-enable it, uncomment next line. +#ENABLE_PIE := 1 PROGRAMMABLE_RESET_ADDRESS := 1 +ifeq ($(ENABLE_PIE),1) BL2_IN_XIP_MEM := 1 +endif STM32MP_BL33_EL1 ?= 1 ifeq ($(STM32MP_BL33_EL1),1) diff --git a/plat/st/stm32mp2/stm32mp2_def.h b/plat/st/stm32mp2/stm32mp2_def.h index 2b21178ad..3e60cad2b 100644 --- a/plat/st/stm32mp2/stm32mp2_def.h +++ b/plat/st/stm32mp2/stm32mp2_def.h @@ -114,8 +114,6 @@ enum ddr_type { #define STM32MP_BL31_SIZE (STM32MP_SYSRAM_SIZE - \ STM32MP_BL2_SIZE) -#define BL31_PROGBITS_LIMIT STM32MP_BL31_SIZE - #define STM32MP_BL2_BASE (STM32MP_SYSRAM_BASE + \ STM32MP_SYSRAM_SIZE - \ STM32MP_BL2_SIZE)