]> git.baikalelectronics.ru Git - kernel.git/commit
ARM: 8780/1: ftrace: Only set kernel memory back to read-only after boot
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 10 Jul 2018 07:22:40 +0000 (08:22 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Wed, 11 Jul 2018 21:57:57 +0000 (22:57 +0100)
commit2fd0a6216552ea7f6647231ac652a1509f2aed70
tree1a448c113d6bd23feeea5c04f0a53ea86a0afd7f
parent451fb27b162b0cbc1a770abc670e35fb594dd7ea
ARM: 8780/1: ftrace: Only set kernel memory back to read-only after boot

Dynamic ftrace requires modifying the code segments that are usually
set to read-only. To do this, a per arch function is called both before
and after the ftrace modifications are performed. The "before" function
will set kernel code text to read-write to allow for ftrace to make the
modifications, and the "after" function will set the kernel code text
back to "read-only" to keep the kernel code text protected.

The issue happens when dynamic ftrace is tested at boot up. The test is
done before the kernel code text has been set to read-only. But the
"before" and "after" calls are still performed. The "after" call will
change the kernel code text to read-only prematurely, and other boot
code that expects this code to be read-write will fail.

The solution is to add a variable that is set when the kernel code text
is expected to be converted to read-only, and make the ftrace "before"
and "after" calls do nothing if that variable is not yet set. This is
similar to the x86 solution from commit 5e691f76602f ("ftrace, x86:
make kernel text writable only for conversions").

Link: http://lkml.kernel.org/r/20180620212906.24b7b66e@vmware.local.home
Reported-by: Stefan Agner <stefan@agner.ch>
Tested-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/mm/init.c