mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-21 20:14:29 +00:00

The arm64 Linux kernel needed to be loaded at a certain offset within any 2MB aligned region; this value was configured at compile time and stored in the Linux kernel image header. The default value was always 512KiB, so this is the value we use in the TF-A build system for the kernel load address. However the whole scheme around the TEXT_OFFSET changed in Linux v5.8: Linux kernels became fully relocatable, so this value is largely ignored now, and its default value changed to 0. The only remainder is a warning message at boot time in case there is a mismatch: [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader! To avoid this warning, and to make TF-A Linux kernel boot protocol compliant, we should load newer kernels to offset 0 of a 2 MB region. This can be done by the user at FPGA boot time, but BL31 needs to know about this address. As we can't change the build default to 0 without breaking older kernels, we should try to make a build dealing with both versions: This patch introduces a small trampoline code, which gets loaded at 512KB of DRAM, and branches up to 2MB. If users load their newer kernels at 2MB, this trampoline will cover them. In case an older kernel is loaded at 512KB, it will overwrite this trampoline code, so it would still work. Change-Id: If49ca86f5dca380036caf2555349748722901277 Signed-off-by: Andre Przywara <andre.przywara@arm.com>
35 lines
1.2 KiB
ArmAsm
35 lines
1.2 KiB
ArmAsm
/*
|
|
* Copyright (c) 2021, ARM Limited. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*
|
|
* The traditional arm64 Linux kernel load address is 512KiB from the
|
|
* beginning of DRAM, caused by this having been the default value of the
|
|
* kernel's CONFIG_TEXT_OFFSET Kconfig value.
|
|
* However kernel version 5.8 changed the default offset (into a 2MB page)
|
|
* to 0, so TF-A's default assumption is no longer true. Fortunately the
|
|
* kernel got more relaxed about this offset at the same time, so it
|
|
* tolerates the wrong offset, but issues a warning:
|
|
* [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader!
|
|
*
|
|
* We cannot easily change the load address offset in TF-A to be 2MiB, because
|
|
* this would break older kernels - and they are not as forgiving in this
|
|
* respect.
|
|
*
|
|
* But we can allow users to load the kernel at the right offset, and
|
|
* offer this trampoline here to transition to this new load address.
|
|
* Any older kernels, or newer kernels misloaded, will overwrite this code
|
|
* here, so it does no harm in this case.
|
|
*/
|
|
|
|
#include <asm_macros.S>
|
|
#include <common/bl_common.ld.h>
|
|
|
|
.text
|
|
.global _tramp_start
|
|
|
|
_tramp_start:
|
|
adr x4, _tramp_start
|
|
orr x4, x4, #0x1fffff
|
|
add x4, x4, #1 /* align up to 2MB */
|
|
br x4
|