diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-06-06 17:00:22 +0000 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2017-06-07 11:52:02 +0100 |
commit | e71a4e1bebaf7fd990efbdc04b38e5526914f0f1 (patch) | |
tree | 0f8906d0ba3979cd8020dd896aa6d764afb360df /arch/arm64/kernel/module.c | |
parent | f8af0b364e249eef0c71200826563947cd74267e (diff) | |
download | linux-stable-e71a4e1bebaf7fd990efbdc04b38e5526914f0f1.tar.gz linux-stable-e71a4e1bebaf7fd990efbdc04b38e5526914f0f1.tar.bz2 linux-stable-e71a4e1bebaf7fd990efbdc04b38e5526914f0f1.zip |
arm64: ftrace: add support for far branches to dynamic ftrace
Currently, dynamic ftrace support in the arm64 kernel assumes that all
core kernel code is within range of ordinary branch instructions that
occur in module code, which is usually the case, but is no longer
guaranteed now that we have support for module PLTs and address space
randomization.
Since on arm64, all patching of branch instructions involves function
calls to the same entry point [ftrace_caller()], we can emit the modules
with a trampoline that has unlimited range, and patch both the trampoline
itself and the branch instruction to redirect the call via the trampoline.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[will: minor clarification to smp_wmb() comment]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel/module.c')
-rw-r--r-- | arch/arm64/kernel/module.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index f035ff6fb223..8c3a7264fb0f 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -420,8 +420,12 @@ int module_finalize(const Elf_Ehdr *hdr, for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { if (strcmp(".altinstructions", secstrs + s->sh_name) == 0) { apply_alternatives((void *)s->sh_addr, s->sh_size); - return 0; } +#ifdef CONFIG_ARM64_MODULE_PLTS + if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) && + !strcmp(".text.ftrace_trampoline", secstrs + s->sh_name)) + me->arch.ftrace_trampoline = (void *)s->sh_addr; +#endif } return 0; |