Commit af419dd6 authored by Sandrine Bailleux's avatar Sandrine Bailleux
Browse files

ARM platforms: Restrict mapping of Trusted ROM in BL1

At the moment, on ARM platforms, BL1 maps everything from BL1_RO_BASE
to BL1_RO_LIMIT. BL1_RO_LIMIT, as defined in the porting guide, is
the maximum address in Trusted ROM that BL1's actual content _can_
occupy. The actual portion of ROM occupied by BL1 can be less than
that, which means that BL1 might map more Trusted ROM than it actually
needs to.

This patch changes BL1's memory mappings on ARM platforms to restrict
the region of Trusted ROM it maps. It uses the symbols exported by
the linker to figure out the actual extents of BL1's ROM footprint.

This change increases the number of page tables used on FVP by 1.
On FVP, we used to map the whole Trusted ROM. As it is 64MB large,
we used to map it as blocks of 2MB using level-2 translation table
entries. We now need a finer-grained mapping, which requires an
additional level-3 translation table.

On ARM CSS platforms, the number of translation tables is unchanged.
The BL1 image resides in flash at address 0x0BEC0000. This address is
not aligned on a 2MB-boundary so a level-3 translation table was
already required to map this memory.

Change-Id: I317a93fd99c40e70d0f13cc3d7a570f05c6c61eb
parent a604623c
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <platform_def.h> #include <platform_def.h>
#include <plat_arm.h> #include <plat_arm.h>
#include <sp805.h> #include <sp805.h>
#include <utils.h>
#include <xlat_tables.h>
#include "../../../bl1/bl1_private.h" #include "../../../bl1/bl1_private.h"
...@@ -118,10 +120,16 @@ void bl1_early_platform_setup(void) ...@@ -118,10 +120,16 @@ void bl1_early_platform_setup(void)
*****************************************************************************/ *****************************************************************************/
void arm_bl1_plat_arch_setup(void) void arm_bl1_plat_arch_setup(void)
{ {
/*
* BL1_ROM_END is not necessarily aligned on a page boundary as it
* just points to the end of BL1's actual content in Trusted ROM.
* Therefore it needs to be rounded up to the next page size in order to
* map the whole last page of it with the right memory attributes.
*/
arm_setup_page_tables(bl1_tzram_layout.total_base, arm_setup_page_tables(bl1_tzram_layout.total_base,
bl1_tzram_layout.total_size, bl1_tzram_layout.total_size,
BL1_RO_BASE, BL1_RO_BASE,
BL1_RO_LIMIT round_up(BL1_ROM_END, PAGE_SIZE)
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL1_COHERENT_RAM_BASE, , BL1_COHERENT_RAM_BASE,
BL1_COHERENT_RAM_LIMIT BL1_COHERENT_RAM_LIMIT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment