Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1352893

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc

From Torsten Duwe <duwe@lst.de>
Newsgroups linux.kernel
Subject Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc
Date 2016-03-08 12:20 +0100
Message-ID <ranQe-5m-11@gated-at.bofh.it> (permalink)
References <r8ELy-1ze-61@gated-at.bofh.it> <r8Xl9-6QX-21@gated-at.bofh.it> <r8XEu-7hh-5@gated-at.bofh.it> <r92uu-2hO-19@gated-at.bofh.it> <r93Ae-32M-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Mar 04, 2016 at 08:22:22PM +0100, Torsten Duwe wrote:
> On Fri, Mar 04, 2016 at 07:16:57PM +0100, Torsten Duwe wrote:
> > On Fri, Mar 04, 2016 at 02:01:37PM +0100, Petr Mladek wrote:
> > > 
> > > Do I understand it correctly that we could not patch functions that
> > > pass arguments on the stack with this implementation? If yes, how hard
> > > would be to get it working, please? At least, it would be great to
> > > catch this problem and handle it with grace. Otherwise, it might
> > > be hard to debug.
> > 
> > No, those functions only require special attention.
> 
> So far it's correct. It's been a while since I wrote that code.
> 
> > I needed _any_ location to store the caller's TOC;
> > and the stack is thread-safe and recursion-safe.
> > The current caller's frame is already full so I had
> > to create a new one.
> 
> Correction: the TOC can be stored in the caller's stack frame at
> the usual location. Only the restore instruction is a problem.

Another correction :-( This is true only for local calls

    -*> Which become *global* calls due to live patching <*-

For callers that made a global call to the patched function originally,
they already _have_ stored their TOC value there, and the r2 they enter
ftrace caller with is bogus.

I see no way to determine which is the case, so my code preserves both:
24(r1) in the caller's frame is left untouched. R2, as it came, is saved in
the mini stack frame, as well as the caller's return address (LR,
shifted 1 frame). Remember, LR got modified to point to klp_return_helper.

Removing this auxiliary stack frame causes even more problems than it solves.

> So one solution could be to call the patch function via a small
> trampoline or pre-prologue that just pops that frame, and have
> the patch function restore R2 manually at the end.

I'll try to demonstrate that. It's not so hard. And klp_return_helper will
do the right thing for >90% of all function replacements automatically.

> Sorry for the confusion,

Once more.

	Torsten

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Torsten Duwe <duwe@lst.de> - 2016-03-04 13:50 +0100
  Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Petr Mladek <pmladek@suse.com> - 2016-03-04 14:10 +0100
    Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Torsten Duwe <duwe@lst.de> - 2016-03-04 19:20 +0100
      Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Torsten Duwe <duwe@lst.de> - 2016-03-04 20:30 +0100
        Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Torsten Duwe <duwe@lst.de> - 2016-03-08 12:20 +0100
  Re: [PATCH][v4] livepatch/ppc: Enable livepatching on powerpc Balbir Singh <bsingharora@gmail.com> - 2016-03-07 01:00 +0100

csiph-web