linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <bsingharora@gmail.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@ozlabs.org
Cc: duwe@lst.de, linux-kernel@vger.kernel.org, rostedt@goodmis.org,
	kamalesh@linux.vnet.ibm.com, pmladek@suse.com, jeyu@redhat.com,
	jkosina@suse.cz, live-patching@vger.kernel.org, mbenes@suse.cz
Subject: Re: [PATCH 6/6] powerpc/livepatch: Add live patching support on ppc64le
Date: Fri, 1 Apr 2016 12:10:59 +1100	[thread overview]
Message-ID: <56FDCAA3.8000503@gmail.com> (raw)
In-Reply-To: <1458817445-5855-6-git-send-email-mpe@ellerman.id.au>



On 24/03/16 22:04, Michael Ellerman wrote:
> 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: Balbir Singh <bsingharora@gmail.com>

  parent reply	other threads:[~2016-04-01  1:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 11:04 [PATCH HACK 1/6] livepatch-test: Add more cases Michael Ellerman
2016-03-24 11:04 ` [PATCH 2/6] ftrace: Make ftrace_location_range() global Michael Ellerman
2016-03-24 15:20   ` Steven Rostedt
2016-03-24 15:24     ` Jiri Kosina
2016-03-25 10:24     ` Michael Ellerman
2016-03-24 11:04 ` [PATCH 3/6] livepatch: Allow architectures to specify an alternate ftrace location Michael Ellerman
2016-03-24 11:04 ` [PATCH 4/6] powerpc/livepatch: Add livepatch header Michael Ellerman
2016-03-24 11:04 ` [PATCH 5/6] powerpc/livepatch: Add livepatch stack to struct thread_info Michael Ellerman
2016-03-28 23:58   ` Balbir Singh
2016-03-29  5:19     ` Michael Ellerman
2016-03-29  5:45       ` Balbir Singh
2016-04-01  1:02   ` Balbir Singh
2016-03-24 11:04 ` [PATCH 6/6] powerpc/livepatch: Add live patching support on ppc64le Michael Ellerman
2016-03-24 13:42   ` Torsten Duwe
2016-03-29  5:28     ` Michael Ellerman
2016-04-01  1:10   ` Balbir Singh [this message]
2016-03-24 16:37 ` [PATCH HACK 1/6] livepatch-test: Add more cases Kamalesh Babulal
2016-03-26  7:11   ` Balbir Singh
2016-03-28  4:52     ` Kamalesh Babulal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56FDCAA3.8000503@gmail.com \
    --to=bsingharora@gmail.com \
    --cc=duwe@lst.de \
    --cc=jeyu@redhat.com \
    --cc=jkosina@suse.cz \
    --cc=kamalesh@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mpe@ellerman.id.au \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).