Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbbKKPXB (ORCPT ); Wed, 11 Nov 2015 10:23:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:40306 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbbKKPW7 (ORCPT ); Wed, 11 Nov 2015 10:22:59 -0500 Date: Wed, 11 Nov 2015 16:22:57 +0100 From: Petr Mladek To: Jessica Yu Cc: Rusty Russell , Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Miroslav Benes , linux-api@vger.kernel.org, live-patching@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 3/5] livepatch: reuse module loader code to write relocations Message-ID: <20151111152256.GP2599@pathway.suse.cz> References: <1447130755-17383-1-git-send-email-jeyu@redhat.com> <1447130755-17383-4-git-send-email-jeyu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447130755-17383-4-git-send-email-jeyu@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2072 Lines: 56 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 > duplicating functionality in livepatch's klp_write_module_reloc(). To > apply relocation sections, remaining SHN_LIVEPATCH symbols referenced by > relocs are resolved and then apply_relocate_add() is called to apply > those relocations. > > Signed-off-by: Jessica Yu > --- > include/linux/livepatch.h | 11 ++++-- > include/linux/module.h | 6 ++++ > kernel/livepatch/core.c | 89 +++++++++++++++++++++++++++++------------------ > 3 files changed, 70 insertions(+), 36 deletions(-) > > index 087a8c7..26c419f 100644 > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -28,6 +28,8 @@ > #include > #include > #include > +#include > +#include > > /** > * struct klp_ops - structure for tracking registered ftrace ops structs > @@ -281,46 +283,54 @@ static int klp_find_external_symbol(struct module *pmod, const char *name, > } > > static int klp_write_object_relocations(struct module *pmod, > - struct klp_object *obj) > + struct klp_object *obj, > + struct klp_patch *patch) > { [...] > + > + /* For each __klp_rela section for this object */ > + list_for_each_entry(reloc_sec, &obj->reloc_secs, list) { Who, when, and how will define reloc_secs, please? I guess that it is just an optimization. It helps to avoid going through all elf sections of all livepatch modules. Therefore, I think that we might fill this when the livepatch module is loaded. But I do not see the code for this. Best Regards, Petr -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/