[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1481043967-15602-3-git-send-email-abelvesa@linux.com>
Date: Tue, 6 Dec 2016 17:06:02 +0000
From: Abel Vesa <abelvesa@...ux.com>
To: linux@...linux.org.uk, jpoimboe@...hat.com, jeyu@...hat.com,
jikos@...nel.org, mbenes@...e.cz, pmladek@...e.com
Cc: rostedt@...dmis.org, mingo@...hat.com, gregkh@...uxfoundation.org,
geert+renesas@...der.be, davem@...emloft.net,
akpm@...ux-foundation.org, emil.l.velikov@...il.com,
mchehab@...nel.org, linux@...ck-us.net, ard.biesheuvel@...aro.org,
jens.wiklander@...aro.org, jean-philippe.brucker@....com,
viro@...iv.linux.org.uk, stefano.stabellini@...citrix.com,
chris.brandt@...esas.com, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
live-patching@...r.kernel.org, Abel Vesa <abelvesa@...ux.com>
Subject: [PATCH 2/7] arm: ftrace: Add call modify mechanism
Function ftrace_modify_call provides a way to replace ftrace_stub
with the ftrace function. This helps the klp_ftrace_handler to be
called via ftrace_ops_no_ops, which in turn will set the pc with
the patched function's starting address. This is used for
livepatching.
Signed-off-by: Abel Vesa <abelvesa@...ux.com>
---
arch/arm/kernel/ftrace.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 3f17594..cb4543a 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -139,6 +139,15 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
ret = ftrace_modify_code(pc, 0, new, false);
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+ if (!ret) {
+ pc = (unsigned long)&ftrace_regs_call;
+ new = ftrace_call_replace(pc, (unsigned long)func);
+
+ ret = ftrace_modify_code(pc, 0, new, false);
+ }
+#endif
+
#ifdef CONFIG_OLD_MCOUNT
if (!ret) {
pc = (unsigned long)&ftrace_call_old;
@@ -151,6 +160,18 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ret;
}
+int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
+ unsigned long addr)
+{
+ unsigned long pc = rec->ip;
+ u32 old, new;
+
+ old = arm_gen_branch(pc, old_addr);
+ new = arm_gen_branch(pc, addr);
+
+ return ftrace_modify_code(pc, old, new, true);
+}
+
int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
{
unsigned long new, old;
--
2.7.4
Powered by blists - more mailing lists