]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/module: Mark module stubs with a magic value
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Mar 2016 04:26:55 +0000 (15:26 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 7 Mar 2016 03:53:53 +0000 (14:53 +1100)
commita24410c770e3d9b9069fecc160195dbb4dc56619
tree57ba5fd193ac1e40cd7b1854d121b10bbbb3960c
parent494b94dd9ea6b17bf8d6366f4c39572f545b2d5c
powerpc/module: Mark module stubs with a magic value

When a module is loaded, calls out to the kernel go via a stub which is
generated at runtime. One of these stubs is used to call _mcount(),
which is the default target of tracing calls generated by the compiler
with -pg.

If dynamic ftrace is enabled (which it typically is), another stub is
used to call ftrace_caller(), which is the target of tracing calls when
ftrace is actually active.

ftrace then wants to disable the calls to _mcount() at module startup,
and enable/disable the calls to ftrace_caller() when enabling/disabling
tracing - all of these it does by patching the code.

As part of that code patching, the ftrace code wants to confirm that the
branch it is about to modify, is in fact a call to a module stub which
calls _mcount() or ftrace_caller().

Currently it does that by inspecting the instructions and confirming
they are what it expects. Although that works, the code to do it is
pretty intricate because it requires lots of knowledge about the exact
format of the stub.

We can make that process easier by marking the generated stubs with a
magic value, and then looking for that magic value. Altough this is not
as rigorous as the current method, I believe it is sufficient in
practice.

Reviewed-by: Balbir Singh <bsingharora@gmail.com>
Reviewed-by: Torsten Duwe <duwe@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/module.h
arch/powerpc/kernel/ftrace.c
arch/powerpc/kernel/module_64.c