Re: livepatch: reuse module loader code to write relocations

2016-03-22 Thread Jessica Yu
+++ Jiri Kosina [21/03/16 23:02 +0100]: On Mon, 21 Mar 2016, Josh Poimboeuf wrote: According to my test that still results in the literal value of "(64 - 8)". Alright. But we should be able to special-case it with a two #if checks on the __SIZEOF_LONG__ value and BUILD_BUG_ON() when __SIZEOF_

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Jiri Kosina
On Mon, 21 Mar 2016, Josh Poimboeuf wrote: > According to my test that still results in the literal value of > "(64 - 8)". Alright. But we should be able to special-case it with a two #if checks on the __SIZEOF_LONG__ value and BUILD_BUG_ON() when __SIZEOF_LONG__ is not of one of the ususal siz

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Josh Poimboeuf
On Mon, Mar 21, 2016 at 10:16:17PM +0100, Jiri Kosina wrote: > On Mon, 21 Mar 2016, Jessica Yu wrote: > > > Yes, this is a concern and I'm not sure what the best way to fix it > > is. If both MODULE_NAME_LEN and KSYM_NAME_LEN were straight up > > constants, then I think Josh's stringify approach w

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Jiri Kosina
On Mon, 21 Mar 2016, Jessica Yu wrote: > Yes, this is a concern and I'm not sure what the best way to fix it > is. If both MODULE_NAME_LEN and KSYM_NAME_LEN were straight up > constants, then I think Josh's stringify approach would have worked > perfectly. However since MODULE_NAME_LEN translates

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Josh Poimboeuf
On Mon, Mar 21, 2016 at 03:18:32PM -0400, Jessica Yu wrote: > +++ Miroslav Benes [21/03/16 14:55 +0100]: > >On Wed, 16 Mar 2016, Jessica Yu wrote: > > > >[...] > > > >>+struct klp_buf { > >>+ char symname[KSYM_SYMBOL_LEN]; > > > >I think it is better to make this KSYM_NAME_LEN. KSYM_SYMBOL_LEN lo

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Jessica Yu
+++ Miroslav Benes [21/03/16 14:55 +0100]: On Wed, 16 Mar 2016, Jessica Yu wrote: [...] +struct klp_buf { + char symname[KSYM_SYMBOL_LEN]; I think it is better to make this KSYM_NAME_LEN. KSYM_SYMBOL_LEN looks like something different and KSYM_NAME_LEN is 128 which you reference below.

Re: livepatch: reuse module loader code to write relocations

2016-03-21 Thread Jessica Yu
+++ Josh Poimboeuf [21/03/16 12:36 -0500]: On Mon, Mar 21, 2016 at 11:46:51AM -0500, Josh Poimboeuf wrote: On Mon, Mar 21, 2016 at 05:31:57PM +0100, Petr Mladek wrote: > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > > index 780f00c..2aa20fa 100644 > > --- a/kernel/livepatch/

Re: livepatch: reuse module loader code to write relocations

2016-02-09 Thread Jessica Yu
+++ Petr Mladek [09/02/16 15:01 +0100]: On Wed 2016-02-03 20:11:09, Jessica Yu wrote: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific relocation code in livepatch. Specifically, reuse the apply_relocate_add() function in the module loader to

Re: livepatch: reuse module loader code to write relocations

2016-02-09 Thread Jessica Yu
+++ Josh Poimboeuf [08/02/16 14:26 -0600]: On Wed, Feb 03, 2016 at 08:11:09PM -0500, Jessica Yu wrote: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific relocation code in livepatch. Specifically, reuse the apply_relocate_add() function in the

Re: livepatch: reuse module loader code to write relocations

2015-12-20 Thread Jessica Yu
+++ Petr Mladek [17/12/15 16:45 +0100]: On Wed 2015-12-16 00:40:48, Jessica Yu wrote: Turns out the string parsing stuff, even with the help of lib/string.c, doesn't look very pretty. As I'm working on v3, I'm starting to think having klp_write_object_relocations() loop simply through all the el

Re: livepatch: reuse module loader code to write relocations

2015-12-17 Thread Petr Mladek
On Wed 2015-12-16 00:40:48, Jessica Yu wrote: > Turns out the string parsing stuff, even with the help of lib/string.c, > doesn't > look very pretty. As I'm working on v3, I'm starting to think having > klp_write_object_relocations() loop simply through all the elf sections might > not be a good i

Re: livepatch: reuse module loader code to write relocations

2015-12-16 Thread Jessica Yu
+++ Miroslav Benes [16/12/15 13:59 +0100]: On Wed, 16 Dec 2015, Jessica Yu wrote: +++ Jessica Yu [09/12/15 14:10 -0500]: > +++ Josh Poimboeuf [08/12/15 12:38 -0600]: > > > > There was a lot of discussion for v1, so I'm not sure, but I thought we > > ended up deciding to get rid of the klp_reloc

Re: livepatch: reuse module loader code to write relocations

2015-12-16 Thread Miroslav Benes
On Wed, 16 Dec 2015, Jessica Yu wrote: > +++ Jessica Yu [09/12/15 14:10 -0500]: > > +++ Josh Poimboeuf [08/12/15 12:38 -0600]: > > > > > > There was a lot of discussion for v1, so I'm not sure, but I thought we > > > ended up deciding to get rid of the klp_reloc_sec struct? Instead I > > > think

Re: livepatch: reuse module loader code to write relocations

2015-12-15 Thread Jessica Yu
+++ Jessica Yu [09/12/15 14:10 -0500]: +++ Josh Poimboeuf [08/12/15 12:38 -0600]: On Mon, Nov 30, 2015 at 11:21:17PM -0500, Jessica Yu wrote: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific relocation code in livepatch. Namely, we reuse appl

Re: livepatch: reuse module loader code to write relocations

2015-12-10 Thread Jessica Yu
+++ Josh Poimboeuf [10/12/15 15:41 -0600]: On Thu, Dec 10, 2015 at 04:33:29PM -0500, Jessica Yu wrote: +++ Josh Poimboeuf [10/12/15 08:28 -0600]: >On Wed, Dec 09, 2015 at 02:10:14PM -0500, Jessica Yu wrote: >>+++ Josh Poimboeuf [08/12/15 12:38 -0600]: + /* For each __klp_rela section f

Re: livepatch: reuse module loader code to write relocations

2015-12-10 Thread Josh Poimboeuf
On Thu, Dec 10, 2015 at 04:33:29PM -0500, Jessica Yu wrote: > +++ Josh Poimboeuf [10/12/15 08:28 -0600]: > >On Wed, Dec 09, 2015 at 02:10:14PM -0500, Jessica Yu wrote: > >>+++ Josh Poimboeuf [08/12/15 12:38 -0600]: > + /* For each __klp_rela section for this object */ > + klp_for_each_reloc

Re: livepatch: reuse module loader code to write relocations

2015-12-10 Thread Jessica Yu
+++ Josh Poimboeuf [10/12/15 08:28 -0600]: On Wed, Dec 09, 2015 at 02:10:14PM -0500, Jessica Yu wrote: +++ Josh Poimboeuf [08/12/15 12:38 -0600]: >>+ /* For each __klp_rela section for this object */ >>+ klp_for_each_reloc_sec(obj, reloc_sec) { >>+ relindex = reloc_sec-

Re: livepatch: reuse module loader code to write relocations

2015-12-10 Thread Josh Poimboeuf
On Wed, Dec 09, 2015 at 02:10:14PM -0500, Jessica Yu wrote: > +++ Josh Poimboeuf [08/12/15 12:38 -0600]: > >>+ /* For each __klp_rela section for this object */ > >>+ klp_for_each_reloc_sec(obj, reloc_sec) { > >>+ relindex = reloc_sec->index; > >>+ num_relas = pmod->sechdrs[

Re: livepatch: reuse module loader code to write relocations

2015-12-09 Thread Jessica Yu
+++ Josh Poimboeuf [08/12/15 12:38 -0600]: On Mon, Nov 30, 2015 at 11:21:17PM -0500, Jessica Yu wrote: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific relocation code in livepatch. Namely, we reuse apply_relocate_add() in the module loader to

Re: livepatch: reuse module loader code to write relocations

2015-12-01 Thread Jessica Yu
+++ Jessica Yu [30/11/15 23:21 -0500]: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific relocation code in livepatch. Namely, we reuse apply_relocate_add() in the module loader to write relocations instead of duplicating functionality in livepa

Re: livepatch: reuse module loader code to write relocations

2015-11-13 Thread Miroslav Benes
On Thu, 12 Nov 2015, Josh Poimboeuf wrote: > On Thu, Nov 12, 2015 at 03:22:44PM -0500, Jessica Yu wrote: > > Looking into this more, I think we do need one __klp_rela section per > > function being patched. Each rela section is linked to the section to > > which the relocations apply via the rela

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Jessica Yu
+++ Josh Poimboeuf [12/11/15 14:32 -0600]: On Thu, Nov 12, 2015 at 03:22:44PM -0500, Jessica Yu wrote: Looking into this more, I think we do need one __klp_rela section per function being patched. Each rela section is linked to the section to which the relocations apply via the rela section's s

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Jessica Yu
+++ Jessica Yu [12/11/15 14:14 -0500]: +++ Miroslav Benes [12/11/15 16:27 +0100]: On Wed, 11 Nov 2015, Jessica Yu wrote: +++ Miroslav Benes [11/11/15 15:30 +0100]: On Mon, 9 Nov 2015, Jessica Yu wrote: So I guess we don't need klp_reloc anymore. Yes, that's correct. I am noticing just now

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Josh Poimboeuf
On Thu, Nov 12, 2015 at 03:22:44PM -0500, Jessica Yu wrote: > Looking into this more, I think we do need one __klp_rela section per > function being patched. Each rela section is linked to the section to > which the relocations apply via the rela section's sh_info field. In > SHT_RELA sections, th

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Jessica Yu
+++ Josh Poimboeuf [12/11/15 11:40 -0600]: On Thu, Nov 12, 2015 at 04:27:01PM +0100, Miroslav Benes wrote: On Wed, 11 Nov 2015, Jessica Yu wrote: > +++ Miroslav Benes [11/11/15 15:30 +0100]: > > On Mon, 9 Nov 2015, Jessica Yu wrote: > > > > So I guess we don't need klp_reloc anymore. > > Yes, t

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Jessica Yu
+++ Miroslav Benes [12/11/15 16:27 +0100]: On Wed, 11 Nov 2015, Jessica Yu wrote: +++ Miroslav Benes [11/11/15 15:30 +0100]: > On Mon, 9 Nov 2015, Jessica Yu wrote: > > So I guess we don't need klp_reloc anymore. Yes, that's correct. I am noticing just now that I forgot to remove the klp_reloc

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Josh Poimboeuf
On Thu, Nov 12, 2015 at 04:27:01PM +0100, Miroslav Benes wrote: > On Wed, 11 Nov 2015, Jessica Yu wrote: > > > +++ Miroslav Benes [11/11/15 15:30 +0100]: > > > On Mon, 9 Nov 2015, Jessica Yu wrote: > > > > > > So I guess we don't need klp_reloc anymore. > > > > Yes, that's correct. I am noticing

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Miroslav Benes
On Wed, 11 Nov 2015, Jessica Yu wrote: > +++ Miroslav Benes [11/11/15 15:30 +0100]: > > On Mon, 9 Nov 2015, Jessica Yu wrote: > > > > So I guess we don't need klp_reloc anymore. > > Yes, that's correct. I am noticing just now that I forgot to remove > the klp_reloc struct definition from livepatc

Re: livepatch: reuse module loader code to write relocations

2015-11-12 Thread Petr Mladek
On Wed 2015-11-11 13:27:18, Jessica Yu wrote: > Basically, the patch module code is expected to build the reloc_secs > list for each object that is being patched. For example in kpatch, the > patch module generates this list in patch_init(). Like you guessed, it > does go through all the elf sectio

Re: livepatch: reuse module loader code to write relocations

2015-11-11 Thread Jessica Yu
+++ Miroslav Benes [11/11/15 15:30 +0100]: On Mon, 9 Nov 2015, Jessica Yu wrote: diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index 31db7a0..601e892 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -85,7 +85,7 @@ struct klp_reloc { /** * struct

Re: livepatch: reuse module loader code to write relocations

2015-11-11 Thread Jessica Yu
+++ Petr Mladek [11/11/15 16:22 +0100]: On Mon 2015-11-09 23:45:53, Jessica Yu wrote: Reuse module loader code to write relocations, thereby eliminating the need for architecture specific code in livepatch. Namely, we reuse apply_relocate_add() in the module loader to write relocs instead of dup