juno: Move BL3-1 arguments from normal DRAM to trusted RAM

On Juno, BL3-1 arguments used to sit at the beginning of the normal
DRAM. This patch moves them in trusted RAM. BL2 now allocates them
as a platform-specific static variable. BL3-1 then copies them
internally before the MMU is enabled.

Change-Id: I5cf526edfab5b49925b685092ff78506a5882f49
This commit is contained in:
Sandrine Bailleux 2014-06-05 17:37:22 +01:00
parent ae4ed84bb1
commit 4be58a282d
3 changed files with 37 additions and 46 deletions

View File

@ -76,11 +76,9 @@ __attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
section("tzfw_coherent_mem"))); section("tzfw_coherent_mem")));
/******************************************************************************* /*******************************************************************************
* Reference to structures which holds the arguments which need to be passed * Structure which holds the arguments which need to be passed to BL3-1
* to BL31
******************************************************************************/ ******************************************************************************/
static bl31_params_t *bl2_to_bl31_params; static bl2_to_bl31_params_mem_t bl31_params_mem;
static entry_point_info_t *bl31_ep_info;
meminfo_t *bl2_plat_sec_mem_layout(void) meminfo_t *bl2_plat_sec_mem_layout(void)
{ {
@ -98,46 +96,41 @@ meminfo_t *bl2_plat_sec_mem_layout(void)
******************************************************************************/ ******************************************************************************/
bl31_params_t *bl2_plat_get_bl31_params(void) bl31_params_t *bl2_plat_get_bl31_params(void)
{ {
bl2_to_bl31_params_mem_t *bl31_params_mem; bl31_params_t *bl2_to_bl31_params;
/* /*
* Allocate the memory for all the arguments that needs to * Initialise the memory for all the arguments that needs to
* be passed to BL31 * be passed to BL3-1
*/ */
bl31_params_mem = (bl2_to_bl31_params_mem_t *)PARAMS_BASE; memset(&bl31_params_mem, 0, sizeof(bl2_to_bl31_params_mem_t));
memset((void *)PARAMS_BASE, 0, sizeof(bl2_to_bl31_params_mem_t));
/* Assign memory for TF related information */ /* Assign memory for TF related information */
bl2_to_bl31_params = &bl31_params_mem->bl31_params; bl2_to_bl31_params = &bl31_params_mem.bl31_params;
SET_PARAM_HEAD(bl2_to_bl31_params, PARAM_BL31, VERSION_1, 0); SET_PARAM_HEAD(bl2_to_bl31_params, PARAM_BL31, VERSION_1, 0);
/* Fill BL31 related information */ /* Fill BL3-1 related information */
bl31_ep_info = &bl31_params_mem->bl31_ep_info; bl2_to_bl31_params->bl31_image_info = &bl31_params_mem.bl31_image_info;
bl2_to_bl31_params->bl31_image_info = &bl31_params_mem->bl31_image_info;
SET_PARAM_HEAD(bl2_to_bl31_params->bl31_image_info, PARAM_IMAGE_BINARY, SET_PARAM_HEAD(bl2_to_bl31_params->bl31_image_info, PARAM_IMAGE_BINARY,
VERSION_1, 0); VERSION_1, 0);
/* Fill BL32 related information if it exists */ /* Fill BL3-2 related information if it exists */
if (BL32_BASE) { #if BL32_BASE
bl2_to_bl31_params->bl32_ep_info = bl2_to_bl31_params->bl32_ep_info = &bl31_params_mem.bl32_ep_info;
&bl31_params_mem->bl32_ep_info; SET_PARAM_HEAD(bl2_to_bl31_params->bl32_ep_info, PARAM_EP,
SET_PARAM_HEAD(bl2_to_bl31_params->bl32_ep_info, VERSION_1, 0);
PARAM_EP, VERSION_1, 0); bl2_to_bl31_params->bl32_image_info = &bl31_params_mem.bl32_image_info;
bl2_to_bl31_params->bl32_image_info = SET_PARAM_HEAD(bl2_to_bl31_params->bl32_image_info, PARAM_IMAGE_BINARY,
&bl31_params_mem->bl32_image_info; VERSION_1, 0);
SET_PARAM_HEAD(bl2_to_bl31_params->bl32_image_info, #endif
PARAM_IMAGE_BINARY,
VERSION_1, 0);
}
/* Fill BL33 related information */ /* Fill BL3-3 related information */
bl2_to_bl31_params->bl33_ep_info = &bl31_params_mem->bl33_ep_info; bl2_to_bl31_params->bl33_ep_info = &bl31_params_mem.bl33_ep_info;
SET_PARAM_HEAD(bl2_to_bl31_params->bl33_ep_info, SET_PARAM_HEAD(bl2_to_bl31_params->bl33_ep_info,
PARAM_EP, VERSION_1, 0); PARAM_EP, VERSION_1, 0);
/* UEFI expects to receive the primary CPU MPID (through x0) */ /* UEFI expects to receive the primary CPU MPID (through x0) */
bl2_to_bl31_params->bl33_ep_info->args.arg0 = PRIMARY_CPU; bl2_to_bl31_params->bl33_ep_info->args.arg0 = PRIMARY_CPU;
bl2_to_bl31_params->bl33_image_info = &bl31_params_mem->bl33_image_info; bl2_to_bl31_params->bl33_image_info = &bl31_params_mem.bl33_image_info;
SET_PARAM_HEAD(bl2_to_bl31_params->bl33_image_info, PARAM_IMAGE_BINARY, SET_PARAM_HEAD(bl2_to_bl31_params->bl33_image_info, PARAM_IMAGE_BINARY,
VERSION_1, 0); VERSION_1, 0);
@ -150,7 +143,7 @@ bl31_params_t *bl2_plat_get_bl31_params(void)
******************************************************************************/ ******************************************************************************/
struct entry_point_info *bl2_plat_get_bl31_ep_info(void) struct entry_point_info *bl2_plat_get_bl31_ep_info(void)
{ {
return bl31_ep_info; return &bl31_params_mem.bl31_ep_info;
} }
/******************************************************************************* /*******************************************************************************
@ -253,7 +246,7 @@ void bl2_platform_setup(void)
/* Flush the TF params and the TF plat params */ /* Flush the TF params and the TF plat params */
void bl2_plat_flush_bl31_params(void) void bl2_plat_flush_bl31_params(void)
{ {
flush_dcache_range((unsigned long)PARAMS_BASE, flush_dcache_range((unsigned long)&bl31_params_mem,
sizeof(bl2_to_bl31_params_mem_t)); sizeof(bl2_to_bl31_params_mem_t));
} }

View File

@ -68,10 +68,11 @@ extern unsigned long __COHERENT_RAM_END__;
#define BL31_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) #define BL31_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
/****************************************************************************** /******************************************************************************
* Reference to structures which hold the arguments that have been passed to * Placeholder variables for copying the arguments that have been passed to
* BL31 from BL2. * BL3-1 from BL2.
******************************************************************************/ ******************************************************************************/
static bl31_params_t *bl2_to_bl31_params; static entry_point_info_t bl32_ep_info;
static entry_point_info_t bl33_ep_info;
/******************************************************************************* /*******************************************************************************
* Return a pointer to the 'entry_point_info' structure of the next image for * Return a pointer to the 'entry_point_info' structure of the next image for
@ -83,9 +84,7 @@ entry_point_info_t *bl31_get_next_image_info(uint32_t type)
{ {
entry_point_info_t *next_image_info; entry_point_info_t *next_image_info;
next_image_info = (type == NON_SECURE) ? next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
bl2_to_bl31_params->bl33_ep_info :
bl2_to_bl31_params->bl32_ep_info;
/* None of the images on this platform can have 0x0 as the entrypoint */ /* None of the images on this platform can have 0x0 as the entrypoint */
if (next_image_info->pc) if (next_image_info->pc)
@ -98,10 +97,9 @@ entry_point_info_t *bl31_get_next_image_info(uint32_t type)
* Perform any BL3-1 specific platform actions. Here is an opportunity to copy * Perform any BL3-1 specific platform actions. Here is an opportunity to copy
* parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
* are lost (potentially). This needs to be done before the MMU is initialized * are lost (potentially). This needs to be done before the MMU is initialized
* so that the memory layout can be used while creating page tables. The 'data' * so that the memory layout can be used while creating page tables. Also, BL2
* parameter is not used since all the information is contained in 'from_bl2'. * has flushed this information to memory, so we are guaranteed to pick up good
* Also, BL2 has flushed this information to memory, so we are guaranteed to * data
* pick up good data
******************************************************************************/ ******************************************************************************/
void bl31_early_platform_setup(bl31_params_t *from_bl2, void bl31_early_platform_setup(bl31_params_t *from_bl2,
void *plat_params_from_bl2) void *plat_params_from_bl2)
@ -112,8 +110,12 @@ void bl31_early_platform_setup(bl31_params_t *from_bl2,
assert(from_bl2->h.type == PARAM_BL31); assert(from_bl2->h.type == PARAM_BL31);
assert(from_bl2->h.version >= VERSION_1); assert(from_bl2->h.version >= VERSION_1);
bl2_to_bl31_params = from_bl2; /*
* Copy BL3-2 and BL3-3 entry point information.
* They are stored in Secure RAM, in BL2's address space.
*/
bl32_ep_info = *from_bl2->bl32_ep_info;
bl33_ep_info = *from_bl2->bl33_ep_info;
} }
/******************************************************************************* /*******************************************************************************

View File

@ -134,10 +134,6 @@
#define DRAM_BASE 0x80000000 #define DRAM_BASE 0x80000000
#define DRAM_SIZE 0x80000000 #define DRAM_SIZE 0x80000000
/* Base address where parameters to BL31 are stored */
/* Juno TODO: Move BL3-1 arguments somewhere in trusted memory */
#define PARAMS_BASE DRAM_BASE
/* Memory mapped Generic timer interfaces */ /* Memory mapped Generic timer interfaces */
#define SYS_CNTCTL_BASE 0x2a430000 #define SYS_CNTCTL_BASE 0x2a430000