Michael Ellerman 85baa09549 powerpc/livepatch: Add live patching support on ppc64le
Add the kconfig logic & assembly support for handling live patched
functions. This depends on DYNAMIC_FTRACE_WITH_REGS, which in turn
depends on the new -mprofile-kernel ftrace ABI, which is only supported
currently on ppc64le.

Live patching is handled by a special ftrace handler. This means it runs
from ftrace_caller(). The live patch handler modifies the NIP so as to
redirect the return from ftrace_caller() to the new patched function.

However there is one particularly tricky case we need to handle.

If a function A calls another function B, and it is known at link time
that they share the same TOC, then A will not save or restore its TOC,
and will call the local entry point of B.

When we live patch B, we replace it with a new function C, which may
not have the same TOC as A. At live patch time it's too late to modify A
to do the TOC save/restore, so the live patching code must interpose
itself between A and C, and do the TOC save/restore that A omitted.

An additionaly complication is that the livepatch code can not create a
stack frame in order to save the TOC. That is because if C takes > 8
arguments, or is varargs, A will have written the arguments for C in
A's stack frame.

To solve this, we introduce a "livepatch stack" which grows upward from
the base of the regular stack, and is used to store the TOC & LR when
calling a live patched function.

When the patched function returns, we retrieve the real LR & TOC from
the livepatch stack, restore them, and pop the livepatch "stack frame".

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Torsten Duwe <duwe@suse.de>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
2016-04-14 15:48:06 +10:00
..
2016-01-20 17:09:18 -08:00
2016-01-20 17:09:18 -08:00
2016-01-27 11:37:37 +11:00
2014-11-27 09:32:58 +11:00
2014-08-13 15:13:42 +10:00
2014-09-25 23:14:46 +10:00
2014-11-03 12:12:32 +11:00
2014-11-03 12:12:32 +11:00
2015-08-06 15:10:20 +10:00
2015-03-24 13:15:52 +11:00
2014-12-11 17:48:14 -08:00
2015-12-17 22:40:56 +11:00
2014-09-25 23:14:41 +10:00
2015-12-14 20:40:32 +11:00
2015-12-14 20:40:32 +11:00
2014-08-06 13:04:32 +02:00
2015-12-02 19:34:40 +11:00
2015-12-16 12:54:04 +11:00
2015-04-07 17:15:13 +10:00
2015-06-24 17:49:38 -07:00