From: Michael Ellerman <mpe@ellerman.id.au>
To: Torsten Duwe <duwe@lst.de>
Cc: linuxppc-dev@ozlabs.org, bsingharora@gmail.com,
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: Tue, 29 Mar 2016 16:28:53 +1100 [thread overview]
Message-ID: <1459229333.8173.12.camel@ellerman.id.au> (raw)
In-Reply-To: <20160324134221.GB29197@lst.de>
On Thu, 2016-03-24 at 14:42 +0100, Torsten Duwe wrote:
> On Thu, Mar 24, 2016 at 10:04:05PM +1100, Michael Ellerman wrote:
> > +livepatch_handler:
> > + CURRENT_THREAD_INFO(r12, r1)
> [...]
> > + /* Put ctr in r12 for global entry and branch there */
> > + mfctr r12
> > + bctrl
> ^
> I like this piece. No need to fiddle out the return helper address.
Good.
> > + /*
> > + * Now we are returning from the patched function to the original
> > + * caller A. We are free to use r0 and r12, and we can use r2 until we
> > + * restore it.
> > + */
> > +
> > + CURRENT_THREAD_INFO(r12, r1)
> > +
> > + /* Save stack pointer into r0 */
> > + mr r0, r1
> > +
> > + ld r1, TI_livepatch_sp(r12)
> > +
> > + /* Check stack marker hasn't been trashed */
> > + lis r2, STACK_END_MAGIC@h
> > + ori r2, r2, STACK_END_MAGIC@l
> > + ld r12, -8(r1)
> > +1: tdne r12, r2
> > + EMIT_BUG_ENTRY 1b, __FILE__, __LINE__ - 1, 0
>
> This however worries me a bit. Sure, in the end, a stack overflow is
> a stack overflow, and if all the information does not fit there,
> there's little you can do.
Yeah stack overflow in the kernel is very very fatal.
> But wouldn't it be better to kmalloc that area and realloc in
> klp_arch_set_pc when it's full? Maybe along with a warning message?
You can't realloc in klp_arch_set_pc(), you might be patching sl*b and holding
one of its locks. You might also recurse.
We could allocate a larger buffer as a "klp stack" for each task when the first
live patch is installed, and for every task created afterward. But that
potentially significantly increases memory usage on live patched kernels :)
> That way a live patched kernel will not run into stack size problems
> any earlier than an unpatched kernel would.
Yeah that's true. I'm not sure what the best trade off is.
cheers
next prev parent reply other threads:[~2016-03-29 5:28 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 [this message]
2016-04-01 1:10 ` Balbir Singh
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=1459229333.8173.12.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--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=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).