From f079e6638faedbb95068857ed8cbba948622e83d Mon Sep 17 00:00:00 2001 From: Jaxson Han Date: Tue, 31 Aug 2021 14:14:03 +0800 Subject: [PATCH] scripts: Add align for empty _app_smem region When _app_smem region is empty, alignment is also needed. If there is no alignment, the _app_smem_start used by arm mpu can be lower than __rodata_region_end, and this two regions can overlap. The Armv8-R aarch64 MPU does not allow overlapped regions. Signed-off-by: Jaxson Han --- include/arch/arm64/scripts/linker.ld | 10 ++++++++++ scripts/gen_app_partitions.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/include/arch/arm64/scripts/linker.ld b/include/arch/arm64/scripts/linker.ld index 8ff175c87ac..36004ce7b56 100644 --- a/include/arch/arm64/scripts/linker.ld +++ b/include/arch/arm64/scripts/linker.ld @@ -218,6 +218,16 @@ SECTIONS #define APP_SHARED_ALIGN . = ALIGN(_region_min_align); #define SMEM_PARTITION_ALIGN(size) MMU_ALIGN +#if defined(CONFIG_ARM_MPU) +/* + * When _app_smem region is empty, alignment is also needed. If there + * is no alignment, the _app_smem_start used by arm mpu can be lower + * than __rodata_region_end, and this two regions can overlap. + * The Armv8-R aarch64 MPU does not allow overlapped regions. + */ +#define EMPTY_APP_SHARED_ALIGN APP_SHARED_ALIGN +#endif + #include _app_smem_size = _app_smem_end - _app_smem_start; diff --git a/scripts/gen_app_partitions.py b/scripts/gen_app_partitions.py index 9cb903880ef..b0e80f03f49 100644 --- a/scripts/gen_app_partitions.py +++ b/scripts/gen_app_partitions.py @@ -90,6 +90,9 @@ linker_end_seq = """ empty_app_smem = """ SECTION_PROLOGUE(_APP_SMEM{1}_SECTION_NAME,,) {{ +#ifdef EMPTY_APP_SHARED_ALIGN + EMPTY_APP_SHARED_ALIGN; +#endif _app_smem{0}_start = .; _app_smem{0}_end = .; }} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)