From: Torsten Duwe <duwe@lst.de>
To: Balbir Singh <bsingharora@gmail.com>
Cc: linuxppc-dev@ozlabs.org, pmladek@suse.com, jeyu@redhat.com,
jkosina@suse.cz, jikos@kernel.org, linux-kernel@vger.kernel.org,
rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com,
live-patching@vger.kernel.org, mbenes@suse.cz
Subject: Re: [v5][PATCH] livepatch/ppc: Enable livepatching on powerpc
Date: Tue, 8 Mar 2016 16:34:35 +0100 [thread overview]
Message-ID: <20160308153435.GA23804@lst.de> (raw)
In-Reply-To: <56DED903.2000209@gmail.com>
On Wed, Mar 09, 2016 at 12:52:03AM +1100, Balbir Singh wrote:
>
> On 08/03/16 21:45, Torsten Duwe wrote:
> > To be fair, my last mail still was not 100% correct, but the conclusion
Wrote a correction to the correction. It should be clear now. Please nag me
if it isn't clear why klp_return_helper and its stack frame is needed.
> > that the mini frame is not needed at all is invalid. Please leave it as it
> > was, I'm working on a test / demonstrator for how to handle these.
> Why, the magic will be in the patched function? Please share the test/demonstrator
Here it comes...
> > NAKed-by: Torsten Duwe <duwe@suse.de>
> Why? For using CR+4 or removing the frame? Or you believe there is a better way to
> handle this that work, IOW what is broken?
The stack frame removal. You're risking a memory access or jump into nirvana
or and endless loop.
klp_return_helper will do the right thing, and functions like e.g. printk
I would live patch like this (untested :-) :
------------------------8<----------------------
#include <stdarg.h>
/* compile using "-ffixed-r14"! */
register unsigned long pass_TOC asm("r14");
/*
* Function pre-prologue to pop the klp_return_helper
* mini stack frame. The saved r2 TOC value is read and
* passed in pass_TOC (r14), the original LR is passed
* in r0 and the LR itself. R12 is updated appropriately
* for local TOC recalculation.
*/
extern void caller(void) asm("printk");
void caller(void)
{
asm("ld %0,24(1)" : "=r" (pass_TOC));
asm("addi 1,1,32");
asm("addi 12,12,(real_printk-printk)@l");
asm("ld 0,16(1)\n\tmtlr 0");
asm("b real_printk");
}
extern int vprintk_default(const char *fmt, va_list args);
extern int printk(const char *fmt, ...) asm("real_printk");
int printk(const char *fmt, ...)
{
va_list args;
int r;
va_start(args, fmt);
r = vprintk_default(fmt, args);
va_end(args);
asm("mr 2,%0" : : "r" (pass_TOC));
return r;
}
------------------------8<----------------------
Signed-off-by: Torsten Duwe <duwe@suse.de>
As you can see, the extra effort for args on the stack is limited.
Torsten
next prev parent reply other threads:[~2016-03-08 15:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 7:33 [v5][PATCH] livepatch/ppc: Enable livepatching on powerpc Balbir Singh
2016-03-08 10:45 ` Torsten Duwe
2016-03-08 13:52 ` Balbir Singh
2016-03-08 15:34 ` Torsten Duwe [this message]
2016-03-09 3:41 ` Balbir Singh
2016-03-09 16:10 ` Petr Mladek
2016-03-09 17:26 ` Torsten Duwe
2016-03-08 16:02 ` Petr Mladek
2016-03-09 3:37 ` Balbir Singh
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=20160308153435.GA23804@lst.de \
--to=duwe@lst.de \
--cc=bsingharora@gmail.com \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--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=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).