From: Jessica Yu <jeyu@redhat.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>,
Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>,
Jiri Kosina <jikos@kernel.org>,
Chris J Arges <chris.j.arges@canonical.com>,
Eugene Shatokhin <eugene.shatokhin@rosalab.ru>
Cc: live-patching@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org, Jessica Yu <jeyu@redhat.com>
Subject: [PATCH v2 1/2] livepatch: use arch_klp_init_object_loaded() to finish arch-specific tasks
Date: Thu, 21 Jul 2016 01:23:59 -0400 [thread overview]
Message-ID: <1469078640-26798-2-git-send-email-jeyu@redhat.com> (raw)
In-Reply-To: <1469078640-26798-1-git-send-email-jeyu@redhat.com>
Introduce arch_klp_init_object_loaded() to complete any additional
arch-specific tasks during patching. Architecture code may override this
function.
Signed-off-by: Jessica Yu <jeyu@redhat.com>
---
include/linux/livepatch.h | 3 +++
kernel/livepatch/core.c | 12 ++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index a93a0b2..9072f04 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -116,6 +116,9 @@ int klp_unregister_patch(struct klp_patch *);
int klp_enable_patch(struct klp_patch *);
int klp_disable_patch(struct klp_patch *);
+void arch_klp_init_object_loaded(struct klp_patch *patch,
+ struct klp_object *obj);
+
/* Called from the module loader during module coming/going states */
int klp_module_coming(struct module *mod);
void klp_module_going(struct module *mod);
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 5c2bc10..164eff6 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -274,7 +274,6 @@ static int klp_write_object_relocations(struct module *pmod,
objname = klp_is_module(obj) ? obj->name : "vmlinux";
- module_disable_ro(pmod);
/* For each klp relocation section */
for (i = 1; i < pmod->klp_info->hdr.e_shnum; i++) {
sec = pmod->klp_info->sechdrs + i;
@@ -309,7 +308,6 @@ static int klp_write_object_relocations(struct module *pmod,
break;
}
- module_enable_ro(pmod);
return ret;
}
@@ -763,6 +761,12 @@ static int klp_init_func(struct klp_object *obj, struct klp_func *func)
func->old_sympos ? func->old_sympos : 1);
}
+/* Arches may override this to finish any remaining arch-specific tasks */
+void __weak arch_klp_init_object_loaded(struct klp_patch *patch,
+ struct klp_object *obj)
+{
+}
+
/* parts of the initialization that is done only when the object is loaded */
static int klp_init_object_loaded(struct klp_patch *patch,
struct klp_object *obj)
@@ -770,10 +774,14 @@ static int klp_init_object_loaded(struct klp_patch *patch,
struct klp_func *func;
int ret;
+ module_disable_ro(patch->mod);
ret = klp_write_object_relocations(patch->mod, obj);
if (ret)
return ret;
+ arch_klp_init_object_loaded(patch, obj);
+ module_enable_ro(patch->mod);
+
klp_for_each_func(obj, func) {
ret = klp_find_object_symbol(obj->name, func->old_name,
func->old_sympos,
--
2.5.5
next prev parent reply other threads:[~2016-07-21 5:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 5:23 [PATCH v2 0/2] Fix issue with alternatives/paravirt patches Jessica Yu
2016-07-21 5:23 ` Jessica Yu [this message]
2016-08-02 8:25 ` [PATCH v2 1/2] livepatch: use arch_klp_init_object_loaded() to finish arch-specific tasks Miroslav Benes
2016-07-21 5:24 ` [PATCH v2 2/2] livepatch/x86: apply alternatives and paravirt patches after relocations Jessica Yu
2016-08-02 8:59 ` Miroslav Benes
2016-08-02 12:59 ` Petr Mladek
2016-08-02 13:02 ` Jiri Kosina
2016-07-26 20:59 ` [PATCH v2 0/2] Fix issue with alternatives/paravirt patches Josh Poimboeuf
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=1469078640-26798-2-git-send-email-jeyu@redhat.com \
--to=jeyu@redhat.com \
--cc=chris.j.arges@canonical.com \
--cc=eugene.shatokhin@rosalab.ru \
--cc=jikos@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=x86@kernel.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).