From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edgar E. Iglesias Date: Fri, 4 Sep 2020 11:07:48 +0200 Subject: [PATCH v2 2/3] arm64: Bail out PIE builds early if load address is not 4K aligned In-Reply-To: <20200904090749.4067768-1-edgar.iglesias@gmail.com> References: <20200904090749.4067768-1-edgar.iglesias@gmail.com> Message-ID: <20200904090749.4067768-3-edgar.iglesias@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: "Edgar E. Iglesias" PIE requires a 4K aligned load address. If this is not met, trap the startup sequence in a WFI loop rather than running into obscure failures. Tested-by: Michal Simek Suggested-by: Andr? Przywara Signed-off-by: Edgar E. Iglesias --- arch/arm/cpu/armv8/start.S | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index 002698b501..732bc385d4 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -59,6 +59,23 @@ reset: save_boot_params_ret: #if CONFIG_POSITION_INDEPENDENT + /* Verify that we're 4K aligned. */ + adr x1, _start + ands x1, x1, #0xfff + b.eq 1f +0: + /* + * FATAL, can't continue. + * U-boot needs to be loaded at a 4K aligned address. + * + * We use ADRP and ADD to load some symbol addresses during startup. + * The ADD uses an absolute (non pc-relative) lo12 relocation + * thus requiring 4K alignment. + */ + wfi + b 0b +1: + /* * Fix .rela.dyn relocations. This allows U-Boot to be loaded to and * executed at a different address than it was linked at. -- 2.25.1