From: Chen-Yu Tsai Date: Sun, 19 Jun 2016 12:38:39 +0800 Subject: [U-Boot] [PATCH 09/15] ARM: Add CONFIG_ARMV7_SECURE_MAX_SIZE and check size of secure section In-Reply-To: <1466311125-20995-1-git-send-email-wens@csie.org> References: <1466311125-20995-1-git-send-email-wens@csie.org> Message-ID: <1466311125-20995-10-git-send-email-wens@csie.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de As the PSCI implementation grows, we might exceed the size of the secure memory that holds the firmware. Add a configurable CONFIG_ARMV7_SECURE_MAX_SIZE so platforms can define how much secure memory is available. The linker then checks the size of the whole secure section against this. Signed-off-by: Chen-Yu Tsai --- arch/arm/cpu/u-boot.lds | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds index 002706ae635d..5a65c27cfa74 100644 --- a/arch/arm/cpu/u-boot.lds +++ b/arch/arm/cpu/u-boot.lds @@ -86,6 +86,17 @@ SECTIONS . = ALIGN(CONSTANT(COMMONPAGESIZE)); KEEP(*(.__secure_stack_end)) + +#ifdef CONFIG_ARMV7_SECURE_MAX_SIZE + /* + * We are not checking (__secure_end - __secure_start) here, + * as these are the load addresses, and do not include the + * stack section. Instead, use the end of the stack section + * and the start of the text section. + */ + ASSERT((. - ADDR(.secure_text)) <= CONFIG_ARMV7_SECURE_MAX_SIZE, + "Error: secure section exceeds secure memory size"); +#endif } #ifndef __ARMV7_PSCI_STACK_IN_RAM -- 2.8.1