[PATCH 3/8] ARM: ftrace: use trampolines to keep .init.text in branching range
Linus Walleij
linus.walleij at linaro.org
Wed Feb 2 16:12:43 PST 2022
On Tue, Jan 25, 2022 at 4:37 PM Ard Biesheuvel <ardb at kernel.org> wrote:
> Kernel images that are large in comparison to the range of a direct
> branch may fail to work as expected with ftrace, as patching a direct
> branch to one of the core ftrace routines may not be possible from the
> .init.text section, if it is emitted too far away from the normal .text
> section.
>
> This is more likely to affect Thumb2 builds, given that its range is
> only -/+ 16 MiB (as opposed to ARM which has -/+ 32 MiB), but may occur
> in either ISA.
>
> To work around this, add a couple of trampolines to .init.text and
> swap these in when the ftrace patching code is operating on callers in
> .init.text.
>
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
LGTM
Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
I suppose part of me wonder what happens if .text itself grows
larger than 16MB under thumb2, but I guess then the linker
will just fail.
Yours,
Linus Walleij
More information about the linux-arm-kernel
mailing list