feat(arm): move GPT setup to common BL source

As of now, GPT setup is being handled from BL2 for plat/arm platforms.
However, for platforms having a separate entity to load firmware images,
it is possible for BL31 to setup the GPT. In order to address this
concern, move the GPT setup implementation from arm_bl2_setup.c file to
arm_common.c. Additionally, rename the API from arm_bl2_gpt_setup to
arm_gpt_setup to make it boot stage agnostic.

Signed-off-by: Rohit Mathew <Rohit.Mathew@arm.com>
Change-Id: I35d17a179c8746945c69db37fd23d763a7774ddc
This commit is contained in:
Rohit Mathew 2024-01-21 22:49:08 +00:00
parent 86e4859a05
commit 341df6af6e
4 changed files with 44 additions and 43 deletions

View file

@ -81,7 +81,7 @@ below.
In the reference implementation for FVP models, you can find an example of PAS
region definitions in the file ``plat/arm/board/fvp/include/fvp_pas_def.h``.
Table creation API calls can be found in ``plat/arm/common/arm_bl2_setup.c`` and
Table creation API calls can be found in ``plat/arm/common/arm_common.c`` and
runtime initialization API calls can be seen in
``plat/arm/common/arm_bl31_setup.c``.

View file

@ -375,6 +375,7 @@ unsigned int plat_arm_calc_core_pos(u_register_t mpidr);
const mmap_region_t *plat_arm_get_mmap(void);
const arm_gpt_info_t *plat_arm_get_gpt_info(void);
void arm_gpt_setup(void);
/* Allow platform to override psci_pm_ops during runtime */
const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops);

View file

@ -131,46 +131,6 @@ void bl2_platform_setup(void)
arm_bl2_platform_setup();
}
#if ENABLE_RME
static void arm_bl2_gpt_setup(void)
{
/*
* It is to be noted that any Arm platform that reuses arm_bl2_gpt_setup
* must implement plat_arm_get_gpt_info within its platform code
*/
const arm_gpt_info_t *arm_gpt_info =
plat_arm_get_gpt_info();
if (arm_gpt_info == NULL) {
ERROR("arm_gpt_info not initialized!!\n");
panic();
}
/* Initialize entire protected space to GPT_GPI_ANY. */
if (gpt_init_l0_tables(arm_gpt_info->pps, arm_gpt_info->l0_base,
arm_gpt_info->l0_size) < 0) {
ERROR("gpt_init_l0_tables() failed!\n");
panic();
}
/* Carve out defined PAS ranges. */
if (gpt_init_pas_l1_tables(arm_gpt_info->pgs,
arm_gpt_info->l1_base,
arm_gpt_info->l1_size,
arm_gpt_info->pas_region_base,
arm_gpt_info->pas_region_count) < 0) {
ERROR("gpt_init_pas_l1_tables() failed!\n");
panic();
}
INFO("Enabling Granule Protection Checks\n");
if (gpt_enable() < 0) {
ERROR("gpt_enable() failed!\n");
panic();
}
}
#endif /* ENABLE_RME */
/*******************************************************************************
* Perform the very early platform specific architectural setup here.
* When RME is enabled the secure environment is initialised before
@ -211,7 +171,7 @@ void arm_bl2_plat_arch_setup(void)
enable_mmu_el3(0);
/* Initialise and enable granule protection after MMU. */
arm_bl2_gpt_setup();
arm_gpt_setup();
#else
enable_mmu_el1(0);
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2024, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -241,3 +241,43 @@ const mmap_region_t *plat_get_addr_mmap(void)
{
return plat_arm_mmap;
}
#if ENABLE_RME
void arm_gpt_setup(void)
{
/*
* It is to be noted that any Arm platform that reuses arm_gpt_setup
* must implement plat_arm_get_gpt_info within its platform code
*/
const arm_gpt_info_t *arm_gpt_info =
plat_arm_get_gpt_info();
if (arm_gpt_info == NULL) {
ERROR("arm_gpt_info not initialized!!\n");
panic();
}
/* Initialize entire protected space to GPT_GPI_ANY. */
if (gpt_init_l0_tables(arm_gpt_info->pps, arm_gpt_info->l0_base,
arm_gpt_info->l0_size) < 0) {
ERROR("gpt_init_l0_tables() failed!\n");
panic();
}
/* Carve out defined PAS ranges. */
if (gpt_init_pas_l1_tables(arm_gpt_info->pgs,
arm_gpt_info->l1_base,
arm_gpt_info->l1_size,
arm_gpt_info->pas_region_base,
arm_gpt_info->pas_region_count) < 0) {
ERROR("gpt_init_pas_l1_tables() failed!\n");
panic();
}
INFO("Enabling Granule Protection Checks\n");
if (gpt_enable() < 0) {
ERROR("gpt_enable() failed!\n");
panic();
}
}
#endif /* ENABLE_RME */