Merge changes from topic "st_mapping_update" into integration

* changes:
  feat(stm32mp1): enable BL2_IN_XIP_MEM to remove relocation sections
  refactor(stm32mp1): reduce MMU memory regions and split XLAT by context
  feat(st): map 2MB for ROM code
  fix(stm32mp1): restrict DEVICE2 mapping in BL2
This commit is contained in:
Madhukar Pappireddy 2022-01-13 23:10:48 +01:00 committed by TrustedFirmware Code Review
commit 97c9114787
7 changed files with 50 additions and 15 deletions

View File

@ -1,13 +1,11 @@
/*
* Copyright (c) 2019, STMicroelectronics - All Rights Reserved
* Copyright (c) 2019-2022, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <errno.h>
#include <platform_def.h>
#include <common/debug.h>
#include <drivers/io/io_storage.h>
#include <drivers/st/bsec.h>
@ -15,6 +13,8 @@
#include <lib/xlat_tables/xlat_tables_v2.h>
#include <plat/common/platform.h>
#include <platform_def.h>
static const struct stm32mp_auth_ops *auth_ops;
void stm32mp_init_auth(struct stm32mp_auth_ops *init_ptr)
@ -47,7 +47,7 @@ int stm32mp_auth_image(boot_api_image_header_t *header, uintptr_t buffer)
}
ret = mmap_add_dynamic_region(STM32MP_ROM_BASE, STM32MP_ROM_BASE,
STM32MP_ROM_SIZE, MT_CODE | MT_SECURE);
STM32MP_ROM_SIZE_2MB_ALIGNED, MT_CODE | MT_SECURE);
if (ret != 0) {
return ret;
}
@ -85,6 +85,6 @@ int stm32mp_auth_image(boot_api_image_header_t *header, uintptr_t buffer)
}
err:
mmap_remove_dynamic_region(STM32MP_ROM_BASE, STM32MP_ROM_SIZE);
mmap_remove_dynamic_region(STM32MP_ROM_BASE, STM32MP_ROM_SIZE_2MB_ALIGNED);
return ret;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -68,6 +68,13 @@
#define BL2_LIMIT (STM32MP_BL2_BASE + \
STM32MP_BL2_SIZE)
#define BL2_RO_BASE STM32MP_BL2_RO_BASE
#define BL2_RO_LIMIT (STM32MP_BL2_RO_BASE + \
STM32MP_BL2_RO_SIZE)
#define BL2_RW_BASE STM32MP_BL2_RW_BASE
#define BL2_RW_LIMIT (STM32MP_BL2_RW_BASE + \
STM32MP_BL2_RW_SIZE)
/*******************************************************************************
* BL32 specific defines.
******************************************************************************/

View File

@ -16,6 +16,7 @@ STM32MP_USE_STM32IMAGE ?= 0
ifneq ($(STM32MP_USE_STM32IMAGE),1)
ENABLE_PIE := 1
BL2_IN_XIP_MEM := 1
endif
STM32_TF_VERSION ?= 0

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -57,7 +57,11 @@ SECTIONS
* The strongest and only alignment contraint is MMU 4K page.
* Indeed as images below will be removed, 4K pages will be re-used.
*/
#if SEPARATE_CODE_AND_RODATA
. = ( STM32MP_BL2_RO_BASE - STM32MP_BINARY_BASE );
#else
. = ( STM32MP_BL2_BASE - STM32MP_BINARY_BASE );
#endif
__BL2_IMAGE_START__ = .;
*(.bl2_image*)
__BL2_IMAGE_END__ = .;

View File

@ -68,6 +68,7 @@
******************************************************************************/
#define STM32MP_ROM_BASE U(0x00000000)
#define STM32MP_ROM_SIZE U(0x00020000)
#define STM32MP_ROM_SIZE_2MB_ALIGNED U(0x00200000)
#define STM32MP_SYSRAM_BASE U(0x2FFC0000)
#define STM32MP_SYSRAM_SIZE U(0x00040000)
@ -110,15 +111,25 @@ enum ddr_type {
(STM32MP_PARAM_LOAD_SIZE + \
STM32MP_HEADER_SIZE))
/* BL2 and BL32/sp_min require 4 tables */
#define MAX_XLAT_TABLES U(4) /* 16 KB for mapping */
/* BL2 and BL32/sp_min require finer granularity tables */
#if defined(IMAGE_BL2)
#define MAX_XLAT_TABLES U(2) /* 8 KB for mapping */
#endif
#if defined(IMAGE_BL32)
#define MAX_XLAT_TABLES U(4) /* 16 KB for mapping */
#endif
/*
* MAX_MMAP_REGIONS is usually:
* BL stm32mp1_mmap size + mmap regions in *_plat_arch_setup
*/
#if defined(IMAGE_BL2)
#define MAX_MMAP_REGIONS 11
#if STM32MP_USB_PROGRAMMER
#define MAX_MMAP_REGIONS 8
#else
#define MAX_MMAP_REGIONS 7
#endif
#endif
#define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x100000))

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021, STMicroelectronics - All Rights Reserved
* Copyright (C) 2021-2022, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -10,9 +10,10 @@
#define STM32MP_DDR_S_SIZE U(0x01E00000) /* 30 MB */
#define STM32MP_DDR_SHMEM_SIZE U(0x00200000) /* 2 MB */
#define STM32MP_BL2_SIZE U(0x0001B000) /* 108 KB for BL2 */
#define STM32MP_BL2_DTB_SIZE U(0x00006000) /* 24 KB for DTB */
#define STM32MP_BL32_SIZE U(0x00019000) /* 100 KB for BL32 */
#define STM32MP_BL2_RO_SIZE U(0x00011000) /* 68 KB */
#define STM32MP_BL2_SIZE U(0x00016000) /* 88 KB for BL2 */
#define STM32MP_BL2_DTB_SIZE U(0x00007000) /* 28 KB for DTB */
#define STM32MP_BL32_SIZE U(0x0001B000) /* 108 KB for BL32 */
#define STM32MP_BL32_DTB_SIZE U(0x00005000) /* 20 KB for DTB */
#define STM32MP_FW_CONFIG_MAX_SIZE PAGE_SIZE /* 4 KB for FCONF DTB */
#define STM32MP_HW_CONFIG_MAX_SIZE U(0x40000) /* 256 KB for HW config DTB */
@ -21,6 +22,15 @@
STM32MP_SEC_SYSRAM_SIZE - \
STM32MP_BL2_SIZE)
#define STM32MP_BL2_RO_BASE STM32MP_BL2_BASE
#define STM32MP_BL2_RW_BASE (STM32MP_BL2_RO_BASE + \
STM32MP_BL2_RO_SIZE)
#define STM32MP_BL2_RW_SIZE (STM32MP_SEC_SYSRAM_BASE + \
STM32MP_SEC_SYSRAM_SIZE - \
STM32MP_BL2_RW_BASE)
#define STM32MP_BL2_DTB_BASE (STM32MP_BL2_BASE - \
STM32MP_BL2_DTB_SIZE)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -82,7 +82,9 @@
static const mmap_region_t stm32mp1_mmap[] = {
MAP_SEC_SYSRAM,
MAP_DEVICE1,
#if STM32MP_RAW_NAND
MAP_DEVICE2,
#endif
{0}
};
#endif