summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@xilinx.com>2020-09-09 19:07:25 +0200
committerMichal Simek <michal.simek@xilinx.com>2020-09-22 12:47:28 +0200
commit04d13b5d09c17a076260e2b9fb92c0d708d37264 (patch)
treea9296bb90bb11a5004d2c96ac0f8a771f92144ee
parent11f4fbf0d4a1160285002f242a2406c1740c4a27 (diff)
downloadu-boot-04d13b5d09c17a076260e2b9fb92c0d708d37264.tar.gz
u-boot-04d13b5d09c17a076260e2b9fb92c0d708d37264.tar.bz2
u-boot-04d13b5d09c17a076260e2b9fb92c0d708d37264.zip
arm64: Trap PIE builds early if load address is not 4K aligned
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 <michal.simek@xilinx.com> Suggested-by: André Przywara <andre.przywara@arm.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
-rw-r--r--arch/arm/cpu/armv8/start.S17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 002698b501..85baebc5f7 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 x0, _start
+ ands x0, x0, #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.