All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Torsten Duwe <duwe@lst.de>
Cc: Balbir Singh <bsingharora@gmail.com>,
	linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com,
	jeyu@redhat.com, jkosina@suse.cz, live-patching@vger.kernel.org,
	mbenes@suse.cz
Subject: Re: [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc
Date: Wed, 9 Mar 2016 10:44:23 +0100	[thread overview]
Message-ID: <20160309094423.GH10940@pathway.suse.cz> (raw)
In-Reply-To: <20160309091904.GA23039@lst.de>

On Wed 2016-03-09 10:19:04, Torsten Duwe wrote:
> On Wed, Mar 09, 2016 at 05:59:40PM +1100, Balbir Singh wrote:
> > 
> > The previous revision was nacked by Torsten, but compared to the alternatives
> 
> I nacked it because I was confident it couldn't work. Same goes
> for this one, sorry. My good intention was to save us all some work.
> 
> > @@ -1265,6 +1271,51 @@ ftrace_call:
> >  	ld	r0, LRSAVE(r1)
> >  	mtlr	r0
> >  
> > +#ifdef CONFIG_LIVEPATCH
> > +	beq+	4f		/* likely(old_NIP == new_NIP) */
> > +	/*
> > +	 * For a local call, restore this TOC after calling the patch function.
> 
> This is the key issue.
> 
> Ftrace_caller can gather and save the current r2 contents, no problem;
> but the point is, it needs to be restored *after* the replacement function.
> I see 3 ways to accomplish this:
> 
> 1st: make _every_ replacement function aware of this, and make it restore
>      the TOC manually just before each return statement.
> 
> 2nd: provide a global hook to do the job, and use a stack frame to execute it.
> 
> 3rd: have a global hook like solution 2, but let it have its own data
>      structure, I'd call it a "shadow stack", for the real return addresses.
>      See struct fgraph_cpu_data in kernel/trace/trace_functions_graph.c
> 
> Using heuristics to determine whether the call was local or global
> makes me feel highly uncomfortable; one day it will break and
> nobody will remember why.
> 
> Balbir, the problem with your patch is that it goes only half the way from
> my solution 2 towards solution 1. When you call a helper function on return,
> you need a place to store the real return address.
> 
> I'll try to demonstrate a solution 1 as well, but you'll probably won't like
> that either...

To be honest, I still do not have a good picture about all the
problems in my head. Anyway, I would really appreciate if we could
find a solution that would work transparently. I mean that adding
an extra hacks into selected functions in the patch might be quite
error prone and problems hard to debug. I think that we all want this
but I wanted to be sure :-)

BTW: I am getting close to send a patch with some basic livepatch
documentation. It might be used to document "temporary" limitations.

Best Regards,
Petr

  reply	other threads:[~2016-03-09  9:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09  6:59 [PATCH][v6][RFC] livepatch/ppc: Enable livepatching on powerpc Balbir Singh
2016-03-09  9:19 ` Torsten Duwe
2016-03-09  9:44   ` Petr Mladek [this message]
2016-03-09 10:03     ` Torsten Duwe
2016-03-09 10:13       ` Jiri Kosina
2016-03-09 11:16         ` Torsten Duwe
2016-03-09 12:56           ` Petr Mladek
2016-03-09 10:27       ` Michael Ellerman
2016-03-10  0:40   ` Balbir Singh
2016-03-15 10:25 ` Miroslav Benes
2016-03-17 15:42 ` Torsten Duwe

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=20160309094423.GH10940@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.