]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
arm64: module/ftrace: intialize PLT at load time
authorMark Rutland <mark.rutland@arm.com>
Thu, 17 Oct 2019 14:26:38 +0000 (15:26 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 14 Apr 2022 09:32:17 +0000 (11:32 +0200)
commitffd0dfb15d33cc0d98b2a291ae89772cedfc61e5
treee7b41cac1eed942c99dbc2535e1d0c8d07e72144
parent02efb96d41edb1d209c907c9dfdc7983a7d5d1d6
arm64: module/ftrace: intialize PLT at load time

BugLink: https://bugs.launchpad.net/bugs/1967582
commit f1a54ae9af0da4d76239256ed640a93ab3aadac0 upstream.

Currently we lazily-initialize a module's ftrace PLT at runtime when we
install the first ftrace call. To do so we have to apply a number of
sanity checks, transiently mark the module text as RW, and perform an
IPI as part of handling Neoverse-N1 erratum #1542419.

We only expect the ftrace trampoline to point at ftrace_caller() (AKA
FTRACE_ADDR), so let's simplify all of this by intializing the PLT at
module load time, before the module loader marks the module RO and
performs the intial I-cache maintenance for the module.

Thus we can rely on the module having been correctly intialized, and can
simplify the runtime work necessary to install an ftrace call in a
module. This will also allow for the removal of module_disable_ro().

Tested by forcing ftrace_make_call() to use the module PLT, and then
loading up a module after setting up ftrace with:

| echo ":mod:<module-name>" > set_ftrace_filter;
| echo function > current_tracer;
| modprobe <module-name>

Since FTRACE_ADDR is only defined when CONFIG_DYNAMIC_FTRACE is
selected, we wrap its use along with most of module_init_ftrace_plt()
with ifdeffery rather than using IS_ENABLED().

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Torsten Duwe <duwe@suse.de>
Tested-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Tested-by: Torsten Duwe <duwe@suse.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm64/kernel/ftrace.c
arch/arm64/kernel/module.c